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