/*! jQuery UI context menu plugin - v1.5.0 - 2014-07-06 | https://github.com/mar10/jquery-ui-contextmenu | Copyright (c) 2014 Martin Wendt; Licensed MIT */ !function(a,b,c,d){"use strict";var e,f,g="onselectstart"in c.createElement("div");a.widget("moogle.contextmenu",{version:"1.4.0-1",options:{autoTrigger:!0,delegate:null,hide:{effect:"fadeOut",duration:"fast"},ignoreParentSelect:!0,menu:null,position:null,preventContextMenuForPopup:!1,preventSelect:!1,show:{effect:"slideDown",duration:"fast"},taphold:!1,beforeOpen:a.noop,blur:a.noop,close:a.noop,create:a.noop,createMenu:a.noop,focus:a.noop,open:a.noop,select:a.noop},_create:function(){var b,d,e,f=this.options;if(this.$headStyle=null,this.$menu=null,this.menuIsTemp=!1,this.currentTarget=null,f.preventSelect){e=(a(this.element).is(c)?a("body"):this.element).uniqueId().attr("id"),b="#"+e+" "+f.delegate+" { -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }",this.$headStyle=a("").prop("type","text/css").appendTo("head");try{this.$headStyle.html(b)}catch(h){this.$headStyle[0].styleSheet.cssText=b}g&&this.element.delegate(f.delegate,"selectstart"+this.eventNamespace,function(a){a.preventDefault()})}this._createUiMenu(f.menu),d="contextmenu"+this.eventNamespace,f.taphold&&(d+=" taphold"+this.eventNamespace),this.element.delegate(f.delegate,d,a.proxy(this._openMenu,this))},_destroy:function(){this.element.undelegate(this.eventNamespace),this._createUiMenu(null),this.$headStyle&&(this.$headStyle.remove(),this.$headStyle=null)},_createUiMenu:function(b){var c;this.isOpen()&&(c=this.currentTarget,this._closeMenu(!0),this.currentTarget=c),this.menuIsTemp?this.$menu.remove():this.$menu&&this.$menu.menu("destroy").hide(),this.$menu=null,this.menuIsTemp=!1,b&&(a.isArray(b)?(this.$menu=a.moogle.contextmenu.createMenuMarkup(b),this.menuIsTemp=!0):this.$menu="string"==typeof b?a(b):b,this.$menu.hide().menu({blur:a.proxy(this.options.blur,this),create:a.proxy(this.options.createMenu,this),focus:a.proxy(this.options.focus,this),select:a.proxy(function(b,c){var d,e=a.moogle.contextmenu.isMenu(c.item),f=c.item.data("actionHandler");c.cmd=c.item.attr("data-command"),c.target=a(this.currentTarget),e&&this.options.ignoreParentSelect||(d=this._trigger.call(this,"select",b,c),f&&(d=f.call(this,b,c)),d!==!1&&this._closeMenu.call(this),b.preventDefault())},this)}))},_openMenu:function(b){var e=this.options,f=e.position,g=this,h=!!b.isTrigger,i={menu:this.$menu,target:a(b.target),extraData:b.extraData,originalEvent:b};if(e.autoTrigger||h){if(this.currentTarget=b.target,b.preventDefault(),this._trigger("beforeOpen",b,i)===!1)return this.currentTarget=null,!1;i.menu=this.$menu,a(c).bind("keydown"+this.eventNamespace,function(b){b.which===a.ui.keyCode.ESCAPE&&g._closeMenu()}).bind("mousedown"+this.eventNamespace+" touchstart"+this.eventNamespace,function(b){a(b.target).closest(".ui-menu-item").length||g._closeMenu()}),a.isFunction(f)&&(f=f(b,i)),f=a.extend({my:"left top",at:"left bottom",of:b.pageX===d?b.target:b,collision:"fit"},f),this.$menu.show().css({position:"absolute",left:0,top:0}).position(f).hide(),e.preventContextMenuForPopup&&this.$menu.bind("contextmenu"+this.eventNamespace,function(a){a.preventDefault()}),this._show(this.$menu,this.options.show,function(){g._trigger.call(g,"open",b,i)})}},_closeMenu:function(b){var d=this,e=b?!1:this.options.hide;a(c).unbind("mousedown"+this.eventNamespace).unbind("touchstart"+this.eventNamespace).unbind("keydown"+this.eventNamespace),this.$menu.unbind("contextmenu"+this.eventNamespace),d.currentTarget=null,this._hide(this.$menu,e,function(){d._trigger("close")})},_setOption:function(b,c){switch(b){case"menu":this.replaceMenu(c)}a.Widget.prototype._setOption.apply(this,arguments)},_getMenuEntry:function(a){return this.$menu.find("li[data-command="+a+"]")},close:function(){this.isOpen()&&this._closeMenu()},enableEntry:function(a,b){this._getMenuEntry(a).toggleClass("ui-state-disabled",b===!1)},getMenu:function(){return this.$menu},isOpen:function(){return!!this.$menu&&!!this.currentTarget},open:function(a,b){b=b||{};var c=jQuery.Event("contextmenu",{target:a.get(0),extraData:b});return this.element.trigger(c)},replaceMenu:function(a){this._createUiMenu(a)},setEntry:function(b,c){var d=this._getMenuEntry(b);"string"==typeof c?a.moogle.contextmenu.updateTitle(d,c):(d.empty(),c.cmd=c.cmd||b,a.moogle.contextmenu.createEntryMarkup(c,d))},showEntry:function(a,b){this._getMenuEntry(a).toggle(b!==!1)}}),a.extend(a.moogle.contextmenu,{createMenuMarkup:function(b,c){var d,e,f,g;for(null==c&&(c=a("