Browse files

fixing repositioning / re-opening of menus - issue #105

  • Loading branch information...
1 parent 9312ea5 commit 20787449bfeaaad30ea610048b7798c0692bd70b @rodneyrehm rodneyrehm committed Jan 20, 2013
Showing with 22 additions and 5 deletions.
  1. +4 −0 README.md
  2. +18 −5 src/jquery.contextMenu.js
View
4 README.md
@@ -103,6 +103,10 @@ $.contextMenu is published under the [MIT license](http://www.opensource.org/lic
## Changelog ##
+### git-master ###
+
+* fixing "opening a second menu can break the layer" - ([Issue #105](https://github.com/medialize/jQuery-contextMenu/issues/105))
+
### 1.6.4 (January 19th 2013) ###
* fixing [jQuery plugin manifest](https://github.com/medialize/jQuery-contextMenu/commit/413b1ecaba0aeb4e50f97cee35f7c367435e7830#commitcomment-2465216), again. yep. I'm that kind of a guy. :(
View
23 src/jquery.contextMenu.js
@@ -221,6 +221,11 @@ var // currently active contextMenu trigger
return;
}
+ // abort event if menu is visible for this trigger
+ if ($this.hasClass('context-menu-active')) {
+ return;
+ }
+
if (!$this.hasClass('context-menu-disabled')) {
// theoretically need to fire a show event at <menu>
// http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#context-menus
@@ -392,12 +397,14 @@ var // currently active contextMenu trigger
}
}
}
+
if (target && triggerAction) {
- $(target).contextMenu({x: x, y: y});
- } else {
- // TODO: it would be nice if we could prevent animations here
- root.$menu.trigger('contextmenu:hide');
+ root.$trigger.one('contextmenu:hidden', function() {
+ $(target).contextMenu({x: x, y: y});
+ });
}
+
+ root.$menu.trigger('contextmenu:hide');
}, 50);
},
// key handled :hover
@@ -813,7 +820,9 @@ var // currently active contextMenu trigger
opt.$menu.find('ul').css('zIndex', css.zIndex + 1);
// position and show context menu
- opt.$menu.css( css )[opt.animation.show](opt.animation.duration);
+ opt.$menu.css( css )[opt.animation.show](opt.animation.duration, function() {
+ $trigger.trigger('contextmenu:visible');
+ });
// make options available and set state
$trigger
.data('contextMenu', opt)
@@ -899,6 +908,10 @@ var // currently active contextMenu trigger
}
});
}
+
+ setTimeout(function() {
+ $trigger.trigger('contextmenu:hidden');
+ }, 10);
});
},
create: function(opt, root) {

0 comments on commit 2078744

Please sign in to comment.