kopia lustrzana https://github.com/wagtail/wagtail
Main submenu and explorer now disable eachother when clicked
rodzic
c22e2e2914
commit
62f0cc338e
|
@ -1,27 +1,44 @@
|
|||
$(function(){
|
||||
var $explorer = $('#explorer');
|
||||
var $body = $('body');
|
||||
|
||||
// Dynamically load menu on request.
|
||||
$(document).on('click', '.dl-trigger', function(){
|
||||
var $this = $(this);
|
||||
var $explorer = $('#explorer');
|
||||
|
||||
// Close any submenuss
|
||||
$('.nav-main .submenu-active, .nav-wrapper').removeClass('submenu-active');
|
||||
|
||||
$this.addClass('icon-spinner');
|
||||
|
||||
if(!$explorer.children().length){
|
||||
$explorer.load($this.data('explorer-menu-url'), function() {
|
||||
$this.removeClass('icon-spinner');
|
||||
|
||||
$explorer.addClass('dl-menuwrapper').dlmenu({
|
||||
animationClasses : {
|
||||
classin : 'dl-animate-in-2',
|
||||
classout : 'dl-animate-out-2'
|
||||
}
|
||||
});
|
||||
$explorer.dlmenu('openMenu');
|
||||
});
|
||||
if($explorer.data('dlmenu') && $explorer.dlmenu('isOpen')){
|
||||
// if it's already open, allow the menu plugin to close it
|
||||
return false;
|
||||
}else{
|
||||
$explorer.dlmenu('openMenu');
|
||||
}
|
||||
$this.addClass('icon-spinner');
|
||||
|
||||
if(!$explorer.children().length){
|
||||
$explorer.load($this.data('explorer-menu-url'), function() {
|
||||
$this.removeClass('icon-spinner');
|
||||
|
||||
$explorer.addClass('dl-menuwrapper').dlmenu({
|
||||
animationClasses : {
|
||||
classin : 'dl-animate-in-2',
|
||||
classout : 'dl-animate-out-2'
|
||||
}
|
||||
});
|
||||
$explorer.dlmenu('openMenu');
|
||||
});
|
||||
}else{
|
||||
$explorer.dlmenu('openMenu');
|
||||
$this.removeClass('icon-spinner');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// Close menu on ESC key
|
||||
$(document).on('keydown click', function(e){
|
||||
if($explorer.data('dlmenu') && $explorer.dlmenu('isOpen') && (e.keyCode == 27 || !e.keyCode)){
|
||||
$explorer.dlmenu('closeMenu');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
$(function(){
|
||||
var $explorer = $('#explorer');
|
||||
|
||||
$('.nav-main .submenu-trigger').on('click', function(){
|
||||
if($(this).closest('li').find('.nav-submenu').length){
|
||||
|
||||
// Close explorer menu, although it may not be instantiated yet
|
||||
if($explorer.data('dlmenu') && $explorer.dlmenu('isOpen')){
|
||||
$explorer.dlmenu('closeMenu');
|
||||
}
|
||||
|
||||
$(this).closest('li').toggleClass('submenu-active');
|
||||
$('.nav-wrapper').toggleClass('submenu-active')
|
||||
$('.nav-wrapper').toggleClass('submenu-active');
|
||||
return false
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('keydown click', function(e){
|
||||
if($('.nav-wrapper.submenu-active').length){
|
||||
if(e.keyCode == 27 || !e.keyCode){
|
||||
$('.nav-main .submenu-active').removeClass('submenu-active');
|
||||
$('.nav-wrapper').toggleClass('submenu-active')
|
||||
}
|
||||
if($('.nav-wrapper.submenu-active').length && (e.keyCode == 27 || !e.keyCode)){
|
||||
$('.nav-main .submenu-active, .nav-wrapper').removeClass('submenu-active');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
else {
|
||||
self._openMenu();
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
|
||||
} );
|
||||
|
||||
|
@ -163,6 +163,11 @@
|
|||
} );
|
||||
|
||||
},
|
||||
|
||||
isOpen: function(){
|
||||
return this.open
|
||||
},
|
||||
|
||||
closeMenu : function() {
|
||||
if( this.open ) {
|
||||
this._closeMenu();
|
||||
|
@ -197,9 +202,9 @@
|
|||
_openMenu : function() {
|
||||
var self = this;
|
||||
// clicking somewhere else makes the menu close
|
||||
$body.off( 'click' ).on( 'click.dlmenu', function() {
|
||||
self._closeMenu() ;
|
||||
} );
|
||||
// $body.off( 'click' ).on( 'click.dlmenu', function() {
|
||||
// self._closeMenu() ;
|
||||
// } );
|
||||
this.$menu.addClass( 'dl-menuopen dl-menu-toggle' ).on( this.transEndEventName, function() {
|
||||
$( this ).removeClass( 'dl-menu-toggle' );
|
||||
} );
|
||||
|
|
Ładowanie…
Reference in New Issue