Skip to content

Commit 7ae7d2b

Browse files
committed
New option autoTrigger: true can be set to false to prevent opening menus on browser's contextmenu event
Closed mar10#25
1 parent 5853a76 commit 7ae7d2b

6 files changed

+49
-32
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# 1.3.0 / unreleased
22

33
* [FEATURE] New optional parameter open(..., extraData).
4-
* [FEATURE] New option `autoTrigger: true` can be set to `false` to prevent opening on browser's `contextmenu` event.
4+
* [FEATURE] New option `autoTrigger: true` can be set to `false` to prevent opening menus on browser's `contextmenu` event
5+
(if you want to use the `open()` method instead).
6+
* [FEATURE] New option `preventContextMenuForPopup`to prevent opening the browser's system context menu on menu entries.
57
* [CHANGE] `setEntry()` and `replaceMenu()` now allow to define titles with HTML markup.
68

79
# 1.2.4 / 2013-12-25

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ $(document).contextmenu({
205205
return {my: "left top", at: "left bottom", of: ui.target};
206206
}, ...</pre>
207207
</dd>
208+
<dt>preventContextMenuForPopup</dt>
209+
<dd>
210+
Type: <code>Boolean</code>, default: <code>false</code><br>
211+
Prevent that a right click inside an open popup menu will open the browser's
212+
system context menu.
213+
</dd>
208214
<dt>preventSelect</dt>
209215
<dd>
210216
Type: <code>Boolean</code>, default: <code>false</code><br>

demo/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878

7979
$(document).contextmenu({
8080
delegate: ".hasmenu",
81+
preventContextMenuForPopup: true,
8182
preventSelect: true,
8283
taphold: true,
8384
menu: [

jquery.ui-contextmenu.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
ignoreParentSelect: true, // Don't trigger 'select' for sub-menu parents
2727
menu: null, // selector or jQuery pointing to <UL>, or a definition hash
2828
position: null, // popup positon
29+
preventContextMenuForPopup: false, // prevent opening the browser's system context menu on menu entries
2930
preventSelect: false, // disable text selection of target
3031
show: { effect: "slideDown", duration: "fast"},
3132
taphold: false, // open menu on taphold events (requires external plugins)
@@ -212,6 +213,11 @@
212213
}).position(posOption)
213214
.hide(); // hide again, so we can apply nice effects
214215

216+
if( opts.preventContextMenuForPopup ) {
217+
this.$menu.bind("contextmenu" + this.eventNamespace, function(event){
218+
event.preventDefault();
219+
});
220+
}
215221
this._show(this.$menu, this.options.show, function(){
216222
self._trigger.call(self, "open", event, ui);
217223
});
@@ -226,6 +232,8 @@
226232
.unbind("mousedown" + this.eventNamespace)
227233
.unbind("touchstart" + this.eventNamespace)
228234
.unbind("keydown" + this.eventNamespace);
235+
this.$menu
236+
.unbind("contextmenu" + this.eventNamespace);
229237
self.currentTarget = null; // issue #44 after hide animation is too late
230238

231239
this._hide(this.$menu, hideOpts, function() {

jquery.ui-contextmenu.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,50 @@
44
"title": "jQuery UI context menu plugin",
55
"description": "Turn a jQuery UI Menu widget into a contextmenu.",
66
"keywords": [
7-
"context-menu",
8-
"contextmenu",
9-
"delegate",
10-
"jquery-ui-menu",
11-
"menu",
12-
"navigation",
13-
"popup",
14-
"right-click",
15-
"right-click-menu"
7+
"context-menu",
8+
"contextmenu",
9+
"delegate",
10+
"jquery-ui-menu",
11+
"menu",
12+
"navigation",
13+
"popup",
14+
"right-click",
15+
"right-click-menu"
1616
],
1717
"author": {
18-
"name": "Martin Wendt",
19-
"email": "jquery@wwwendt.de",
20-
"url": "http://careers.stackoverflow.com/martin-wendt"
18+
"name": "Martin Wendt",
19+
"email": "jquery@wwwendt.de",
20+
"url": "http://careers.stackoverflow.com/martin-wendt"
2121
},
2222
"repository": {
23-
"type": "git",
24-
"url": "https://github.com/mar10/jquery-ui-contextmenu"
23+
"type": "git",
24+
"url": "https://github.com/mar10/jquery-ui-contextmenu"
2525
},
2626
"homepage": "https://github.com/mar10/jquery-ui-contextmenu",
2727
"demo": "http://wwwendt.de/tech/demo/jquery-contextmenu/demo/",
2828
"docs": "https://github.com/mar10/jquery-ui-contextmenu/blob/master/README.md",
2929
"bugs": "https://github.com/mar10/jquery-ui-contextmenu/issues",
3030
"licenses": [
31-
{
32-
"type": "MIT",
33-
"url": "https://github.com/mar10/jquery-ui-contextmenu/blob/master/MIT-LICENSE.txt"
34-
}
31+
{
32+
"type": "MIT",
33+
"url": "https://github.com/mar10/jquery-ui-contextmenu/blob/master/MIT-LICENSE.txt"
34+
}
3535
],
3636
"dependencies": {
37-
"jquery": ">=1.7"
37+
"jquery": ">=1.7"
3838
},
3939
"devDependencies": {
40-
"grunt": "~0.4.1",
41-
"grunt-contrib-concat": "~0.1.3",
42-
"grunt-contrib-connect": "~0.3.0",
43-
"grunt-contrib-jshint": "~0.3.0",
44-
"grunt-contrib-qunit": "~0.2.0",
45-
"grunt-contrib-uglify": "~0.2.0",
46-
"grunt-exec": "~0.4.0",
47-
"grunt-saucelabs": "~4.1.2",
48-
"grunt-contrib-watch": "~0.5.3"
40+
"grunt": "~0.4.1",
41+
"grunt-contrib-concat": "~0.1.3",
42+
"grunt-contrib-connect": "~0.3.0",
43+
"grunt-contrib-jshint": "~0.3.0",
44+
"grunt-contrib-qunit": "~0.2.0",
45+
"grunt-contrib-uglify": "~0.2.0",
46+
"grunt-exec": "~0.4.0",
47+
"grunt-saucelabs": "~4.1.2",
48+
"grunt-contrib-watch": "~0.5.3"
4949
},
5050
"scripts": {
51-
"test": "grunt ci --verbose"
51+
"test": "grunt ci --verbose"
5252
}
5353
}

0 commit comments

Comments
 (0)