Remember sidebar collapse state

This commit is contained in:
Deon George 2018-08-12 17:01:50 +10:00
parent f8d7432965
commit 3af5ae6466

View File

@ -12,6 +12,44 @@
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.AdminLTESidebarTweak = {};
$.AdminLTESidebarTweak.options = {
EnableRemember: true,
//Removes the transition after page reload.
NoTransitionAfterReload: false
};
$(function () {
"use strict";
$("body").on("collapsed.pushMenu", function(){
if($.AdminLTESidebarTweak.options.EnableRemember){
document.cookie = "toggleState=closed";
}
});
$("body").on("expanded.pushMenu", function(){
if($.AdminLTESidebarTweak.options.EnableRemember){
document.cookie = "toggleState=opened";
}
});
if($.AdminLTESidebarTweak.options.EnableRemember){
var re = new RegExp('toggleState' + "=([^;]+)");
var value = re.exec(document.cookie);
var toggleState = (value != null) ? unescape(value[1]) : null;
if(toggleState == 'closed'){
if($.AdminLTESidebarTweak.options.NoTransitionAfterReload){
$("body").addClass('sidebar-collapse hold-transition').delay(100).queue(function(){
$(this).removeClass('hold-transition');
});
}else{
$("body").addClass('sidebar-collapse');
}
}
}
});
</script>
<!-- Optionally, you can add Slimscroll and FastClick plugins.