refactor(hide-columns): minor renaming and preparation for css work
This commit is contained in:
parent
bc023f5bfb
commit
68fc4e4c3a
@ -57,12 +57,12 @@ export class HideColumns {
|
||||
}
|
||||
|
||||
setupHideButton(th, prevHidden) {
|
||||
const hider = document.createElement('button');
|
||||
const hider = document.createElement('span');
|
||||
hider.setAttribute(HIDER_TEXT_ATTR, th.innerText);
|
||||
|
||||
hider.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
this.toggleColumnVisibility(th, hider);
|
||||
this.switchColumnDisplay(th, hider);
|
||||
});
|
||||
|
||||
// TODO fade in / fade out animation in css
|
||||
@ -81,23 +81,18 @@ export class HideColumns {
|
||||
this._tableUtilContainer.appendChild(hider);
|
||||
}
|
||||
|
||||
// TODO better name
|
||||
toggleColumnVisibility(th, hider) {
|
||||
switchColumnDisplay(th, hider) {
|
||||
const storageKey = this.getStorageKey(th);
|
||||
|
||||
const hidden = !this._storageManager.load(storageKey);
|
||||
|
||||
// hide/unhide column
|
||||
this.updateColumnDisplay(th.cellIndex, hidden);
|
||||
|
||||
// tweak hider button
|
||||
this.updateHider(hider, hidden);
|
||||
|
||||
// persist new hidden setting for column
|
||||
this._storageManager.save(storageKey, hidden);
|
||||
}
|
||||
|
||||
// TODO better name
|
||||
updateColumnDisplay(columnIndex, hidden) {
|
||||
this._element.getElementsByTagName('tr').forEach(row => {
|
||||
if (row.cells[columnIndex]) {
|
||||
@ -106,7 +101,6 @@ export class HideColumns {
|
||||
});
|
||||
}
|
||||
|
||||
// TODO better name
|
||||
updateHider(hider, hidden) {
|
||||
// TODO set css classes instead
|
||||
if (hidden) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user