From: Coleman Watts Date: Thu, 18 Jul 2019 17:29:14 +0000 (-0400) Subject: Menubar - get rid of hardcoded pixel values in crm.menubar.js X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9a4cacdc03ead0e84135621aff7b9b84672517ca;p=civicrm-core.git Menubar - get rid of hardcoded pixel values in crm.menubar.js --- diff --git a/css/crm-menubar.css b/css/crm-menubar.css index c1a0e5413f..5b584524f4 100644 --- a/css/crm-menubar.css +++ b/css/crm-menubar.css @@ -203,7 +203,7 @@ body.crm-menubar-over-cms-menu #crm-menubar-toggle-position a i { /* hide the button in desktop view */ #civicrm-menu-nav .crm-menubar-toggle-btn { position: absolute; - top: -99999px; + top: -99999px; /* do not edit this without updating the isMobile() function in crm.menubar.js */ } #civicrm-menu { diff --git a/js/crm.menubar.js b/js/crm.menubar.js index 3dcc3f1de2..bd42b8992f 100644 --- a/js/crm.menubar.js +++ b/js/crm.menubar.js @@ -244,7 +244,7 @@ } }) .on('resize', function() { - if ($(window).width() >= 768 && $mainMenuState[0].checked) { + if (!isMobile() && $mainMenuState[0].checked) { $mainMenuState[0].click(); } handleResize(); @@ -438,13 +438,18 @@ } function handleResize() { - if ($(window).width() >= 768 && $('#civicrm-menu').height() > 50) { + if (!isMobile() && ($('#civicrm-menu').height() >= (2 * $('#civicrm-menu > li').height()))) { $('body').addClass('crm-menubar-wrapped'); } else { $('body').removeClass('crm-menubar-wrapped'); } } + // Figure out if we've hit the mobile breakpoint, based on the rule in crm-menubar.css + function isMobile() { + return $('.crm-menubar-toggle-btn', '#civicrm-menu-nav').css('top') !== '-99999px'; + } + function traverse(items, itemName, op) { var found; _.each(items, function(item, index) {