Skip to content
Snippets Groups Projects
Unverified Commit 04656e8c authored by Eileen McNaughton's avatar Eileen McNaughton Committed by GitHub
Browse files

Merge pull request #14442 from colemanw/drupal8jquery

Conditionally use Drupal's jQuery only if available
parents 64979dea 5d175460
No related merge requests found
......@@ -17,13 +17,16 @@ localStorage.setItem('Drupal.toolbar.activeTabID', JSON.stringify('toolbar-item-
// 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]();
}
});
// 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
if (window.jQuery) {
// This event is only triggered by Drupal's copy of jQuery. CRM.$ won't pick it up.
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.$);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment