Created
September 16, 2011 14:51
-
-
Save alokito/1222275 to your computer and use it in GitHub Desktop.
patch to jquery.contextMenu.js from jQuery Context Menu Plugin v1.01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The attached "jquery.contextMenu.js.diff" is a patch for two improvements to the jQuery Context Menu Plugin | |
1) instead of requiring an id for the menu div, allow the plugin to accept either the | |
id string or a jquery object. I have been dynamically adding menus, and it is annoying | |
to have to make up ids. The code change is as simple as adding the followin to the contextMenu function: | |
if (o.menu.substr) | |
o.menu = $('#' + o.menu); | |
and then going through the rest of the code and making sure that o.menu is used as a | |
jquery object instead of an id string. This was easy to do, although I ended up | |
changing a lot of lines. | |
2) With safari 5 on a macbook, control-click gets mapped to e.button == 1 && e.ctrlKey, | |
rather than e.button == 2. To make this plugin work with safari 5 on a macbook, I ended | |
up abstracting out a "isRightClick" function that checks for both these conditions, | |
currently | |
"e.button == 2 || ($.browser.webkit && e.ctrlKey)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment