X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2Fcrm.drupal8.js;h=74e64cb779290f261b403dddcce74bd3f54a3afa;hb=a40e45577fc9cfc15558d1e6c0f242fbf900f5c3;hp=32c06a6bb43a1a1f3715c4be38f0507c637101c3;hpb=fcd5a30dadd80ca4ec68930a92ae3e28c65f8ea9;p=civicrm-core.git diff --git a/js/crm.drupal8.js b/js/crm.drupal8.js index 32c06a6bb4..74e64cb779 100644 --- a/js/crm.drupal8.js +++ b/js/crm.drupal8.js @@ -1,17 +1,29 @@ // http://civicrm.org/licensing -CRM.$(function($) { - // d8 Hack to hide title when it should be (CRM-19960) - var pageTitle = $('.page-title'); - if ('' == pageTitle.text()) { - pageTitle.hide(); - } - $('#toolbar-bar').hide(); +// When on a CiviCRM page the CiviCRM toolbar tab should be active +localStorage.setItem('Drupal.toolbar.activeTabID', JSON.stringify('toolbar-item-civicrm')); - $('.crm-hidemenu').click(function(e) { - $('#toolbar-bar').slideDown(); - }); - $('#crm-notification-container').on('click', '#crm-restore-menu', function() { - $('#toolbar-bar').slideUp(); - }); -}); +(function($) { + function adjustToggle() { + if ($(window).width() < 768) { + $('#civicrm-menu-nav .crm-menubar-toggle-btn').css({ + left: '' + $('#toolbar-item-civicrm').offset().left + 'px', + width: '' + $('#toolbar-item-civicrm').innerWidth() + 'px' + }); + } + } + $(window).resize(adjustToggle); + $(document).on('crmLoad', adjustToggle); + + // Wait for document.ready so Drupal's jQuery is available to this script + $(function($) { + // Need Drupal's jQuery to listen to this event + jQuery(document).on('drupalToolbarTabChange', function(event, tab) { + if (CRM.menubar && CRM.menubar.position === 'below-cms-menu') { + var action = jQuery(tab).is('#toolbar-item-civicrm') ? 'show' : 'hide'; + CRM.menubar[action](); + } + }); + }); + +})(CRM.$);