Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

Commit

Permalink
Pass ui argument to open event
Browse files Browse the repository at this point in the history
Close #113
  • Loading branch information
mar10 committed Mar 18, 2017
1 parent d420a2d commit 5212d2e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 36 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# 1.14.0-0 / Unreleased
# 1.15.1-0 / Unreleased

*

# 1.15.0 / 2017-03-18

* [FEATURE] #113: Pass `ui` argument to `open` event.

# 1.14.0 / 2017-01-30

* #108: Update AMD dependency to be compatible with the jQuery 1.12 layout:
"jquery-ui/ui/widgets/menu"
Expand Down
63 changes: 34 additions & 29 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -82,71 +82,76 @@ module.exports = (grunt) ->
throttled: 5
browsers: [
{ browserName: "chrome", platform: "Windows 8.1" }
{ browserName: "firefox", platform: "Windows 8.1" }
# { browserName: "firefox", platform: "Windows 8.1" }
{ browserName: "firefox", platform: "Linux" }
{ browserName: "internet explorer", version: "6", platform: "Windows XP" }
{ browserName: "internet explorer", version: "7", platform: "Windows XP" }
{ browserName: "internet explorer", version: "8", platform: "Windows 7" }
# { browserName: "internet explorer", version: "6", platform: "Windows XP" }
# { browserName: "internet explorer", version: "7", platform: "Windows XP" }
# { browserName: "internet explorer", version: "8", platform: "Windows 7" }
{ browserName: "internet explorer", version: "11", platform: "Windows 8.1" }
{ browserName: "microsoftedge", platform: "Windows 10" }
{ browserName: "safari", version: "9", platform: "OS X 10.11" }
# { browserName: "safari", version: "9", platform: "OS X 10.11" }
{ browserName: "safari", version: "10", platform: "OS X 10.12" }
]
testname: "jquery.ui-contextmenu qunit tests (jQuery UI 10)"
# statusCheckAttempts: 180
recordVideo: false
videoUploadOnPass: false

ui_12:
ui_11: # UI Menu 11+ dropped support for IE7
options:
urls: [
"http://localhost:9999/test/test-jquery-3-ui-1.12.html"
"http://localhost:9999/test/test-jquery-1.11-ui-1.11.html"
# "http://localhost:9999/test/index.html",
# "http://localhost:9999/test/index-jquery-ui-1-10.html"
]

# username: process.env.SAUCE_USERNAME,
# key: process.env.SAUCE_ACCESS_KEY,
build: process.env.TRAVIS_JOB_ID
throttled: 5
browsers: [
{ browserName: "chrome", platform: "Windows 8.1" }
{ browserName: "firefox", platform: "Windows 8.1" }
# { browserName: "firefox", platform: "Windows 8.1" }
# { browserName: "firefox", platform: "Windows XP" }
{ browserName: "firefox", platform: "Linux" }
# jQuery UI 11+ stopped support for IE <= 7
{ browserName: "internet explorer", version: "8", platform: "Windows 7" }
{ browserName: "internet explorer", version: "9", platform: "Windows 7" }
{ browserName: "internet explorer", version: "10", platform: "Windows 8" }
{ browserName: "internet explorer", version: "11", platform: "Windows 8.1" }
{ browserName: "microsoftedge", platform: "Windows 10" }
{ browserName: "safari", version: "9", platform: "OS X 10.11" }
# { browserName: "safari", version: "6", platform: "OS X 10.8" }
# { browserName: "safari", version: "7", platform: "OS X 10.9" }
# { browserName: "safari", version: "8", platform: "OS X 10.10" }
# { browserName: "safari", version: "9", platform: "OS X 10.11" }
{ browserName: "safari", version: "10", platform: "OS X 10.12" }
]
testname: "jquery.ui-contextmenu qunit tests (jQuery UI 12)"
testname: "jquery.ui-contextmenu qunit tests (jQuery UI 11+)"
# statusCheckAttempts: 180
recordVideo: false
videoUploadOnPass: false

ui: # UI Menu 11+ dropped support for IE7
ui_12:
options:
urls: [
"http://localhost:9999/test/test-jquery-1.11-ui-1.11.html"
# "http://localhost:9999/test/index.html",
# "http://localhost:9999/test/index-jquery-ui-1-10.html"
"http://localhost:9999/test/test-jquery-3-ui-1.12.html"
]

# username: process.env.SAUCE_USERNAME,
# key: process.env.SAUCE_ACCESS_KEY,
build: process.env.TRAVIS_JOB_ID
throttled: 5
browsers: [
{ browserName: "chrome", platform: "Windows 8.1" }
{ browserName: "firefox", platform: "Windows 8.1" }
# { browserName: "firefox", platform: "Windows XP" }
{ browserName: "firefox", platform: "Linux" }
# jQuery UI 11+ stopped support for IE 7
# { browserName: "internet explorer", version: "6", platform: "Windows XP" }
# { browserName: "internet explorer", version: "7", platform: "Windows XP" }
{ browserName: "internet explorer", version: "8", platform: "Windows 7" }
{ browserName: "internet explorer", version: "9", platform: "Windows 7" }
{ browserName: "internet explorer", version: "10", platform: "Windows 8" }
# jQuery UI 12+ stopped support for IE <= 10
{ browserName: "internet explorer", version: "11", platform: "Windows 8.1" }
{ browserName: "microsoftedge", platform: "Windows 10" }
{ browserName: "safari", version: "6", platform: "OS X 10.8" }
{ browserName: "safari", version: "7", platform: "OS X 10.9" }
{ browserName: "safari", version: "8", platform: "OS X 10.10" }
# { browserName: "safari", version: "6", platform: "OS X 10.8" }
# { browserName: "safari", version: "7", platform: "OS X 10.9" }
# { browserName: "safari", version: "8", platform: "OS X 10.10" }
{ browserName: "safari", version: "9", platform: "OS X 10.11" }
{ browserName: "safari", version: "10", platform: "OS X 10.12" }
]
testname: "jquery.ui-contextmenu qunit tests (jQuery UI 11+)"
testname: "jquery.ui-contextmenu qunit tests (jQuery UI 12)"
# statusCheckAttempts: 180
recordVideo: false
videoUploadOnPass: false
Expand Down Expand Up @@ -203,7 +208,7 @@ module.exports = (grunt) ->
grunt.registerTask "server", ["connect:demo"]
grunt.registerTask "dev", ["connect:dev", "watch:dev"]
grunt.registerTask "test", ["jshint", "jscs", "qunit"]
grunt.registerTask "sauce", ["connect:sauce", "saucelabs-qunit:ui","saucelabs-qunit:ui_10", "saucelabs-qunit:ui_12"]
grunt.registerTask "sauce", ["connect:sauce", "saucelabs-qunit:ui_12", "saucelabs-qunit:ui_11", "saucelabs-qunit:ui_10"]
if parseInt(process.env.TRAVIS_PULL_REQUEST, 10) > 0
# saucelab keys do not work on forks
# http://support.saucelabs.com/entries/25614798
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ $("#container").contextmenu({
});
```

Alternatively we can
<a href="https://github.com/mar10/jquery-ui-contextmenu/wiki#initialize-menu-from-an-existing-ul-element">
initialaize the menu from embedded &lt;ul> markup</a>.

For more information:

* [Read the Tutorial](https://github.com/mar10/jquery-ui-contextmenu/wiki) and
Expand Down
7 changes: 4 additions & 3 deletions jquery.ui-contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ $.widget("moogle.contextmenu", {
/** Close popup. */
_closeMenu: function(immediately) {
var self = this,
hideOpts = immediately ? false : this.options.hide;
hideOpts = immediately ? false : this.options.hide,
ui = { menu: this.$menu, target: $(this.currentTarget) };

// Note: we don't want to unbind the 'contextmenu' event
$(document)
Expand All @@ -296,10 +297,10 @@ $.widget("moogle.contextmenu", {
self.previousFocus.focus();
self.previousFocus = null;
}
self._trigger("close");
self._trigger("close", null, ui);
});
} else {
self._trigger("close");
self._trigger("close", null, ui);
}
},
/** Handle $().contextmenu("option", key, value) calls. */
Expand Down
9 changes: 6 additions & 3 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function _clickTest(menu, assert) {
var $ctx, $popup,
done = assert.async();

assert.expect(3);
assert.expect(6);

$("#container").contextmenu({
delegate: ".hasmenu",
Expand All @@ -302,6 +302,7 @@ function _clickTest(menu, assert) {
// hide: false,
beforeOpen: function(event, ui) {
log("beforeOpen(" + ui.target.text() + ")");
assert.equal( ui.target.text(), "AAA", "beforeOpen: ui.target is set" );
},
create: function(event, ui) {
log("create");
Expand Down Expand Up @@ -330,15 +331,17 @@ function _clickTest(menu, assert) {
assert.equal( ui.cmd, "cut", "select: ui.cmd is set" );
assert.equal( ui.target.text(), "AAA", "select: ui.target is set" );
},
open: function(event) {
open: function(event, ui) {
log("open");
assert.equal( ui.target.text(), "AAA", "open: ui.target is set" );
setTimeout(function() {
entryEvent($popup, 0, "mouseenter");
click($popup, 0);
}, 10);
},
close: function(event) {
close: function(event, ui) {
log("close");
assert.equal( ui.target.text(), "AAA", "open: ui.target is set" );
assert.equal(logOutput(),
"createMenu,create,open(),beforeOpen(AAA),after open(),open,select(cut),close",
"Event sequence OK.");
Expand Down

0 comments on commit 5212d2e

Please sign in to comment.