From 261c63d238e2139c348b44e243b40f7c163bb36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyril=20Rez=C3=A9?= Date: Tue, 16 Aug 2016 23:07:01 +0200 Subject: [PATCH] Fix for #11521 : Isis admin menu on small viewport width devices (#11528) * Fix for #11521 : Isis admin menu on small viewport width devices Do not run auto-scrolling on small devices for Isis admin menu * Adjust min-width for auto-scrolling * Remove extra empty line --- administrator/templates/isis/js/template.js | 173 ++++++++++---------- 1 file changed, 90 insertions(+), 83 deletions(-) diff --git a/administrator/templates/isis/js/template.js b/administrator/templates/isis/js/template.js index 38f5aed4dc67d..1cc34f8adebd6 100644 --- a/administrator/templates/isis/js/template.js +++ b/administrator/templates/isis/js/template.js @@ -69,108 +69,115 @@ /** * Append submenu items to empty UL on hover allowing a scrollable dropdown */ - var menuScroll = $('#menu > li > ul'), - emptyMenu = $('#nav-empty'); - - $('#menu > li').on('click mouseenter', function() { - - // Set max-height (and width if scroll) for dropdown menu, depending of window height - var $dropdownMenu = $(this).children('ul'), - windowHeight = $w.height(), - linkHeight = $(this).outerHeight(true), - statusHeight = $('#status').outerHeight(true), - menuHeight = $dropdownMenu.height(), - menuOuterHeight = $dropdownMenu.outerHeight(true), - scrollMenuWidth = $dropdownMenu.width() + 15, - maxHeight = windowHeight - (linkHeight + statusHeight + (menuOuterHeight - menuHeight) + 20); - - if (maxHeight < menuHeight) { - $dropdownMenu.css('width', scrollMenuWidth); - } else if (maxHeight > menuHeight) { - $dropdownMenu.css('width', 'auto'); - } + if ($w.width() > 767) { + + var menuScroll = $('#menu > li > ul'), + emptyMenu = $('#nav-empty'); + + $('#menu > li').on('click mouseenter', function() { + + // Set max-height (and width if scroll) for dropdown menu, depending of window height + var $dropdownMenu = $(this).children('ul'), + windowHeight = $w.height(), + linkHeight = $(this).outerHeight(true), + statusHeight = $('#status').outerHeight(true), + menuHeight = $dropdownMenu.height(), + menuOuterHeight = $dropdownMenu.outerHeight(true), + scrollMenuWidth = $dropdownMenu.width() + 15, + maxHeight = windowHeight - (linkHeight + statusHeight + (menuOuterHeight - menuHeight) + 20); + + if (maxHeight < menuHeight) { + $dropdownMenu.css('width', scrollMenuWidth); + } else if (maxHeight > menuHeight) { + $dropdownMenu.css('width', 'auto'); + } - $dropdownMenu.css('max-height', maxHeight); + $dropdownMenu.css('max-height', maxHeight); - // Get the submenu position - linkWidth = $(this).outerWidth(true); - menuWidth = $dropdownMenu.width(); - linkPaddingLeft = $(this).children('a').css('padding-left'); - offsetLeft = Math.round($(this).offset().left) - parseInt(linkPaddingLeft); + // Get the submenu position + linkWidth = $(this).outerWidth(true); + menuWidth = $dropdownMenu.width(); + linkPaddingLeft = $(this).children('a').css('padding-left'); + offsetLeft = Math.round($(this).offset().left) - parseInt(linkPaddingLeft); - emptyMenu.empty().hide(); + emptyMenu.empty().hide(); - }); + }); - menuScroll.find('.dropdown-submenu > a').on('mouseover', function() { + menuScroll.find('.dropdown-submenu > a').on('mouseover', function() { - var $self = $(this), - dropdown = $self.next('ul'), - submenuWidth = dropdown.outerWidth(), - offsetTop = $self.offset().top, - linkPaddingTop = parseInt(dropdown.css('padding-top')) + parseInt($(this).css('padding-top')), - scroll = $w.scrollTop() + linkPaddingTop; + var $self = $(this), + dropdown = $self.next('ul'), + submenuWidth = dropdown.outerWidth(), + offsetTop = $self.offset().top, + linkPaddingTop = parseInt(dropdown.css('padding-top')) + parseInt($(this).css('padding-top')), + scroll = $w.scrollTop() + linkPaddingTop; - // Set the submenu position - if ($('html').attr('dir') == 'rtl') - { - emptyMenu.css({ - top : offsetTop - scroll, - left: offsetLeft - (menuWidth - linkWidth) - submenuWidth - }); - } - else - { - emptyMenu.css({ - top : offsetTop - scroll, - left: offsetLeft + menuWidth - }); - } + // Set the submenu position + if ($('html').attr('dir') == 'rtl') + { + emptyMenu.css({ + top : offsetTop - scroll, + left: offsetLeft - (menuWidth - linkWidth) - submenuWidth + }); + } + else + { + emptyMenu.css({ + top : offsetTop - scroll, + left: offsetLeft + menuWidth + }); + } - // Append items to empty