Created
September 16, 2015 14:41
-
-
Save wluisi/b7e48ed8f639d24cdf0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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