Remember sidebar section state when browsing the wiki
So we do not have to open the same section of the sidebar every time, we click a link to a new page. It forgets the toggle-state if the content is manually or automatically widened, for example by clicking on an edit-button. SPR-883
This commit is contained in:
parent
cb7cc643bf
commit
2bd7f884e5
1 changed files with 26 additions and 1 deletions
|
@ -11,6 +11,20 @@ jQuery(function () {
|
|||
var setWideContent = function () {
|
||||
$nav.find('div.nav-panel').hide(); // close all panels
|
||||
jQuery('body').addClass('wide-content');
|
||||
removeToggleStorage();
|
||||
},
|
||||
|
||||
/**
|
||||
* removes information about the toggle-state
|
||||
*/
|
||||
removeToggleStorage = function () {
|
||||
for (var index=0; index <= sessionStorage.length; index += 1) {
|
||||
var item = sessionStorage.getItem('sidebar-section-' + index + '-open');
|
||||
if (!item) {
|
||||
break;
|
||||
}
|
||||
sessionStorage.removeItem('sidebar-section-' + index + '-open');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -46,6 +60,7 @@ jQuery(function () {
|
|||
focusFirstSubLink($panel);
|
||||
}
|
||||
});
|
||||
sessionStorage.setItem('sidebar-section-' + $toggler.data('index') + '-open', !isOpen);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -57,9 +72,13 @@ jQuery(function () {
|
|||
var $main = $nav.find('nav.nav-main');
|
||||
if (!$main.length) return;
|
||||
|
||||
if(jQuery('body').hasClass('wide-content')) {
|
||||
removeToggleStorage();
|
||||
}
|
||||
|
||||
var ELEMENT = JSINFO.template.sprintdoc.sidebar_toggle_elements;
|
||||
var $elements = $main.find(ELEMENT);
|
||||
$elements.each(function () {
|
||||
$elements.each(function (index) {
|
||||
var $me = jQuery(this),
|
||||
|
||||
// prepare text and the optional icon
|
||||
|
@ -83,6 +102,7 @@ jQuery(function () {
|
|||
.text(text)
|
||||
.wrapInner('<span class="lbl">')
|
||||
.prepend($icon)
|
||||
.data('index', index)
|
||||
;
|
||||
|
||||
// wrap all following siblings til the next element in a wrapper
|
||||
|
@ -102,6 +122,11 @@ jQuery(function () {
|
|||
if ($toggler.parent('li').length) {
|
||||
$toggler.parent('li').addClass('toggler');
|
||||
}
|
||||
|
||||
if (sessionStorage.getItem('sidebar-section-' + index + '-open') === 'true') {
|
||||
$wrap.css('display', 'block');
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue