| 1 | // http://civicrm.org/licensing |
| 2 | |
| 3 | // When on a CiviCRM page the CiviCRM toolbar tab should be active |
| 4 | localStorage.setItem('Drupal.toolbar.activeTabID', JSON.stringify('toolbar-item-civicrm')); |
| 5 | |
| 6 | (function($) { |
| 7 | function adjustToggle() { |
| 8 | if ($(window).width() < 768 && $('#toolbar-item-civicrm').length) { |
| 9 | $('#civicrm-menu-nav .crm-menubar-toggle-btn').css({ |
| 10 | left: '' + $('#toolbar-item-civicrm').offset().left + 'px', |
| 11 | width: '' + $('#toolbar-item-civicrm').innerWidth() + 'px' |
| 12 | }); |
| 13 | } |
| 14 | } |
| 15 | $(window).resize(adjustToggle); |
| 16 | $(document).on('crmLoad', adjustToggle); |
| 17 | |
| 18 | // Wait for document.ready so Drupal's jQuery is available to this script |
| 19 | $(function($) { |
| 20 | // If Drupal's jQuery isn't loaded (e.g. on a stripped-down front-end page), we don't need to worry about the toolbar |
| 21 | if (window.jQuery) { |
| 22 | // This event is only triggered by Drupal's copy of jQuery. CRM.$ won't pick it up. |
| 23 | jQuery(document).on('drupalToolbarTabChange', function (event, tab) { |
| 24 | if (CRM.menubar && CRM.menubar.position === 'below-cms-menu') { |
| 25 | var action = jQuery(tab).is('#toolbar-item-civicrm') ? 'show' : 'hide'; |
| 26 | CRM.menubar[action](); |
| 27 | } |
| 28 | }); |
| 29 | } |
| 30 | }); |
| 31 | |
| 32 | })(CRM.$); |