mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-25 11:01:12 +00:00
[assets] Move localStorage chunks of code to their own file:
This should prevent a sync issue with updateDisplay not always being loaded on time.
This commit is contained in:
parent
964b47ea97
commit
6b0a3ce4b1
2 changed files with 9 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
/* globals setDisplay TabGroup updateDisplay */
|
||||
/* globals TabGroup */
|
||||
|
||||
// set up javascript listeners
|
||||
window.onload = function() {
|
||||
|
@ -28,14 +28,6 @@ window.onload = function() {
|
|||
|
||||
Array.from(document.getElementsByClassName('tab-group'))
|
||||
.forEach(t => new TabGroup(t));
|
||||
|
||||
// display based on localstorage vars
|
||||
document.querySelectorAll('[data-hide]')
|
||||
.forEach(t => setDisplay(t));
|
||||
|
||||
// update localstorage
|
||||
Array.from(document.getElementsByClassName('set-display'))
|
||||
.forEach(t => t.onclick = updateDisplay);
|
||||
};
|
||||
|
||||
function back(e) {
|
||||
|
|
|
@ -18,3 +18,11 @@ function setDisplay(el) {
|
|||
var value = window.localStorage.getItem(key);
|
||||
addRemoveClass(el, 'hidden', value);
|
||||
}
|
||||
|
||||
// display based on localstorage vars
|
||||
document.querySelectorAll('[data-hide]')
|
||||
.forEach(t => setDisplay(t));
|
||||
|
||||
// update localstorage
|
||||
Array.from(document.getElementsByClassName('set-display'))
|
||||
.forEach(t => t.onclick = updateDisplay);
|
||||
|
|
Loading…
Reference in a new issue