fix position of navigation bar is not saved

This commit is contained in:
mlorb 2018-05-30 16:46:27 +02:00
parent 3253cac86f
commit 100ddf127d

View file

@ -1,3 +1,5 @@
var STORAGE_TOGGLE_KEY = "scinote-sidebar-toggled";
(function(global) {
'use strict';
global.SideBarToggle = (function() {
@ -12,6 +14,7 @@
{ 'margin-left': '-280px', 'padding-left': '294px' }
);
$('#toggle-sidebar-btn').attr('data-shown', '');
sessionStorage.setItem(STORAGE_TOGGLE_KEY, "un-toggled");
}
function hide() {
@ -25,6 +28,7 @@
'padding-left': '14px'
});
$('#toggle-sidebar-btn').removeAttr('data-shown');
sessionStorage.setItem(STORAGE_TOGGLE_KEY, "toggled");
}
function toggle() {
@ -41,11 +45,26 @@
return btn.is('[data-shown]');
}
function isToggledStorage() {
var val = sessionStorage.getItem(STORAGE_TOGGLE_KEY);
if (val === null) {
return null;
}
return val === "toggled";
}
return Object.freeze({
show: show,
hide: hide,
toggle: toggle,
isShown: isShown
isShown: isShown,
isToggledStorage: isToggledStorage
})
})();
$(document).ready(function() {
if (SideBarToggle.isToggledStorage()) {
SideBarToggle.hide();;
}
})
})(window);