From 30aa8e9544ef9a54fd5c383f975e9f76d6e9d23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20Deutschla=CC=88nder?= Date: Thu, 27 Apr 2017 17:40:46 +0200 Subject: [PATCH] SPR-953: bugfixes for content-wide nav --- css/area_main-sidebar-nav.less | 3 ++- css/base.less | 2 +- css/base_structure.less | 2 +- css/plugins/starred.less | 3 +++ js/sidebar.js | 29 ++++++++++++++++++++++++----- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/css/area_main-sidebar-nav.less b/css/area_main-sidebar-nav.less index 0fac304..c099b28 100755 --- a/css/area_main-sidebar-nav.less +++ b/css/area_main-sidebar-nav.less @@ -173,7 +173,8 @@ } // without wrapping UL - nav > a.nav { + nav > a.nav, + nav div.nav a{ margin-left: -3.5rem; @media @screen_md-lg { diff --git a/css/base.less b/css/base.less index ea343b1..766cc31 100755 --- a/css/base.less +++ b/css/base.less @@ -43,7 +43,7 @@ @fix_border-radius: 3px; // inputs, editbox (textarea), buttons, content, code, quicksearch, msg -@toggle-showsidebar_width: 3.07rem; // shown sidebar after toggle +@toggle-showsidebar_width: 3.47rem; // shown sidebar after toggle @headericons-margin-xxs: .45rem; // screen xxs margin-top for header icons diff --git a/css/base_structure.less b/css/base_structure.less index f9ba184..b1516bf 100755 --- a/css/base_structure.less +++ b/css/base_structure.less @@ -166,7 +166,7 @@ .wide-content.showSidebar { .content { .row > .col-xs-12 { - margin-left: 2.1rem; + margin-left: 2.3rem; } } } diff --git a/css/plugins/starred.less b/css/plugins/starred.less index 057a04c..fcc8c4d 100644 --- a/css/plugins/starred.less +++ b/css/plugins/starred.less @@ -29,6 +29,9 @@ nav.nav-starred { ul { list-style: none; + &#sidebar-menu-starred { + margin-left: 0; + } li { margin-left: 0; svg { diff --git a/js/sidebar.js b/js/sidebar.js index 98ed6d0..3c62880 100644 --- a/js/sidebar.js +++ b/js/sidebar.js @@ -24,7 +24,7 @@ jQuery(function () { if (!item) { continue; } - window.sessionStorage.removeItem('sidebar-section-' + index + '-open'); + window.sessionStorage.setItem('sidebar-section-' + index + '-open', 'false'); } }, @@ -254,12 +254,20 @@ jQuery(function () { $templateMenus = $nav.find('> nav:not(.nav-main)'), stModes = ['recent', 'media', 'index'], - utModes = ['profile','admin']; + utModes = ['profile','admin'], + isWideContent = false; /* set active states for site tool menu and user tool menu */ setActive(stModes,$siteTools); setActive(utModes,$userTools); + if(jQuery('body').is('.wide-content')) { + window.sessionStorage.setItem('wide-content', true); + isWideContent = true; + } + + + /* 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'), @@ -267,14 +275,25 @@ jQuery(function () { $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'); + + var item = window.sessionStorage.getItem('sidebar-section-' + tIndex + '-open'); + if (item) { + if(isWideContent) { + window.sessionStorage.setItem('sidebar-section-' + tIndex + '-open', 'false'); + } else { + if (item === 'true') { + jQuery(this).find('.nav-panel').css('display', 'block'); + setTogglerClass($toggler, 'is-open'); + } + } } + //console.log(window.sessionStorage); + }); }; + // main initContentNav(); initSidebarToggling();