Improved sidebar open/close handling
This commit is contained in:
parent
96a6830e61
commit
6bc2787602
@ -14,6 +14,7 @@
|
||||
});
|
||||
|
||||
$.AdminLTESidebarTweak = {};
|
||||
$.AdminLTESidebarTweak.Open = true;
|
||||
|
||||
$.AdminLTESidebarTweak.options = {
|
||||
EnableRemember: true,
|
||||
@ -24,6 +25,29 @@
|
||||
// Work out our timezone.
|
||||
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
/**
|
||||
* Open and close the sidebar
|
||||
* @param state
|
||||
* @param addclass
|
||||
*/
|
||||
function sidebaropenclose(state,addclass) {
|
||||
// Dont do anything if the state hasnt changed.
|
||||
if (state == $.AdminLTESidebarTweak.Open) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.AdminLTESidebarTweak.Open = state;
|
||||
|
||||
if (addclass !== 'undefined')
|
||||
$("body")
|
||||
.addClass(state ? 'sidebar-open' : 'sidebar-collapse');
|
||||
|
||||
$(this).delay(500).queue(function() {
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
$(this).dequeue();
|
||||
});
|
||||
}
|
||||
|
||||
$(function () {
|
||||
"use strict";
|
||||
|
||||
@ -31,22 +55,15 @@
|
||||
if($.AdminLTESidebarTweak.options.EnableRemember) {
|
||||
document.cookie = "toggleState=closed;path=/";
|
||||
|
||||
$("body").delay(500).queue(function () {
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
$(this).dequeue();
|
||||
});
|
||||
$("body").queue(sidebaropenclose(false));
|
||||
}
|
||||
});
|
||||
|
||||
// @todo this is not firing.
|
||||
$("body").on("shown.lte.pushmenu", function(){
|
||||
if($.AdminLTESidebarTweak.options.EnableRemember){
|
||||
document.cookie = "toggleState=opened;path=/";
|
||||
|
||||
$("body").delay(500).queue(function () {
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
$(this).dequeue();
|
||||
});
|
||||
$("body").queue(sidebaropenclose(true));
|
||||
}
|
||||
});
|
||||
|
||||
@ -60,12 +77,7 @@
|
||||
$(this).removeClass('hold-transition');
|
||||
});
|
||||
}else{
|
||||
$("body")
|
||||
.addClass('sidebar-collapse')
|
||||
.delay(500).queue(function () {
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
$(this).dequeue();
|
||||
});
|
||||
$("body").queue(sidebaropenclose(false,true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user