Skip to content

Instantly share code, notes, and snippets.

@zaurmag
Last active August 7, 2016 18:17
Show Gist options
  • Save zaurmag/990615de99b708886dbf27507bace879 to your computer and use it in GitHub Desktop.
Save zaurmag/990615de99b708886dbf27507bace879 to your computer and use it in GitHub Desktop.
Плагин мобильного меню
// ======= Open/Close mobile Menu =======
(function($) {
$.fn.toggleMenu = function(options) {
var settings = $.extend({
closeClick: false
}, options);
return this.each(function() {
$(this).find('.hamburger').click(function() {
$(this).toggleClass('open');
$(this).parent().next().toggleClass('show');
return false
});
var $this = $(this);
$(this).next().find('.close-menu-btn').click(function() {
$(this).parent().removeClass('show');
$this.find('.hamburger').removeClass('open');
return false;
});
if (settings.closeClick == true) {
$(this).next().find('li a').click(function() {
var parentUl = $(this).parents('ul');
parentUl.prev().find('.hamburger').removeClass('open');
parentUl.removeClass('show').slideUp(200);
});
}
});
};
})(jQuery);
// Open/Close init mobile Menu
$('.toggle_menu_button').toggleMenu();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment