mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°3564 Alert and CollapsibleSectionState can now be saved
This commit is contained in:
@@ -24,7 +24,10 @@ $(function () {
|
||||
{
|
||||
// default options
|
||||
options:
|
||||
{},
|
||||
{
|
||||
hasCollapsibleStateSavingEnabled: false,
|
||||
collapsibleStateStorageKey: null,
|
||||
},
|
||||
css_classes:
|
||||
{
|
||||
opened: 'ibo-is-opened',
|
||||
@@ -51,6 +54,26 @@ $(function () {
|
||||
},
|
||||
_onCollapseTogglerClick: function (oEvent) {
|
||||
this.element.toggleClass(this.css_classes.opened);
|
||||
|
||||
if (this.options.hasCollapsibleStateSavingEnabled) {
|
||||
localStorage.setItem(
|
||||
this.options.collapsibleStateStorageKey,
|
||||
this.element.hasClass(this.css_classes.opened)
|
||||
);
|
||||
}
|
||||
},
|
||||
enableSaveCollapsibleState: function (bOpenedByDefault, sSectionStateStorageKey) {
|
||||
this.options.hasCollapsibleStateSavingEnabled = true;
|
||||
this.options.collapsibleStateStorageKey = sSectionStateStorageKey;
|
||||
|
||||
let bStoredSectionState = JSON.parse(localStorage.getItem(sSectionStateStorageKey));
|
||||
let bIsSectionOpenedInitially = (bStoredSectionState == null) ? bOpenedByDefault : bStoredSectionState;
|
||||
|
||||
if (bIsSectionOpenedInitially) {
|
||||
this.element.addClass(this.css_classes.opened);
|
||||
} else {
|
||||
this.element.removeClass(this.css_classes.opened);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user