|
11 | 11 | /*
|
12 | 12 | * TODO:
|
13 | 13 | * - change namespace to 'moogle'
|
14 |
| - * - use _on / _off |
15 |
| - * - move version to prototype |
16 |
| - * - generally take more advantage off http://api.jqueryui.com/jQuery.widget/ |
17 |
| - * - open() programatically at a given positon |
18 | 14 | */
|
19 | 15 | (function ($) {
|
20 |
| -// function getMenuFromEvent(event){ |
21 |
| -// var menu = $(event.target).closest(":ui-menu"), |
22 |
| -// $menu = $(menu); |
23 |
| -// return $menu.data("ui-menu") || $menu.data("menu"); |
24 |
| -// } |
25 | 16 | var supportSelectstart = "onselectstart" in document.createElement("div");
|
26 | 17 |
|
27 | 18 | /** Return command without leading '#' (default to ""). */
|
|
55 | 46 | var eventNames, targetId,
|
56 | 47 | opts = this.options;
|
57 | 48 |
|
58 |
| - console.log(this.element) |
59 |
| - |
| 49 | +// console.log(this.element) |
| 50 | + |
60 | 51 | this.$headStyle = null;
|
61 | 52 | this.orgMenu = null;
|
62 | 53 | this.currentTarget = null;
|
63 | 54 | this.ns = "." + this.widgetName;
|
64 |
| - |
| 55 | + |
65 | 56 | if(opts.preventSelect){
|
66 | 57 | // Create a global style for all potential menu targets
|
67 |
| - // If the contextmenu was bound to `document`, we apply the |
68 |
| - // selector relative to the <body> tag instead |
69 |
| - targetId = ($(this.element).is(document) ? $("body") : this.element).uniqueId().attr("id"); |
| 58 | + // If the contextmenu was bound to `document`, we apply the |
| 59 | + // selector relative to the <body> tag instead |
| 60 | + targetId = ($(this.element).is(document) ? $("body") : this.element).uniqueId().attr("id"); |
70 | 61 | this.$headStyle = $("<style class='ui-contextmenu-style'>")
|
71 | 62 | .prop("type", "text/css")
|
72 | 63 | .html("#" + targetId + " " + opts.delegate + " { " +
|
|
210 | 201 | _getMenu: function(){
|
211 | 202 | // this.options.menu may be a string, jQuery or a function returning that.
|
212 | 203 | var $menu = this.options.menu;
|
213 |
| -// if( $.isFunction($menu) ){ |
214 |
| -// $menu = $menu(); |
215 |
| -// } |
216 | 204 | return (typeof $menu === "string") ? $($menu) : $menu;
|
217 | 205 | },
|
218 | 206 | /** Open context menu on a specific target (must match options.delegate) */
|
|
233 | 221 | },
|
234 | 222 | /** Redefine the whole menu. */
|
235 | 223 | replaceMenu: function(data){
|
236 |
| -// return this.element.contextmenu("option", "menu", menu); |
237 | 224 | var opts = this.options,
|
238 | 225 | $menu = this._getMenu();
|
239 | 226 |
|
|
270 | 257 | .first()
|
271 | 258 | .replaceWith(titleOrData);
|
272 | 259 | }else{
|
273 |
| - $parent = $entry.closest("li"); |
274 |
| - $parent.empty(); |
| 260 | + $parent = $entry.closest("li").empty(); |
275 | 261 | $.ui.contextmenu.createEntryMarkup(titleOrData, $parent);
|
276 | 262 | }
|
277 | 263 | },
|
@@ -301,7 +287,7 @@ $.extend($.ui.contextmenu, {
|
301 | 287 | $a.append($("<span class='ui-icon'>").addClass(entry.uiIcon));
|
302 | 288 | }
|
303 | 289 | if(entry.disabled){
|
304 |
| - $a.addClass("ui-state-disabled"); |
| 290 | + $parentLi.addClass("ui-state-disabled"); |
305 | 291 | }
|
306 | 292 | }
|
307 | 293 | return $a;
|
|
0 commit comments