@@ -109,6 +109,20 @@ $(document).ready(function () {
109109 // The Electron module used to communicate asynchronously from a renderer process to the main process.
110110 const ipcRenderer = require ( 'electron' ) . ipcRenderer ;
111111
112+ // Setup css styling for sidebar button state when clicked.
113+ const navButtons = $ ( "#sidebar-wrapper" ) . find ( ".btn-change" ) ;
114+ navButtons . each ( ( i , clickedButton ) => {
115+ $ ( clickedButton ) . click ( function ( ) {
116+ navButtons . each ( ( i , button ) => {
117+ if ( button === clickedButton ) {
118+ $ ( button ) . addClass ( "selected" ) ;
119+ } else {
120+ $ ( button ) . removeClass ( "selected" ) ;
121+ }
122+ } ) ;
123+ } ) ;
124+ } ) ;
125+
112126 // Define DOM element constants for the modal dialog.
113127 const componentModal = {
114128 container : $ ( "#nodeModal" ) ,
@@ -455,59 +469,49 @@ $(document).ready(function () {
455469 splitter . setSizes ( splitSizes ) ;
456470 }
457471
458- // Show Table View (aka " clue DataTable"). Hide node view and component summary table.
459- function showTableView ( ) {
472+ // Show clue DataTable. Hide node view and component summary table
473+ showClueButton . click ( ( ) => {
460474 restoreSplitterSizes ( ) ;
461475 $ ( ".gutter-horizontal" ) . removeClass ( "div-hide" ) . addClass ( "div-show" ) ;
462476 cluesContainer . show ( ) ;
463477 nodeContainer . hide ( ) ;
464478 componentContainer . hide ( ) ;
465479 barChartContainer . hide ( ) ;
466480 cluesTable . draw ( ) ;
467- }
468-
469- // Show clue DataTable. Hide node view and component summary table
470- showClueButton . click ( showTableView ) ;
481+ } ) ;
471482
472483 // Show clue DataTable. Hide node view and component summary table -- custom menu
473- ipcRenderer . on ( 'table-view' , showTableView ) ;
484+ ipcRenderer . on ( 'table-view' , ( ) => showClueButton . trigger ( "click" ) ) ;
474485
475486 // Show node view. Hide clue and component table
476- function showNodeView ( ) {
487+ showNodeViewButton . click ( ( ) => {
477488 restoreSplitterSizes ( ) ;
478489 $ ( ".gutter-horizontal" ) . removeClass ( "div-hide" ) . addClass ( "div-show" ) ;
479490 nodeContainer . show ( ) ;
480491 cluesContainer . hide ( ) ;
481492 componentContainer . hide ( ) ;
482493 barChartContainer . hide ( ) ;
483494 nodeView . redraw ( ) ;
484- }
485-
486- // Show node view. Hide clue and component table
487- showNodeViewButton . click ( showNodeView ) ;
495+ } ) ;
488496
489497 // Show node view. Hide clue and component table -- custom menu
490- ipcRenderer . on ( 'node-view' , showNodeView ) ;
498+ ipcRenderer . on ( 'node-view' , ( ) => showNodeViewButton . trigger ( "click" ) ) ;
491499
492500 // Show component summary table. Hide DataTable and node view
493- function showComponentSummaryView ( ) {
501+ showComponentButton . click ( ( ) => {
494502 $ ( ".gutter-horizontal" ) . removeClass ( "div-show" ) . addClass ( "div-hide" ) ;
495503 splitter . collapse ( 0 ) ;
496504 componentContainer . show ( ) ;
497505 nodeContainer . hide ( ) ;
498506 cluesContainer . hide ( ) ;
499507 barChartContainer . hide ( ) ;
500508 componentsTable . reload ( ) ;
501- }
502-
503- // Show component summary table. Hide DataTable and node view
504- showComponentButton . click ( showComponentSummaryView ) ;
509+ } ) ;
505510
506511 // Show component summary table. Hide DataTable and node view -- custom menu
507- ipcRenderer . on ( 'component-summary-view' , showComponentSummaryView ) ;
512+ ipcRenderer . on ( 'component-summary-view' , ( ) => showComponentButton . trigger ( "click" ) ) ;
508513
509- // Show bar chart table. Hide other views
510- function showBarChartView ( ) {
514+ showBarChartButton . click ( ( ) => {
511515 restoreSplitterSizes ( ) ;
512516 $ ( ".gutter-horizontal" ) . removeClass ( "div-hide" ) . addClass ( "div-show" ) ;
513517 barChartContainer . show ( ) ;
@@ -519,12 +523,10 @@ $(document).ready(function () {
519523 . then ( ( value ) => {
520524 barChartTotalFiles . text ( value ) ;
521525 } ) ;
522- }
523-
524- showBarChartButton . click ( showBarChartView ) ;
526+ } ) ;
525527
526528 // Show chart summary table. Hide other views -- custom menu
527- ipcRenderer . on ( 'chart-summary-view' , showBarChartView ) ;
529+ ipcRenderer . on ( 'chart-summary-view' , ( ) => showBarChartButton . trigger ( "click" ) ) ;
528530
529531 // Creates the database and all View objects from a SQLite file
530532 function loadDatabaseFromFile ( fileName ) {
@@ -808,5 +810,5 @@ $(document).ready(function () {
808810 } ) ;
809811
810812 restoreSplitterSizes ( ) ;
811- showTableView ( ) ;
813+ showClueButton . trigger ( "click" ) ;
812814} ) ;
0 commit comments