Skip to content
This repository was archived by the owner on Jan 30, 2021. It is now read-only.

Commit 50b9e73

Browse files
committed
manually added pull request from origin codrops#22
1 parent b5966a2 commit 50b9e73

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

js/jquery.dlmenu.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@
7676
this.open = false;
7777
this.$trigger = this.$el.children( '.dl-trigger' );
7878
this.$menu = this.$el.children( 'ul.dl-menu' );
79-
this.$menuitems = this.$menu.find( 'li:not(.dl-back)' );
79+
this.$menu.hide();
80+
this.$el.css('z-index', '9999');
8081
this.$el.find( 'ul.dl-submenu' ).prepend( '<li class="dl-back"><a href="#">' + this.options.backLabel + '</a></li>' );
81-
this.$back = this.$menu.find( 'li.dl-back' );
8282

8383
// Set the label text for the back link.
8484
if (this.options.useActiveItemAsBackLabel) {
85-
this.$back.each(function() {
85+
this.$menu.find( 'li.dl-back' ).each(function() {
8686
var $this = $(this),
8787
parentLabel = $this.parents('li:first').find('a:first').text();
8888

@@ -113,12 +113,11 @@
113113
$body.off( 'click' ).children().on( 'click.dlmenu', function() {
114114
self._closeMenu() ;
115115
} );
116-
117116
}
118117
return false;
119118
} );
120119

121-
this.$menuitems.on( 'click.dlmenu', function( event ) {
120+
this.$menu.on( 'click.dlmenu', 'li:not(.dl-back)', function( event ) {
122121

123122
event.stopPropagation();
124123

@@ -158,7 +157,7 @@
158157

159158
} );
160159

161-
this.$back.on( 'click.dlmenu', function( event ) {
160+
this.$menu.on( 'click.dlmenu', 'li.dl-back', function( event ) {
162161

163162
var $this = $( this ),
164163
$submenu = $this.parents( 'ul.dl-submenu:first' ),
@@ -219,6 +218,7 @@
219218
else {
220219
onTransitionEndFn.call();
221220
}
221+
this.$menu.hide();
222222

223223
this.open = false;
224224
},
@@ -229,6 +229,9 @@
229229
},
230230
_openMenu : function() {
231231
var self = this;
232+
233+
this.$menu.show();
234+
232235
// clicking somewhere else makes the menu close
233236
$body.off( 'click' ).on( 'click.dlmenu', function() {
234237
self._closeMenu() ;
@@ -242,7 +245,7 @@
242245
// resets the menu to its original state (first level of options)
243246
_resetMenu : function() {
244247
this.$menu.removeClass( 'dl-subview' );
245-
this.$menuitems.removeClass( 'dl-subview dl-subviewopen' );
248+
this.$menu.find( 'li:not(.dl-back)' ).removeClass( 'dl-subview dl-subviewopen' );
246249
}
247250
};
248251

0 commit comments

Comments
 (0)