!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):jQuery)}(function(e){"use strict";function t(e){for(var t,n=e.split(/\s+/),a=[],o=0;t=n[o];o++)t=t.charAt(0).toUpperCase(),a.push(t);return a}function n(t){return t.id&&e('label[for="'+t.id+'"]').val()||t.name}function a(t,o,i){return i||(i=0),o.each(function(){var o,s,c=e(this),r=this,l=this.nodeName.toLowerCase();switch("label"===l&&c.find("input, textarea, select").length&&(o=c.text(),c=c.children().first(),r=c.get(0),l=r.nodeName.toLowerCase()),l){case"menu":s={name:c.attr("label"),items:{}},i=a(s.items,c.children(),i);break;case"a":case"button":s={name:c.text(),disabled:!!c.attr("disabled"),callback:function(){return function(){c.click()}}()};break;case"menuitem":case"command":switch(c.attr("type")){case void 0:case"command":case"menuitem":s={name:c.attr("label"),disabled:!!c.attr("disabled"),icon:c.attr("icon"),callback:function(){return function(){c.click()}}()};break;case"checkbox":s={type:"checkbox",disabled:!!c.attr("disabled"),name:c.attr("label"),selected:!!c.attr("checked")};break;case"radio":s={type:"radio",disabled:!!c.attr("disabled"),name:c.attr("label"),radio:c.attr("radiogroup"),value:c.attr("id"),selected:!!c.attr("checked")};break;default:s=void 0}break;case"hr":s="-------";break;case"input":switch(c.attr("type")){case"text":s={type:"text",name:o||n(r),disabled:!!c.attr("disabled"),value:c.val()};break;case"checkbox":s={type:"checkbox",name:o||n(r),disabled:!!c.attr("disabled"),selected:!!c.attr("checked")};break;case"radio":s={type:"radio",name:o||n(r),disabled:!!c.attr("disabled"),radio:!!c.attr("name"),value:c.val(),selected:!!c.attr("checked")};break;default:s=void 0}break;case"select":s={type:"select",name:o||n(r),disabled:!!c.attr("disabled"),selected:c.val(),options:{}},c.children().each(function(){s.options[this.value]=e(this).text()});break;case"textarea":s={type:"textarea",name:o||n(r),disabled:!!c.attr("disabled"),value:c.val()};break;case"label":break;default:s={type:"html",html:c.clone(!0)}}s&&(i++,t["key"+i]=s)}),i}if(e.support.htmlMenuitem="HTMLMenuItemElement"in window,e.support.htmlCommand="HTMLCommandElement"in window,e.support.eventSelectstart="onselectstart"in document.documentElement,!e.ui||!e.ui.widget){var o=e.cleanData;e.cleanData=function(t){for(var n,a=0;null!=(n=t[a]);a++)try{e(n).triggerHandler("remove")}catch(i){}o(t)}}var i=null,s=!1,c=e(window),r=0,l={},u={},d={},m={selector:null,appendTo:null,trigger:"right",autoHide:!1,delay:200,reposition:!0,determinePosition:function(t){if(e.ui&&e.ui.position)t.css("display","block").position({my:"center top",at:"center bottom",of:this,offset:"0 5",collision:"fit"}).css("display","none");else{var n=this.offset();n.top+=this.outerHeight(),n.left+=this.outerWidth()/2-t.outerWidth()/2,t.css(n)}},position:function(e,t,n){var a;if(!t&&!n)return void e.determinePosition.call(this,e.$menu);a="maintain"===t&&"maintain"===n?e.$menu.position():{top:n,left:t};var o=c.scrollTop()+c.height(),i=c.scrollLeft()+c.width(),s=e.$menu.height(),r=e.$menu.width();a.top+s>o&&(a.top-=s),a.top<0&&(a.top=0),a.left+r>i&&(a.left-=r),e.$menu.css(a)},positionSubmenu:function(t){if(e.ui&&e.ui.position)t.css("display","block").position({my:"left top",at:"right top",of:this,collision:"flipfit fit"}).css("display","");else{var n={top:0,left:this.outerWidth()};t.css(n)}},zIndex:1,animation:{duration:50,show:"slideDown",hide:"slideUp"},events:{show:e.noop,hide:e.noop},callback:null,items:{}},p={timer:null,pageX:null,pageY:null},f=function(e){for(var t=0,n=e;;)if(t=Math.max(t,parseInt(n.css("z-index"),10)||0),n=n.parent(),!n||!n.length||"html body".indexOf(n.prop("nodeName").toLowerCase())>-1)break;return t},h={abortevent:function(e){e.preventDefault(),e.stopImmediatePropagation()},contextmenu:function(t){var n=e(this);if("right"===t.data.trigger&&(t.preventDefault(),t.stopImmediatePropagation()),!("right"!==t.data.trigger&&"demand"!==t.data.trigger&&t.originalEvent||n.hasClass("context-menu-active")||n.hasClass("context-menu-disabled"))){if(i=n,t.data.build){var a=t.data.build(i,t);if(a===!1)return;if(t.data=e.extend(!0,{},m,t.data,a||{}),!t.data.items||e.isEmptyObject(t.data.items))throw window.console&&(console.error||console.log).call(console,"No items specified to show in contextMenu"),new Error("No Items specified");t.data.$trigger=i,x.create(t.data)}var o=!1;for(var s in t.data.items)if(t.data.items.hasOwnProperty(s)){var c;c=e.isFunction(t.data.items[s].visible)?t.data.items[s].visible.call(e(t.currentTarget),s,t.data):"undefined"!=typeof s.visible?t.data.items[s].visible===!0:!0,c&&(o=!0)}o&&x.show.call(n,t.data,t.pageX,t.pageY)}},click:function(t){t.preventDefault(),t.stopImmediatePropagation(),e(this).trigger(e.Event("contextmenu",{data:t.data,pageX:t.pageX,pageY:t.pageY}))},mousedown:function(t){var n=e(this);i&&i.length&&!i.is(n)&&i.data("contextMenu").$menu.trigger("contextmenu:hide"),2===t.button&&(i=n.data("contextMenuActive",!0))},mouseup:function(t){var n=e(this);n.data("contextMenuActive")&&i&&i.length&&i.is(n)&&!n.hasClass("context-menu-disabled")&&(t.preventDefault(),t.stopImmediatePropagation(),i=n,n.trigger(e.Event("contextmenu",{data:t.data,pageX:t.pageX,pageY:t.pageY}))),n.removeData("contextMenuActive")},mouseenter:function(t){var n=e(this),a=e(t.relatedTarget),o=e(document);a.is(".context-menu-list")||a.closest(".context-menu-list").length||i&&i.length||(p.pageX=t.pageX,p.pageY=t.pageY,p.data=t.data,o.on("mousemove.contextMenuShow",h.mousemove),p.timer=setTimeout(function(){p.timer=null,o.off("mousemove.contextMenuShow"),i=n,n.trigger(e.Event("contextmenu",{data:p.data,pageX:p.pageX,pageY:p.pageY}))},t.data.delay))},mousemove:function(e){p.pageX=e.pageX,p.pageY=e.pageY},mouseleave:function(t){var n=e(t.relatedTarget);if(!n.is(".context-menu-list")&&!n.closest(".context-menu-list").length){try{clearTimeout(p.timer)}catch(t){}p.timer=null}},layerClick:function(t){var n,a,o=e(this),i=o.data("contextMenuRoot"),s=t.button,r=t.pageX,l=t.pageY;t.preventDefault(),t.stopImmediatePropagation(),setTimeout(function(){var o,u="left"===i.trigger&&0===s||"right"===i.trigger&&2===s;if(document.elementFromPoint&&(i.$layer.hide(),n=document.elementFromPoint(r-c.scrollLeft(),l-c.scrollTop()),i.$layer.show()),i.reposition&&u)if(document.elementFromPoint){if(i.$trigger.is(n)||i.$trigger.has(n).length)return void i.position.call(i.$trigger,i,r,l)}else if(a=i.$trigger.offset(),o=e(window),a.top+=o.scrollTop(),a.top<=t.pageY&&(a.left+=o.scrollLeft(),a.left<=t.pageX&&(a.bottom=a.top+i.$trigger.outerHeight(),a.bottom>=t.pageY&&(a.right=a.left+i.$trigger.outerWidth(),a.right>=t.pageX))))return void i.position.call(i.$trigger,i,r,l);n&&u&&i.$trigger.one("contextmenu:hidden",function(){e(n).contextMenu({x:r,y:l})}),i.$menu.trigger("contextmenu:hide")},50)},keyStop:function(e,t){t.isInput||e.preventDefault(),e.stopPropagation()},key:function(e){var t={};switch(i&&(t=i.data("contextMenu")||{}),e.keyCode){case 9:case 38:if(h.keyStop(e,t),t.isInput){if(9===e.keyCode&&e.shiftKey)return e.preventDefault(),t.$selected&&t.$selected.find("input, textarea, select").blur(),void t.$menu.trigger("prevcommand");if(38===e.keyCode&&"checkbox"===t.$selected.find("input, textarea, select").prop("type"))return void e.preventDefault()}else if(9!==e.keyCode||e.shiftKey)return void t.$menu.trigger("prevcommand");case 40:if(h.keyStop(e,t),!t.isInput)return void t.$menu.trigger("nextcommand");if(9===e.keyCode)return e.preventDefault(),t.$selected&&t.$selected.find("input, textarea, select").blur(),void t.$menu.trigger("nextcommand");if(40===e.keyCode&&"checkbox"===t.$selected.find("input, textarea, select").prop("type"))return void e.preventDefault();break;case 37:if(h.keyStop(e,t),t.isInput||!t.$selected||!t.$selected.length)break;if(!t.$selected.parent().hasClass("context-menu-root")){var n=t.$selected.parent().parent();return t.$selected.trigger("contextmenu:blur"),void(t.$selected=n)}break;case 39:if(h.keyStop(e,t),t.isInput||!t.$selected||!t.$selected.length)break;var a=t.$selected.data("contextMenu")||{};if(a.$menu&&t.$selected.hasClass("context-menu-submenu"))return t.$selected=null,a.$selected=null,void a.$menu.trigger("nextcommand");break;case 35:case 36:return t.$selected&&t.$selected.find("input, textarea, select").length?void 0:((t.$selected&&t.$selected.parent()||t.$menu).children(":not(.disabled, .not-selectable)")[36===e.keyCode?"first":"last"]().trigger("contextmenu:focus"),void e.preventDefault());case 13:if(h.keyStop(e,t),t.isInput){if(t.$selected&&!t.$selected.is("textarea, select"))return void e.preventDefault();break}return void("undefined"!=typeof t.$selected&&t.$selected.trigger("mouseup"));case 32:case 33:case 34:return void h.keyStop(e,t);case 27:return h.keyStop(e,t),void t.$menu.trigger("contextmenu:hide");default:var o=String.fromCharCode(e.keyCode).toUpperCase();if(t.accesskeys&&t.accesskeys[o])return void t.accesskeys[o].$node.trigger(t.accesskeys[o].$menu?"contextmenu:focus":"mouseup")}e.stopPropagation(),"undefined"!=typeof t.$selected&&t.$selected.trigger(e)},prevItem:function(t){t.stopPropagation();var n=e(this).data("contextMenu")||{};if(n.$selected){var a=n.$selected;n=n.$selected.parent().data("contextMenu")||{},n.$selected=a}for(var o=n.$menu.children(),i=n.$selected&&n.$selected.prev().length?n.$selected.prev():o.last(),s=i;i.hasClass("disabled")||i.hasClass("not-selectable");)if(i=i.prev().length?i.prev():o.last(),i.is(s))return;n.$selected&&h.itemMouseleave.call(n.$selected.get(0),t),h.itemMouseenter.call(i.get(0),t);var c=i.find("input, textarea, select");c.length&&c.focus()},nextItem:function(t){t.stopPropagation();var n=e(this).data("contextMenu")||{};if(n.$selected){var a=n.$selected;n=n.$selected.parent().data("contextMenu")||{},n.$selected=a}for(var o=n.$menu.children(),i=n.$selected&&n.$selected.next().length?n.$selected.next():o.first(),s=i;i.hasClass("disabled")||i.hasClass("not-selectable");)if(i=i.next().length?i.next():o.first(),i.is(s))return;n.$selected&&h.itemMouseleave.call(n.$selected.get(0),t),h.itemMouseenter.call(i.get(0),t);var c=i.find("input, textarea, select");c.length&&c.focus()},focusInput:function(){var t=e(this).closest(".context-menu-item"),n=t.data(),a=n.contextMenu,o=n.contextMenuRoot;o.$selected=a.$selected=t,o.isInput=a.isInput=!0},blurInput:function(){var t=e(this).closest(".context-menu-item"),n=t.data(),a=n.contextMenu,o=n.contextMenuRoot;o.isInput=a.isInput=!1},menuMouseenter:function(){var t=e(this).data().contextMenuRoot;t.hovering=!0},menuMouseleave:function(t){var n=e(this).data().contextMenuRoot;n.$layer&&n.$layer.is(t.relatedTarget)&&(n.hovering=!1)},itemMouseenter:function(t){var n=e(this),a=n.data(),o=a.contextMenu,i=a.contextMenuRoot;return i.hovering=!0,t&&i.$layer&&i.$layer.is(t.relatedTarget)&&(t.preventDefault(),t.stopImmediatePropagation()),(o.$menu?o:i).$menu.children(".hover").trigger("contextmenu:blur"),n.hasClass("disabled")||n.hasClass("not-selectable")?void(o.$selected=null):void n.trigger("contextmenu:focus")},itemMouseleave:function(t){var n=e(this),a=n.data(),o=a.contextMenu,i=a.contextMenuRoot;return i!==o&&i.$layer&&i.$layer.is(t.relatedTarget)?("undefined"!=typeof i.$selected&&i.$selected.trigger("contextmenu:blur"),t.preventDefault(),t.stopImmediatePropagation(),void(i.$selected=o.$selected=o.$node)):void n.trigger("contextmenu:blur")},itemClick:function(t){var n,a=e(this),o=a.data(),i=o.contextMenu,s=o.contextMenuRoot,c=o.contextMenuKey;if(i.items[c]&&!a.is(".disabled, .context-menu-submenu, .context-menu-separator, .not-selectable")){if(t.preventDefault(),t.stopImmediatePropagation(),e.isFunction(s.callbacks[c])&&Object.prototype.hasOwnProperty.call(s.callbacks,c))n=s.callbacks[c];else{if(!e.isFunction(s.callback))return;n=s.callback}n.call(s.$trigger,c,s)!==!1?s.$menu.trigger("contextmenu:hide"):s.$menu.parent().length&&x.update.call(s.$trigger,s)}},inputClick:function(e){e.stopImmediatePropagation()},hideMenu:function(t,n){var a=e(this).data("contextMenuRoot");x.hide.call(a.$trigger,a,n&&n.force)},focusItem:function(t){t.stopPropagation();var n=e(this),a=n.data(),o=a.contextMenu,i=a.contextMenuRoot;n.addClass("hover visible").siblings().removeClass("visible").filter(".hover").trigger("contextmenu:blur"),o.$selected=i.$selected=n,o.$node&&i.positionSubmenu.call(o.$node,o.$menu)},blurItem:function(t){t.stopPropagation();var n=e(this),a=n.data(),o=a.contextMenu;o.autoHide&&n.removeClass("visible"),n.removeClass("hover"),o.$selected=null}},x={show:function(t,n,a){var o=e(this),s={};return e("#context-menu-layer").trigger("mousedown"),t.$trigger=o,t.events.show.call(o,t)===!1?void(i=null):(x.update.call(o,t),t.position.call(o,t,n,a),t.zIndex&&(s.zIndex=f(o)+t.zIndex),x.layer.call(t.$menu,t,s.zIndex),t.$menu.find("ul").css("zIndex",s.zIndex+1),t.$menu.css(s)[t.animation.show](t.animation.duration,function(){o.trigger("contextmenu:visible")}),o.data("contextMenu",t).addClass("context-menu-active"),e(document).off("keydown.contextMenu").on("keydown.contextMenu",h.key),void(t.autoHide&&e(document).on("mousemove.contextMenuAutoHide",function(e){var n=o.offset();n.right=n.left+o.outerWidth(),n.bottom=n.top+o.outerHeight(),!t.$layer||t.hovering||e.pageX>=n.left&&e.pageX<=n.right&&e.pageY>=n.top&&e.pageY<=n.bottom||t.$menu.trigger("contextmenu:hide")})))},hide:function(t,n){var a=e(this);if(t||(t=a.data("contextMenu")||{}),n||!t.events||t.events.hide.call(a,t)!==!1){if(a.removeData("contextMenu").removeClass("context-menu-active"),t.$layer){setTimeout(function(e){return function(){e.remove()}}(t.$layer),10);try{delete t.$layer}catch(o){t.$layer=null}}i=null,t.$menu.find(".hover").trigger("contextmenu:blur"),t.$selected=null,e(document).off(".contextMenuAutoHide").off("keydown.contextMenu"),t.$menu&&t.$menu[t.animation.hide](t.animation.duration,function(){t.build&&(t.$menu.remove(),e.each(t,function(e){switch(e){case"ns":case"selector":case"build":case"trigger":return!0;default:t[e]=void 0;try{delete t[e]}catch(n){}return!0}})),setTimeout(function(){a.trigger("contextmenu:hidden")},10)})}},create:function(n,a){void 0===a&&(a=n),n.$menu=e('<ul class="context-menu-list"></ul>').addClass(n.className||"").data({contextMenu:n,contextMenuRoot:a}),e.each(["callbacks","commands","inputs"],function(e,t){n[t]={},a[t]||(a[t]={})}),a.accesskeys||(a.accesskeys={}),e.each(n.items,function(o,i){var s=e('<li class="context-menu-item"></li>').addClass(i.className||""),c=null,r=null;if(s.on("click",e.noop),i.$node=s.data({contextMenu:n,contextMenuRoot:a,contextMenuKey:o}),"undefined"!=typeof i.accesskey)for(var l,u=t(i.accesskey),m=0;l=u[m];m++)if(!a.accesskeys[l]){a.accesskeys[l]=i,i._name=i.name.replace(new RegExp("("+l+")","i"),'<span class="context-menu-accesskey">$1</span>');break}if("string"==typeof i)s.addClass("context-menu-separator not-selectable");else if(i.type&&d[i.type])d[i.type].call(s,i,n,a),e.each([n,a],function(t,n){n.commands[o]=i,e.isFunction(i.callback)&&(n.callbacks[o]=i.callback)});else{switch("html"===i.type?s.addClass("context-menu-html not-selectable"):i.type?(c=e("<label></label>").appendTo(s),e("<span></span>").html(i._name||i.name).appendTo(c),s.addClass("context-menu-input"),n.hasTypes=!0,e.each([n,a],function(e,t){t.commands[o]=i,t.inputs[o]=i})):i.items&&(i.type="sub"),i.type){case"text":r=e('<input type="text" value="1" name="" value="">').attr("name","context-menu-input-"+o).val(i.value||"").appendTo(c);break;case"textarea":r=e('<textarea name=""></textarea>').attr("name","context-menu-input-"+o).val(i.value||"").appendTo(c),i.height&&r.height(i.height);break;case"checkbox":r=e('<input type="checkbox" value="1" name="" value="">').attr("name","context-menu-input-"+o).val(i.value||"").prop("checked",!!i.selected).prependTo(c);break;case"radio":r=e('<input type="radio" value="1" name="" value="">').attr("name","context-menu-input-"+i.radio).val(i.value||"").prop("checked",!!i.selected).prependTo(c);break;case"select":r=e('<select name="">').attr("name","context-menu-input-"+o).appendTo(c),i.options&&(e.each(i.options,function(t,n){e("<option></option>").val(t).text(n).appendTo(r)}),r.val(i.selected));break;case"sub":e("<span></span>").html(i._name||i.name).appendTo(s),i.appendTo=i.$node,x.create(i,a),s.data("contextMenu",i).addClass("context-menu-submenu"),i.callback=null;break;case"html":e(i.html).appendTo(s);break;default:e.each([n,a],function(t,n){n.commands[o]=i,e.isFunction(i.callback)&&(n.callbacks[o]=i.callback)}),e("<span></span>").html(i._name||i.name||"").appendTo(s)}i.type&&"sub"!==i.type&&"html"!==i.type&&(r.on("focus",h.focusInput).on("blur",h.blurInput),i.events&&r.on(i.events,n)),i.icon&&(i._icon=e.isFunction(i.icon)?i.icon.call(this,s,o,i):"icon icon-"+i.icon,s.addClass(i._icon))}i.$input=r,i.$label=c,s.appendTo(n.$menu),!n.hasTypes&&e.support.eventSelectstart&&s.on("selectstart.disableTextSelect",h.abortevent)}),n.$node||n.$menu.css("display","none").addClass("context-menu-root"),n.$menu.appendTo(n.appendTo||document.body)},resize:function(t,n){t.css({position:"absolute",display:"block"}),t.data("width",Math.ceil(t.width())),t.css({position:"static",minWidth:"0px",maxWidth:"100000px"}),t.find("> li > ul").each(function(){x.resize(e(this),!0)}),n||t.find("ul").addBack().css({position:"",display:"",minWidth:"",maxWidth:""}).width(function(){return e(this).data("width")})},update:function(t,n){var a=this;void 0===n&&(n=t,x.resize(t.$menu)),t.$menu.children().each(function(){var o,i=e(this),s=i.data("contextMenuKey"),c=t.items[s],r=e.isFunction(c.disabled)&&c.disabled.call(a,s,n)||c.disabled===!0;if(o=e.isFunction(c.visible)?c.visible.call(a,s,n):"undefined"!=typeof c.visible?c.visible===!0:!0,i[o?"show":"hide"](),i[r?"addClass":"removeClass"]("disabled"),e.isFunction(c.icon)&&(i.removeClass(c._icon),c._icon=c.icon.call(this,a,s,c),i.addClass(c._icon)),c.type)switch(i.find("input, select, textarea").prop("disabled",r),c.type){case"text":case"textarea":c.$input.val(c.value||"");break;case"checkbox":case"radio":c.$input.val(c.value||"").prop("checked",!!c.selected);break;case"select":c.$input.val(c.selected||"")}c.$menu&&x.update.call(a,c,n)})},layer:function(t,n){var a=t.$layer=e('<div id="context-menu-layer" style="position:fixed; z-index:'+n+'; top:0; left:0; opacity: 0; filter: alpha(opacity=0); background-color: #000;"></div>').css({height:c.height(),width:c.width(),display:"block"}).data("contextMenuRoot",t).insertBefore(this).on("contextmenu",h.abortevent).on("mousedown",h.layerClick);return void 0===document.body.style.maxWidth&&a.css({position:"absolute",height:e(document).height()}),a}};e.fn.contextMenu=function(t){var n=this,a=t;if(this.length>0)if(void 0===t)this.first().trigger("contextmenu");else if(t.x&&t.y)this.first().trigger(e.Event("contextmenu",{pageX:t.x,pageY:t.y}));else if("hide"===t){var o=this.first().data("contextMenu")?this.first().data("contextMenu").$menu:null;o&&o.trigger("contextmenu:hide")}else"destroy"===t?e.contextMenu("destroy",{context:this}):e.isPlainObject(t)?(t.context=this,e.contextMenu("create",t)):t?this.removeClass("context-menu-disabled"):t||this.addClass("context-menu-disabled");else e.each(u,function(){this.selector===n.selector&&(a.data=this,e.extend(a.data,{trigger:"demand"}))}),h.contextmenu.call(a.target,a);return this},e.contextMenu=function(t,n){"string"!=typeof t&&(n=t,t="create"),"string"==typeof n?n={selector:n}:void 0===n&&(n={});var a=e.extend(!0,{},m,n||{}),o=e(document),i=o,c=!1;switch(a.context&&a.context.length?(i=e(a.context).first(),a.context=i.get(0),c=a.context!==document):a.context=document,t){case"create":if(!a.selector)throw new Error("No selector specified");if(a.selector.match(/.context-menu-(list|item|input)($|\s)/))throw new Error('Cannot bind to selector "'+a.selector+'" as it contains a reserved className');if(!a.build&&(!a.items||e.isEmptyObject(a.items)))throw new Error("No Items specified");switch(r++,a.ns=".contextMenu"+r,c||(l[a.selector]=a.ns),u[a.ns]=a,a.trigger||(a.trigger="right"),s||(o.on({"contextmenu:hide.contextMenu":h.hideMenu,"prevcommand.contextMenu":h.prevItem,"nextcommand.contextMenu":h.nextItem,"contextmenu.contextMenu":h.abortevent,"mouseenter.contextMenu":h.menuMouseenter,"mouseleave.contextMenu":h.menuMouseleave},".context-menu-list").on("mouseup.contextMenu",".context-menu-input",h.inputClick).on({"mouseup.contextMenu":h.itemClick,"contextmenu:focus.contextMenu":h.focusItem,"contextmenu:blur.contextMenu":h.blurItem,"contextmenu.contextMenu":h.abortevent,"mouseenter.contextMenu":h.itemMouseenter,"mouseleave.contextMenu":h.itemMouseleave},".context-menu-item"),s=!0),i.on("contextmenu"+a.ns,a.selector,a,h.contextmenu),c&&i.on("remove"+a.ns,function(){e(this).contextMenu("destroy")}),a.trigger){case"hover":i.on("mouseenter"+a.ns,a.selector,a,h.mouseenter).on("mouseleave"+a.ns,a.selector,a,h.mouseleave);break;case"left":i.on("click"+a.ns,a.selector,a,h.click)}a.build||x.create(a);break;case"destroy":var d;if(c){var p=a.context;e.each(u,function(t,n){if(n.context!==p)return!0;d=e(".context-menu-list").filter(":visible"),d.length&&d.data().contextMenuRoot.$trigger.is(e(n.context).find(n.selector))&&d.trigger("contextmenu:hide",{force:!0});try{u[n.ns].$menu&&u[n.ns].$menu.remove(),delete u[n.ns]}catch(a){u[n.ns]=null}return e(n.context).off(n.ns),!0})}else if(a.selector){if(l[a.selector]){d=e(".context-menu-list").filter(":visible"),d.length&&d.data().contextMenuRoot.$trigger.is(a.selector)&&d.trigger("contextmenu:hide",{force:!0});try{u[l[a.selector]].$menu&&u[l[a.selector]].$menu.remove(),delete u[l[a.selector]]}catch(f){u[l[a.selector]]=null}o.off(l[a.selector])}}else o.off(".contextMenu .contextMenuAutoHide"),e.each(u,function(t,n){e(n.context).off(n.ns)}),l={},u={},r=0,s=!1,e("#context-menu-layer, .context-menu-list").remove();break;case"html5":(!e.support.htmlCommand&&!e.support.htmlMenuitem||"boolean"==typeof n&&n)&&e('menu[type="context"]').each(function(){this.id&&e.contextMenu({selector:"[contextmenu="+this.id+"]",items:e.contextMenu.fromMenu(this)})}).css("display","none");break;default:throw new Error('Unknown operation "'+t+'"')}return this},e.contextMenu.setInputValues=function(t,n){void 0===n&&(n={}),e.each(t.inputs,function(e,t){switch(t.type){case"text":case"textarea":t.value=n[e]||"";break;case"checkbox":t.selected=n[e]?!0:!1;break;case"radio":t.selected=(n[t.radio]||"")===t.value;break;case"select":t.selected=n[e]||""}})},e.contextMenu.getInputValues=function(t,n){return void 0===n&&(n={}),e.each(t.inputs,function(e,t){switch(t.type){case"text":case"textarea":case"select":n[e]=t.$input.val();break;case"checkbox":n[e]=t.$input.prop("checked");break;case"radio":t.$input.prop("checked")&&(n[t.radio]=t.value)}}),n},e.contextMenu.fromMenu=function(t){var n=e(t),o={};return a(o,n.children()),o},e.contextMenu.defaults=m,e.contextMenu.types=d,e.contextMenu.handle=h,e.contextMenu.op=x,e.contextMenu.menus=u});
|