From 045d16c4717bf8b0bf942ba2d7ed64c3c8e5949f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20Deutschla=CC=88nder?= Date: Thu, 27 Apr 2017 15:14:18 +0200 Subject: [PATCH] SPR-953: menu state is-active and span.curid for site tools and user tools --- js/sidebar.js | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/js/sidebar.js b/js/sidebar.js index dc8160c..e6a923d 100644 --- a/js/sidebar.js +++ b/js/sidebar.js @@ -172,10 +172,6 @@ jQuery(function () { } }, - addTemplateMenuesCurrentStates = function () { - - }, - /** * Make sure the content area is always as high as the sidebar */ @@ -229,12 +225,48 @@ jQuery(function () { var $body = jQuery('body'); $body.toggleClass('show-mobile-sidebar'); }); + }, + + /** + * set is-active class if body has at least one of the given selectors + * @param selectorArray Array of selectors + * @param $nav container in which the $toggler is situated + */ + setActive = function(selectorArray, $nav) { + for(var i=0; i< selectorArray.length; i++) { + 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(''); + } + } + }, + + /** + * sets active states in site tool menu and user tool menu for certain modes + * adds sessionStorage behaviour + * + */ + initTemplateMenues = function () { + var $body = jQuery('body'), + $siteTools = $nav.find('> .nav-sitetools'), + $userTools = $nav.find('> .nav-usermenu'), + $templateMenus = $nav.find('> nav:not(.nav-main)'), + + stModes = ['recent', 'media', 'index'], + utModes = ['profile','admin']; + + setActive(stModes,$siteTools); + setActive(utModes,$userTools); + }; // main initContentNav(); initSidebarToggling(); initMenuHandling(); + initTemplateMenues(); initContentMinHeight(); initSearchToggling(); initMobileToggling();