X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2Fcrm.menubar.js;h=152a6e376e185de20a3318e0aee980a8c3aff961;hb=01d61708aa95a0f05f7193e2d2d244e4093aa453;hp=ed5eb920ee600ff5fea5c225bf2c26016f2a4d05;hpb=d7dd5603042869c286c8e1966bf73b6b13d9cafd;p=civicrm-core.git diff --git a/js/crm.menubar.js b/js/crm.menubar.js index ed5eb920ee..152a6e376e 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) {