@@ -27,6 +27,7 @@ var supportSelectstart = "onselectstart" in document.createElement("div"),
27
27
$ . widget ( "moogle.contextmenu" , {
28
28
version : "@VERSION" ,
29
29
options : {
30
+ addClass : "ui-contextmenu" , // Add this class to the outer <ul>
30
31
autoTrigger : true , // open menu on browser's `contextmenu` event
31
32
delegate : null , // selector
32
33
hide : { effect : "fadeOut" , duration : "fast" } ,
@@ -111,7 +112,9 @@ $.widget("moogle.contextmenu", {
111
112
} ,
112
113
/** (Re)Create jQuery UI Menu. */
113
114
_createUiMenu : function ( menuDef ) {
114
- var ct ;
115
+ var ct ,
116
+ opts = this . options ;
117
+
115
118
// Remove temporary <ul> if any
116
119
if ( this . isOpen ( ) ) {
117
120
// #58: 'replaceMenu' in beforeOpen causing select: to lose ui.target
@@ -120,11 +123,13 @@ $.widget("moogle.contextmenu", {
120
123
this . _closeMenu ( true ) ;
121
124
this . currentTarget = ct ;
122
125
}
123
-
124
126
if ( this . menuIsTemp ) {
125
127
this . $menu . remove ( ) ; // this will also destroy ui.menu
126
128
} else if ( this . $menu ) {
127
- this . $menu . menu ( "destroy" ) . hide ( ) ;
129
+ this . $menu
130
+ . menu ( "destroy" )
131
+ . removeClass ( this . options . addClass )
132
+ . hide ( ) ;
128
133
}
129
134
this . $menu = null ;
130
135
this . menuIsTemp = false ;
@@ -143,21 +148,22 @@ $.widget("moogle.contextmenu", {
143
148
// Create - but hide - the jQuery UI Menu widget
144
149
this . $menu
145
150
. hide ( )
146
- // .addClass("moogle-contextmenu" )
151
+ . addClass ( opts . addClass )
147
152
// Create a menu instance that delegates events to our widget
148
- . menu ( $ . extend ( true , { } , this . options . uiMenuOptions , {
149
- blur : $ . proxy ( this . options . blur , this ) ,
150
- create : $ . proxy ( this . options . createMenu , this ) ,
151
- focus : $ . proxy ( this . options . focus , this ) ,
153
+ . menu ( $ . extend ( true , { } , opts . uiMenuOptions , {
154
+ blur : $ . proxy ( opts . blur , this ) ,
155
+ create : $ . proxy ( opts . createMenu , this ) ,
156
+ focus : $ . proxy ( opts . focus , this ) ,
152
157
select : $ . proxy ( function ( event , ui ) {
153
158
// User selected a menu entry
154
159
var retval ,
155
160
isParent = $ . moogle . contextmenu . isMenu ( ui . item ) ,
156
161
actionHandler = ui . item . data ( "actionHandler" ) ;
162
+
157
163
ui . cmd = ui . item . attr ( "data-command" ) ;
158
164
ui . target = $ ( this . currentTarget ) ;
159
165
// ignore clicks, if they only open a sub-menu
160
- if ( ! isParent || ! this . options . ignoreParentSelect ) {
166
+ if ( ! isParent || ! opts . ignoreParentSelect ) {
161
167
retval = this . _trigger . call ( this , "select" , event , ui ) ;
162
168
if ( actionHandler ) {
163
169
retval = actionHandler . call ( this , event , ui ) ;
0 commit comments