Skip to content

Instantly share code, notes, and snippets.

@wluisi
Created September 16, 2015 14:41
Show Gist options
  • Save wluisi/b7e48ed8f639d24cdf0c to your computer and use it in GitHub Desktop.
Save wluisi/b7e48ed8f639d24cdf0c to your computer and use it in GitHub Desktop.
// Controls events for panel menu.
// We use context here on click events to compensate for a stupid bug in views ajax.
Drupal.behaviors.menuPanelBehavior = {
attach: function(context, settings) {
$(document).ready(function() {
$('body', context).click(function(e) {
// Ignore click on search box.
if (e.target.id == "edit-search-block-form--2") {
return;
}
else {
menuPanelClose();
}
});
$('.menu-panel-trigger', context).click(function(e) {
e.preventDefault();
e.stopPropagation();
//console.log('trigger clicked');
menuPanelToggleMenu();
});
$('#menu-panel .close-menu', context).click(function(e) {
e.preventDefault();
//console.log('close button clicked');
menuPanelClose();
});
});
// Helper functions
function menuPanelClose() {
$('body').removeClass('menu-panel-expanded');
}
function menuPanelToggleMenu() {
$('body').toggleClass('menu-panel-expanded');
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment