mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-06 05:04:35 +08:00
Merge pull request #1182 from mlorb/ml-sci-2459
Fix position of navigation bar is not saved [SCI-2459]
This commit is contained in:
commit
c17a947969
1 changed files with 19 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
(function(global) {
|
(function(global) {
|
||||||
'use strict';
|
'use strict';
|
||||||
global.SideBarToggle = (function() {
|
global.SideBarToggle = (function() {
|
||||||
|
var STORAGE_TOGGLE_KEY = "scinote-sidebar-toggled";
|
||||||
|
|
||||||
function show() {
|
function show() {
|
||||||
$('#wrapper').removeClass('hidden2');
|
$('#wrapper').removeClass('hidden2');
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
{ 'margin-left': '-280px', 'padding-left': '294px' }
|
{ 'margin-left': '-280px', 'padding-left': '294px' }
|
||||||
);
|
);
|
||||||
$('#toggle-sidebar-btn').attr('data-shown', '');
|
$('#toggle-sidebar-btn').attr('data-shown', '');
|
||||||
|
sessionStorage.setItem(STORAGE_TOGGLE_KEY, "un-toggled");
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
|
@ -25,6 +27,7 @@
|
||||||
'padding-left': '14px'
|
'padding-left': '14px'
|
||||||
});
|
});
|
||||||
$('#toggle-sidebar-btn').removeAttr('data-shown');
|
$('#toggle-sidebar-btn').removeAttr('data-shown');
|
||||||
|
sessionStorage.setItem(STORAGE_TOGGLE_KEY, "toggled");
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
|
@ -41,11 +44,26 @@
|
||||||
return btn.is('[data-shown]');
|
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({
|
return Object.freeze({
|
||||||
show: show,
|
show: show,
|
||||||
hide: hide,
|
hide: hide,
|
||||||
toggle: toggle,
|
toggle: toggle,
|
||||||
isShown: isShown
|
isShown: isShown,
|
||||||
|
isToggledStorage: isToggledStorage
|
||||||
})
|
})
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
if (SideBarToggle.isToggledStorage()) {
|
||||||
|
SideBarToggle.hide();;
|
||||||
|
}
|
||||||
|
})
|
||||||
})(window);
|
})(window);
|
||||||
|
|
Loading…
Add table
Reference in a new issue