mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-06 05:04:35 +08:00
fix position of navigation bar is not saved
This commit is contained in:
parent
3253cac86f
commit
100ddf127d
1 changed files with 20 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue