Skip to content

Commit e4fe3b6

Browse files
committed
Update sidebar menu css when selected #4
* Add .btn-change.selected css for when sidebar menu is currently selected * Fix node view to only redraw when there is a currentId * Fix chart summary files_count error Signed-off-by: Jillian Daguil <[email protected]>
1 parent 8f06aea commit e4fe3b6

File tree

5 files changed

+42
-33
lines changed

5 files changed

+42
-33
lines changed

assets/css/main.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ div.node-content {
239239
.sidebar-nav li .btn-sidebar:hover {
240240
text-decoration: none;
241241
color: #fff;
242-
background: rgba(255,255,255,0.2);
242+
background: rgba(255, 255, 255, 0.25);
243243
}
244244

245245
.sidebar-nav li .btn-sidebar:active,
@@ -248,6 +248,11 @@ div.node-content {
248248
outline: none;
249249
}
250250

251+
.sidebar-nav li .btn-change.selected {
252+
color: #fff;
253+
background: rgba(255, 255, 255, 0.12);
254+
}
255+
251256
/*---------------------------------------
252257
DataTables custom
253258
-----------------------------------------*/

assets/js/aboutCodeDB.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class AboutCodeDB {
239239
})
240240
})
241241
.then((count) => {
242-
return count.files_count;
242+
return count ? count.files_count : 0;
243243
});
244244
}
245245

assets/js/nodeview.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ class NodeView {
111111
}
112112

113113
redraw() {
114-
this._update(this.currentId);
114+
if (this.currentId) {
115+
this._update(this.currentId);
116+
}
115117
}
116118

117119
// Resize the spacing between nodes

assets/js/renderer.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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
});

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,22 @@
7272
</button>
7373
</li>
7474
<li>
75-
<button class="btn btn-sidebar" id="show-bar-chart" data-toggle="tooltip" data-placement="right" title="Chart Summary View">
75+
<button class="btn btn-sidebar btn-change" id="show-bar-chart" data-toggle="tooltip" data-placement="right" title="Chart Summary View">
7676
<i class="fa fa-bar-chart" aria-hidden="true"></i>
7777
</button>
7878
</li>
7979
<li>
80-
<button class="btn btn-sidebar" id="show-clue-table" data-toggle="tooltip" title="Table View">
80+
<button class="btn btn-sidebar btn-change" id="show-clue-table" data-toggle="tooltip" title="Table View">
8181
<i class="fa fa-table" aria-hidden="true"></i>
8282
</button>
8383
</li>
8484
<li>
85-
<button class="btn btn-sidebar" id="show-tree" data-toggle="tooltip" title="Node View">
85+
<button class="btn btn-sidebar btn-change" id="show-tree" data-toggle="tooltip" title="Node View">
8686
<i class="fa fa-code-fork" aria-hidden="true"></i>
8787
</button>
8888
</li>
8989
<li>
90-
<button class="btn btn-sidebar" id="show-component-table" data-toggle="modal" data-placement="right" title="Component Summary View">
90+
<button class="btn btn-sidebar btn-change" id="show-component-table" data-toggle="modal" data-placement="right" title="Component Summary View">
9191
<i class="fa fa-list-ol" aria-hidden="true"></i>
9292
</button>
9393
</li>

0 commit comments

Comments
 (0)