Skip to content

Commit

Permalink
Highlight which columns are being shown
Browse files Browse the repository at this point in the history
  • Loading branch information
pflooky committed Nov 12, 2023
1 parent bda8f82 commit aaa5124
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
21 changes: 18 additions & 3 deletions docs/javascripts/tableselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,29 @@ document$.subscribe(function() {

let columnIdx = el.getAttribute("data-column");
let column = dataTable.column(columnIdx);
let isColVisible = column.visible();

// Toggle the visibility
column.visible(!column.visible());
// Toggle the visibility of the column
column.visible(!isColVisible);
// Toggle the highlighting of the button
if (el.classList.contains("md-button-column-visible")) {
el.classList.remove("md-button-column-visible");
} else {
el.classList.add("md-button-column-visible");
}
});
});

// Toggle on the visible buttons
document.querySelectorAll(".md-button.toggle-vis").forEach((el) => {
if (parseInt(el.getAttribute("data-column")) < 4) {
el.classList.add("md-button-column-visible");
}
});

// Toggle on the visible columns
let numCols = dataTable.columns().nodes().length;
if (numCols > 4) {
if (numCols >= 4) {
for (let i = 4; i < numCols; i++) {
let column = dataTable.column(i);
column.visible(false);
Expand Down
4 changes: 4 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
.sorting_disabled {
font-size: 0.8rem;
}

.md-button-column-visible {
background-color: royalblue;
}
21 changes: 18 additions & 3 deletions site/javascripts/tableselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,29 @@ document$.subscribe(function() {

let columnIdx = el.getAttribute("data-column");
let column = dataTable.column(columnIdx);
let isColVisible = column.visible();

// Toggle the visibility
column.visible(!column.visible());
// Toggle the visibility of the column
column.visible(!isColVisible);
// Toggle the highlighting of the button
if (el.classList.contains("md-button-column-visible")) {
el.classList.remove("md-button-column-visible");
} else {
el.classList.add("md-button-column-visible");
}
});
});

// Toggle on the visible buttons
document.querySelectorAll(".md-button.toggle-vis").forEach((el) => {
if (parseInt(el.getAttribute("data-column")) < 4) {
el.classList.add("md-button-column-visible");
}
});

// Toggle on the visible columns
let numCols = dataTable.columns().nodes().length;
if (numCols > 4) {
if (numCols >= 4) {
for (let i = 4; i < numCols; i++) {
let column = dataTable.column(i);
column.visible(false);
Expand Down
Binary file modified site/sitemap.xml.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions site/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
.sorting_disabled {
font-size: 0.8rem;
}

.md-button-column-visible {
background-color: royalblue;
}

0 comments on commit aaa5124

Please sign in to comment.