From 13c822c242fe3e6b6b0178bf99029a650ef49d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20Deutschla=CC=88nder?= Date: Thu, 27 Apr 2017 16:06:10 +0200 Subject: [PATCH] SPR-953: sessionStorage handling for template menus --- js/sidebar.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/js/sidebar.js b/js/sidebar.js index e6a923d..98ed6d0 100644 --- a/js/sidebar.js +++ b/js/sidebar.js @@ -237,7 +237,6 @@ jQuery(function () { var mode = selectorArray[i]; if(jQuery('body').is('.do-'+mode)){ setTogglerClass($nav.find('.nav'),'is-active'); - alert('a[href*="do='+mode+'"]'); $nav.find('a[href*="do='+mode+'"]').wrapAll(''); } } @@ -245,7 +244,7 @@ jQuery(function () { /** * sets active states in site tool menu and user tool menu for certain modes - * adds sessionStorage behaviour + * adds sessionStorage behaviour equivalent approach to content menus * */ initTemplateMenues = function () { @@ -257,16 +256,30 @@ jQuery(function () { stModes = ['recent', 'media', 'index'], utModes = ['profile','admin']; + /* set active states for site tool menu and user tool menu */ setActive(stModes,$siteTools); setActive(utModes,$userTools); + /* set data attributes for sessionStorage and check onload if one of the template menus should be opened */ + $templateMenus.each(function( index ) { + var $t = jQuery(this).find('.nav'), + y = $nav.find('.nav-main').find('.nav').length, + $toggler = ($t.is('a')) ? $t : $t.find('a:last'), + tIndex = y + index; + $toggler.data('index', tIndex); + if (window.sessionStorage.getItem('sidebar-section-' + tIndex + '-open') === 'true') { + jQuery(this).find('.nav-panel').css('display', 'block'); + setTogglerClass($toggler,'is-open'); + } + }); + }; // main initContentNav(); initSidebarToggling(); - initMenuHandling(); initTemplateMenues(); + initMenuHandling(); initContentMinHeight(); initSearchToggling(); initMobileToggling();