Remember sidebar collapsed state

This commit is contained in:
Bernd Bestel 2018-07-14 11:25:19 +02:00
parent e5a4d11c0b
commit aa0771877f
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300

View File

@ -32,6 +32,32 @@ if (!Grocy.ActiveNav.isEmpty())
}
}
var observer = new MutationObserver(function(mutations)
{
mutations.forEach(function(mutation)
{
if (mutation.attributeName === "class")
{
var attributeValue = $(mutation.target).prop(mutation.attributeName);
if (attributeValue.contains("sidenav-toggled"))
{
window.localStorage.setItem("sidebar_state", "collapsed");
}
else
{
window.localStorage.setItem("sidebar_state", "expanded");
}
}
});
});
observer.observe(document.body, {
attributes: true
});
if (window.localStorage.getItem("sidebar_state") === "collapsed")
{
$("#sidenavToggler").click();
}
$.timeago.settings.allowFuture = true;
RefreshContextualTimeago = function()
{