2018-03-28 20:12:11 +08:00
|
|
|
(function(global) {
|
|
|
|
'use strict';
|
|
|
|
global.SideBarToggle = (function() {
|
2018-05-30 23:58:18 +08:00
|
|
|
var STORAGE_TOGGLE_KEY = "scinote-sidebar-toggled";
|
2018-03-28 20:12:11 +08:00
|
|
|
|
|
|
|
function show() {
|
2018-05-28 16:28:35 +08:00
|
|
|
$('#wrapper').removeClass('hidden2');
|
2018-03-28 20:12:11 +08:00
|
|
|
$('#wrapper').css('paddingLeft', '280px');
|
|
|
|
$('.navbar-secondary').css(
|
2019-12-04 21:19:19 +08:00
|
|
|
{ 'margin-left': '-280px', 'padding-left': '280px' }
|
2018-03-28 20:12:11 +08:00
|
|
|
);
|
2018-06-01 19:18:49 +08:00
|
|
|
$('#sidebar-arrow').attr('data-shown', '');
|
2018-05-30 22:46:27 +08:00
|
|
|
sessionStorage.setItem(STORAGE_TOGGLE_KEY, "un-toggled");
|
2018-03-28 20:12:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function hide() {
|
2018-05-28 16:28:35 +08:00
|
|
|
$('#wrapper').addClass('hidden2');
|
2018-03-28 20:12:11 +08:00
|
|
|
$('#wrapper').css('paddingLeft', '0');
|
|
|
|
$('.navbar-secondary').css({
|
|
|
|
'margin-left': '0',
|
2019-12-04 21:19:19 +08:00
|
|
|
'padding-left': '0'
|
2018-03-28 20:12:11 +08:00
|
|
|
});
|
2018-06-01 19:18:49 +08:00
|
|
|
$('#sidebar-arrow').removeAttr('data-shown');
|
2018-05-30 22:46:27 +08:00
|
|
|
sessionStorage.setItem(STORAGE_TOGGLE_KEY, "toggled");
|
2018-03-28 20:12:11 +08:00
|
|
|
}
|
|
|
|
|
2018-05-24 19:39:04 +08:00
|
|
|
function toggle() {
|
2018-06-01 19:18:49 +08:00
|
|
|
var btn = $('#sidebar-arrow');
|
2018-05-25 14:50:27 +08:00
|
|
|
if (btn.is('[data-shown]')) {
|
2018-05-24 19:39:04 +08:00
|
|
|
hide();
|
|
|
|
} else {
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-27 21:44:15 +08:00
|
|
|
function isShown() {
|
2018-06-01 19:18:49 +08:00
|
|
|
var btn = $('#sidebar-arrow');
|
2018-05-27 21:44:15 +08:00
|
|
|
return btn.is('[data-shown]');
|
2018-03-28 20:12:11 +08:00
|
|
|
}
|
|
|
|
|
2018-05-30 22:46:27 +08:00
|
|
|
function isToggledStorage() {
|
|
|
|
var val = sessionStorage.getItem(STORAGE_TOGGLE_KEY);
|
|
|
|
if (val === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return val === "toggled";
|
|
|
|
}
|
|
|
|
|
2018-03-28 20:12:11 +08:00
|
|
|
return Object.freeze({
|
|
|
|
show: show,
|
2018-05-24 19:39:04 +08:00
|
|
|
hide: hide,
|
2018-05-27 21:44:15 +08:00
|
|
|
toggle: toggle,
|
2018-05-30 22:46:27 +08:00
|
|
|
isShown: isShown,
|
|
|
|
isToggledStorage: isToggledStorage
|
2018-03-28 20:12:11 +08:00
|
|
|
})
|
|
|
|
})();
|
2018-05-30 22:46:27 +08:00
|
|
|
|
2018-07-19 23:56:42 +08:00
|
|
|
if (SideBarToggle.isToggledStorage()) {
|
|
|
|
SideBarToggle.hide();;
|
|
|
|
}
|
2018-03-28 20:12:11 +08:00
|
|
|
})(window);
|