Skip to content

Commit

Permalink
fixing repositioning / re-opening of menus - issue #105
Browse files Browse the repository at this point in the history
  • Loading branch information
rodneyrehm committed Jan 20, 2013
1 parent 9312ea5 commit 2078744
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -103,6 +103,10 @@ $.contextMenu is published under the [MIT license](http://www.opensource.org/lic


## Changelog ## ## 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) ### ### 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. :( * fixing [jQuery plugin manifest](https://github.com/medialize/jQuery-contextMenu/commit/413b1ecaba0aeb4e50f97cee35f7c367435e7830#commitcomment-2465216), again. yep. I'm that kind of a guy. :(
Expand Down
23 changes: 18 additions & 5 deletions src/jquery.contextMenu.js
Expand Up @@ -221,6 +221,11 @@ var // currently active contextMenu trigger
return; return;
} }


// abort event if menu is visible for this trigger
if ($this.hasClass('context-menu-active')) {
return;
}

if (!$this.hasClass('context-menu-disabled')) { if (!$this.hasClass('context-menu-disabled')) {
// theoretically need to fire a show event at <menu> // theoretically need to fire a show event at <menu>
// http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#context-menus // http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#context-menus
Expand Down Expand Up @@ -392,12 +397,14 @@ var // currently active contextMenu trigger
} }
} }
} }

if (target && triggerAction) { if (target && triggerAction) {
$(target).contextMenu({x: x, y: y}); root.$trigger.one('contextmenu:hidden', function() {
} else { $(target).contextMenu({x: x, y: y});
// TODO: it would be nice if we could prevent animations here });
root.$menu.trigger('contextmenu:hide');
} }

root.$menu.trigger('contextmenu:hide');
}, 50); }, 50);
}, },
// key handled :hover // key handled :hover
Expand Down Expand Up @@ -813,7 +820,9 @@ var // currently active contextMenu trigger
opt.$menu.find('ul').css('zIndex', css.zIndex + 1); opt.$menu.find('ul').css('zIndex', css.zIndex + 1);


// position and show context menu // 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 // make options available and set state
$trigger $trigger
.data('contextMenu', opt) .data('contextMenu', opt)
Expand Down Expand Up @@ -899,6 +908,10 @@ var // currently active contextMenu trigger
} }
}); });
} }

setTimeout(function() {
$trigger.trigger('contextmenu:hidden');
}, 10);
}); });
}, },
create: function(opt, root) { create: function(opt, root) {
Expand Down

0 comments on commit 2078744

Please sign in to comment.