summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorTooru Fujisawa <arai.unmht@gmail.com>2016-09-15 00:19:54 +0200
committerDylan William Hardison <dylan@hardison.net>2016-09-15 00:30:29 +0200
commit639a051e3aea3608efd7607b944b2c33aa17cfe5 (patch)
tree7fd7053427e072ea46b9e773f3f07c69199ece6e /js
parent7ab2e46e4b0ec991f5f51c2b8f384ba7321945fc (diff)
downloadbugzilla-639a051e3aea3608efd7607b944b2c33aa17cfe5.tar.gz
bugzilla-639a051e3aea3608efd7607b944b2c33aa17cfe5.tar.xz
Bug 1213791 - "suggested reviewers" menu overflows horizontally from visible area if reviewers have long name.
Diffstat (limited to 'js')
-rw-r--r--js/jquery/plugins/contextMenu/contextMenu-min.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/js/jquery/plugins/contextMenu/contextMenu-min.js b/js/jquery/plugins/contextMenu/contextMenu-min.js
index 9b7f33d5d..91ade6c22 100644
--- a/js/jquery/plugins/contextMenu/contextMenu-min.js
+++ b/js/jquery/plugins/contextMenu/contextMenu-min.js
@@ -1,14 +1,17 @@
/*!
- * jQuery contextMenu - Plugin for simple contextMenu handling
+ * jQuery contextMenu v2.2.4 - Plugin for simple contextMenu handling
*
- * Version: git-master
+ * Version: v2.2.4
*
- * Authors: Rodney Rehm, Addy Osmani (patches for FF)
- * Web: http://medialize.github.com/jQuery-contextMenu/
+ * Authors: Björn Brala (SWIS.nl), Rodney Rehm, Addy Osmani (patches for FF)
+ * Web: http://swisnl.github.io/jQuery-contextMenu/
+ *
+ * Copyright (c) 2011-2016 SWIS BV and contributors
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
* GPL v3 http://opensource.org/licenses/GPL-3.0
*
+ * Date: 2016-08-26T13:44:56.511Z
*/
-(function($,undefined){$.support.htmlMenuitem=("HTMLMenuItemElement" in window);$.support.htmlCommand=("HTMLCommandElement" in window);$.support.eventSelectstart=("onselectstart" in document.documentElement);if(!$.ui||!$.ui.widget){var _cleanData=$.cleanData;$.cleanData=function(elems){for(var i=0,elem;(elem=elems[i])!=null;i++){try{$(elem).triggerHandler("remove")}catch(e){}}_cleanData(elems)}}var $currentTrigger=null,initialized=false,$win=$(window),counter=0,namespaces={},menus={},types={},defaults={selector:null,appendTo:null,trigger:"right",autoHide:false,delay:200,reposition:true,determinePosition:function($menu){if($.ui&&$.ui.position){$menu.css("display","block").position({my:"center top",at:"center bottom",of:this,offset:"0 5",collision:"fit"}).css("display","none")}else{var offset=this.offset();offset.top+=this.outerHeight();offset.left+=this.outerWidth()/2-$menu.outerWidth()/2;$menu.css(offset)}},position:function(opt,x,y){var $this=this,offset;if(!x&&!y){opt.determinePosition.call(this,opt.$menu);return}else{if(x==="maintain"&&y==="maintain"){offset=opt.$menu.position()}else{offset={top:y,left:x}}}var bottom=$win.scrollTop()+$win.height(),right=$win.scrollLeft()+$win.width(),height=opt.$menu.height(),width=opt.$menu.width();if(offset.top+height>bottom){offset.top-=height}if(offset.top<0){offset.top=0}if(offset.left+width>right){offset.left-=width}opt.$menu.css(offset)},positionSubmenu:function($menu){if($.ui&&$.ui.position){$menu.css("display","block").position({my:"left top",at:"right top",of:this,collision:"flipfit fit"}).css("display","")}else{var offset={top:0,left:this.outerWidth()};$menu.css(offset)}},zIndex:1,animation:{duration:50,show:"slideDown",hide:"slideUp"},events:{show:$.noop,hide:$.noop},callback:null,items:{}},hoveract={timer:null,pageX:null,pageY:null},zindex=function($t){var zin=0,$tt=$t;while(true){zin=Math.max(zin,parseInt($tt.css("z-index"),10)||0);$tt=$tt.parent();if(!$tt||!$tt.length||"html body".indexOf($tt.prop("nodeName").toLowerCase())>-1){break}}return zin},handle={abortevent:function(e){e.preventDefault();e.stopImmediatePropagation()},contextmenu:function(e){var $this=$(this);if(e.data.trigger=="right"){e.preventDefault();e.stopImmediatePropagation()}if(e.data.trigger!="right"&&e.originalEvent){return}if($this.hasClass("context-menu-active")){return}if(!$this.hasClass("context-menu-disabled")){$currentTrigger=$this;if(e.data.build){var built=e.data.build($currentTrigger,e);if(built===false){return}e.data=$.extend(true,{},defaults,e.data,built||{});if(!e.data.items||$.isEmptyObject(e.data.items)){if(window.console){(console.error||console.log).call(console,"No items specified to show in contextMenu")}throw new Error("No Items specified")}e.data.$trigger=$currentTrigger;op.create(e.data)}op.show.call($this,e.data,e.pageX,e.pageY)}},click:function(e){e.preventDefault();e.stopImmediatePropagation();$(this).trigger($.Event("contextmenu",{data:e.data,pageX:e.pageX,pageY:e.pageY}))},mousedown:function(e){var $this=$(this);if($currentTrigger&&$currentTrigger.length&&!$currentTrigger.is($this)){$currentTrigger.data("contextMenu").$menu.trigger("contextmenu:hide")}if(e.button==2){$currentTrigger=$this.data("contextMenuActive",true)}},mouseup:function(e){var $this=$(this);if($this.data("contextMenuActive")&&$currentTrigger&&$currentTrigger.length&&$currentTrigger.is($this)&&!$this.hasClass("context-menu-disabled")){e.preventDefault();e.stopImmediatePropagation();$currentTrigger=$this;$this.trigger($.Event("contextmenu",{data:e.data,pageX:e.pageX,pageY:e.pageY}))}$this.removeData("contextMenuActive")},mouseenter:function(e){var $this=$(this),$related=$(e.relatedTarget),$document=$(document);if($related.is(".context-menu-list")||$related.closest(".context-menu-list").length){return}if($currentTrigger&&$currentTrigger.length){return}hoveract.pageX=e.pageX;hoveract.pageY=e.pageY;hoveract.data=e.data;$document.on("mousemove.contextMenuShow",handle.mousemove);hoveract.timer=setTimeout(function(){hoveract.timer=null;$document.off("mousemove.contextMenuShow");$currentTrigger=$this;$this.trigger($.Event("contextmenu",{data:hoveract.data,pageX:hoveract.pageX,pageY:hoveract.pageY}))},e.data.delay)},mousemove:function(e){hoveract.pageX=e.pageX;hoveract.pageY=e.pageY},mouseleave:function(e){var $related=$(e.relatedTarget);if($related.is(".context-menu-list")||$related.closest(".context-menu-list").length){return}try{clearTimeout(hoveract.timer)}catch(e){}hoveract.timer=null},layerClick:function(e){var $this=$(this),root=$this.data("contextMenuRoot"),button=e.button,x=e.pageX,y=e.pageY,target,offset;e.preventDefault();e.stopImmediatePropagation();setTimeout(function(){var $window;var triggerAction=((root.trigger=="left"&&button===0)||(root.trigger=="right"&&button===2));if(document.elementFromPoint){root.$layer.hide();target=document.elementFromPoint(x-$win.scrollLeft(),y-$win.scrollTop());root.$layer.show()}if(root.reposition&&triggerAction){if(document.elementFromPoint){if(root.$trigger.is(target)||root.$trigger.has(target).length){root.position.call(root.$trigger,root,x,y);return}}else{offset=root.$trigger.offset();$window=$(window);offset.top+=$window.scrollTop();if(offset.top<=e.pageY){offset.left+=$window.scrollLeft();if(offset.left<=e.pageX){offset.bottom=offset.top+root.$trigger.outerHeight();if(offset.bottom>=e.pageY){offset.right=offset.left+root.$trigger.outerWidth();if(offset.right>=e.pageX){root.position.call(root.$trigger,root,x,y);return}}}}}}if(target&&triggerAction){root.$trigger.one("contextmenu:hidden",function(){$(target).contextMenu({x:x,y:y})})}root.$menu.trigger("contextmenu:hide")},50)},keyStop:function(e,opt){if(!opt.isInput){e.preventDefault()}e.stopPropagation()},key:function(e){var opt={};if($currentTrigger){opt=$currentTrigger.data("contextMenu")||{}}switch(e.keyCode){case 9:case 38:handle.keyStop(e,opt);if(opt.isInput){if(e.keyCode==9&&e.shiftKey){e.preventDefault();opt.$selected&&opt.$selected.find("input, textarea, select").blur();opt.$menu.trigger("prevcommand");return}else{if(e.keyCode==38&&opt.$selected.find("input, textarea, select").prop("type")=="checkbox"){e.preventDefault();return}}}else{if(e.keyCode!=9||e.shiftKey){opt.$menu.trigger("prevcommand");return}}case 40:handle.keyStop(e,opt);if(opt.isInput){if(e.keyCode==9){e.preventDefault();opt.$selected&&opt.$selected.find("input, textarea, select").blur();opt.$menu.trigger("nextcommand");return}else{if(e.keyCode==40&&opt.$selected.find("input, textarea, select").prop("type")=="checkbox"){e.preventDefault();return}}}else{opt.$menu.trigger("nextcommand");return}break;case 37:handle.keyStop(e,opt);if(opt.isInput||!opt.$selected||!opt.$selected.length){break}if(!opt.$selected.parent().hasClass("context-menu-root")){var $parent=opt.$selected.parent().parent();opt.$selected.trigger("contextmenu:blur");opt.$selected=$parent;return}break;case 39:handle.keyStop(e,opt);if(opt.isInput||!opt.$selected||!opt.$selected.length){break}var itemdata=opt.$selected.data("contextMenu")||{};if(itemdata.$menu&&opt.$selected.hasClass("context-menu-submenu")){opt.$selected=null;itemdata.$selected=null;itemdata.$menu.trigger("nextcommand");return}break;case 35:case 36:if(opt.$selected&&opt.$selected.find("input, textarea, select").length){return}else{(opt.$selected&&opt.$selected.parent()||opt.$menu).children(":not(.disabled, .not-selectable)")[e.keyCode==36?"first":"last"]().trigger("contextmenu:focus");e.preventDefault();return}break;case 13:handle.keyStop(e,opt);if(opt.isInput){if(opt.$selected&&!opt.$selected.is("textarea, select")){e.preventDefault();return}break}opt.$selected&&opt.$selected.trigger("mouseup");return;case 32:case 33:case 34:handle.keyStop(e,opt);return;case 27:handle.keyStop(e,opt);opt.$menu.trigger("contextmenu:hide");return;default:var k=(String.fromCharCode(e.keyCode)).toUpperCase();if(opt.accesskeys&&opt.accesskeys[k]){opt.accesskeys[k].$node.trigger(opt.accesskeys[k].$menu?"contextmenu:focus":"mouseup");return}break}e.stopPropagation();opt.$selected&&opt.$selected.trigger(e)},prevItem:function(e){e.stopPropagation();var opt=$(this).data("contextMenu")||{};if(opt.$selected){var $s=opt.$selected;opt=opt.$selected.parent().data("contextMenu")||{};opt.$selected=$s}var $children=opt.$menu.children(),$prev=!opt.$selected||!opt.$selected.prev().length?$children.last():opt.$selected.prev(),$round=$prev;while($prev.hasClass("disabled")||$prev.hasClass("not-selectable")){if($prev.prev().length){$prev=$prev.prev()}else{$prev=$children.last()}if($prev.is($round)){return}}if(opt.$selected){handle.itemMouseleave.call(opt.$selected.get(0),e)}handle.itemMouseenter.call($prev.get(0),e);var $input=$prev.find("input, textarea, select");if($input.length){$input.focus()}},nextItem:function(e){e.stopPropagation();var opt=$(this).data("contextMenu")||{};if(opt.$selected){var $s=opt.$selected;opt=opt.$selected.parent().data("contextMenu")||{};opt.$selected=$s}var $children=opt.$menu.children(),$next=!opt.$selected||!opt.$selected.next().length?$children.first():opt.$selected.next(),$round=$next;while($next.hasClass("disabled")||$next.hasClass("not-selectable")){if($next.next().length){$next=$next.next()}else{$next=$children.first()}if($next.is($round)){return}}if(opt.$selected){handle.itemMouseleave.call(opt.$selected.get(0),e)}handle.itemMouseenter.call($next.get(0),e);var $input=$next.find("input, textarea, select");if($input.length){$input.focus()}},focusInput:function(e){var $this=$(this).closest(".context-menu-item"),data=$this.data(),opt=data.contextMenu,root=data.contextMenuRoot;root.$selected=opt.$selected=$this;root.isInput=opt.isInput=true},blurInput:function(e){var $this=$(this).closest(".context-menu-item"),data=$this.data(),opt=data.contextMenu,root=data.contextMenuRoot;root.isInput=opt.isInput=false},menuMouseenter:function(e){var root=$(this).data().contextMenuRoot;root.hovering=true},menuMouseleave:function(e){var root=$(this).data().contextMenuRoot;if(root.$layer&&root.$layer.is(e.relatedTarget)){root.hovering=false}},itemMouseenter:function(e){var $this=$(this),data=$this.data(),opt=data.contextMenu,root=data.contextMenuRoot;root.hovering=true;if(e&&root.$layer&&root.$layer.is(e.relatedTarget)){e.preventDefault();e.stopImmediatePropagation()}(opt.$menu?opt:root).$menu.children(".hover").trigger("contextmenu:blur");if($this.hasClass("disabled")||$this.hasClass("not-selectable")){opt.$selected=null;return}$this.trigger("contextmenu:focus")},itemMouseleave:function(e){var $this=$(this),data=$this.data(),opt=data.contextMenu,root=data.contextMenuRoot;if(root!==opt&&root.$layer&&root.$layer.is(e.relatedTarget)){root.$selected&&root.$selected.trigger("contextmenu:blur");e.preventDefault();e.stopImmediatePropagation();root.$selected=opt.$selected=opt.$node;return}$this.trigger("contextmenu:blur")},itemClick:function(e){var $this=$(this),data=$this.data(),opt=data.contextMenu,root=data.contextMenuRoot,key=data.contextMenuKey,callback;if(!opt.items[key]||$this.is(".disabled, .context-menu-submenu, .context-menu-separator, .not-selectable")){return}e.preventDefault();e.stopImmediatePropagation();if($.isFunction(root.callbacks[key])&&Object.prototype.hasOwnProperty.call(root.callbacks,key)){callback=root.callbacks[key]}else{if($.isFunction(root.callback)){callback=root.callback}else{return}}if(callback.call(root.$trigger,key,root)!==false){root.$menu.trigger("contextmenu:hide")}else{if(root.$menu.parent().length){op.update.call(root.$trigger,root)}}},inputClick:function(e){e.stopImmediatePropagation()},hideMenu:function(e,data){var root=$(this).data("contextMenuRoot");op.hide.call(root.$trigger,root,data&&data.force)},focusItem:function(e){e.stopPropagation();var $this=$(this),data=$this.data(),opt=data.contextMenu,root=data.contextMenuRoot;$this.addClass("hover").siblings(".hover").trigger("contextmenu:blur");opt.$selected=root.$selected=$this;if(opt.$node){root.positionSubmenu.call(opt.$node,opt.$menu)}},blurItem:function(e){e.stopPropagation();var $this=$(this),data=$this.data(),opt=data.contextMenu;$this.removeClass("hover");opt.$selected=null}},op={show:function(opt,x,y){var $trigger=$(this),css={};$("#context-menu-layer").trigger("mousedown");opt.$trigger=$trigger;if(opt.events.show.call($trigger,opt)===false){$currentTrigger=null;return}op.update.call($trigger,opt);opt.position.call($trigger,opt,x,y);if(opt.zIndex){css.zIndex=zindex($trigger)+opt.zIndex}op.layer.call(opt.$menu,opt,css.zIndex);opt.$menu.find("ul").css("zIndex",css.zIndex+1);opt.$menu.css(css)[opt.animation.show](opt.animation.duration,function(){$trigger.trigger("contextmenu:visible")});$trigger.data("contextMenu",opt).addClass("context-menu-active");$(document).off("keydown.contextMenu").on("keydown.contextMenu",handle.key);if(opt.autoHide){$(document).on("mousemove.contextMenuAutoHide",function(e){var pos=$trigger.offset();pos.right=pos.left+$trigger.outerWidth();pos.bottom=pos.top+$trigger.outerHeight();if(opt.$layer&&!opt.hovering&&(!(e.pageX>=pos.left&&e.pageX<=pos.right)||!(e.pageY>=pos.top&&e.pageY<=pos.bottom))){opt.$menu.trigger("contextmenu:hide")}})}},hide:function(opt,force){var $trigger=$(this);if(!opt){opt=$trigger.data("contextMenu")||{}}if(!force&&opt.events&&opt.events.hide.call($trigger,opt)===false){return}$trigger.removeData("contextMenu").removeClass("context-menu-active");if(opt.$layer){setTimeout((function($layer){return function(){$layer.remove()}})(opt.$layer),10);try{delete opt.$layer}catch(e){opt.$layer=null}}$currentTrigger=null;opt.$menu.find(".hover").trigger("contextmenu:blur");opt.$selected=null;$(document).off(".contextMenuAutoHide").off("keydown.contextMenu");opt.$menu&&opt.$menu[opt.animation.hide](opt.animation.duration,function(){if(opt.build){opt.$menu.remove();$.each(opt,function(key,value){switch(key){case"ns":case"selector":case"build":case"trigger":return true;default:opt[key]=undefined;try{delete opt[key]}catch(e){}return true}})}setTimeout(function(){$trigger.trigger("contextmenu:hidden")},10)})},create:function(opt,root){if(root===undefined){root=opt}opt.$menu=$('<ul class="context-menu-list"></ul>').addClass(opt.className||"").data({contextMenu:opt,contextMenuRoot:root});$.each(["callbacks","commands","inputs"],function(i,k){opt[k]={};if(!root[k]){root[k]={}}});root.accesskeys||(root.accesskeys={});$.each(opt.items,function(key,item){var $t=$('<li class="context-menu-item"></li>').addClass(item.className||""),$label=null,$input=null;$t.on("click",$.noop);item.$node=$t.data({contextMenu:opt,contextMenuRoot:root,contextMenuKey:key});if(item.accesskey){var aks=splitAccesskey(item.accesskey);for(var i=0,ak;ak=aks[i];i++){if(!root.accesskeys[ak]){root.accesskeys[ak]=item;item._name=item.name.replace(new RegExp("("+ak+")","i"),'<span class="context-menu-accesskey">$1</span>');break}}}if(typeof item=="string"){$t.addClass("context-menu-separator not-selectable")}else{if(item.type&&types[item.type]){types[item.type].call($t,item,opt,root);$.each([opt,root],function(i,k){k.commands[key]=item;if($.isFunction(item.callback)){k.callbacks[key]=item.callback}})}else{if(item.type=="html"){$t.addClass("context-menu-html not-selectable")}else{if(item.type){$label=$("<label></label>").appendTo($t);$("<span></span>").text(item._name||item.name).appendTo($label);$t.addClass("context-menu-input");opt.hasTypes=true;$.each([opt,root],function(i,k){k.commands[key]=item;k.inputs[key]=item})}else{if(item.items){item.type="sub"}}}switch(item.type){case"text":$input=$('<input type="text" value="1" name="" value="">').attr("name","context-menu-input-"+key).val(item.value||"").appendTo($label);break;case"textarea":$input=$('<textarea name=""></textarea>').attr("name","context-menu-input-"+key).val(item.value||"").appendTo($label);if(item.height){$input.height(item.height)}break;case"checkbox":$input=$('<input type="checkbox" value="1" name="" value="">').attr("name","context-menu-input-"+key).val(item.value||"").prop("checked",!!item.selected).prependTo($label);break;case"radio":$input=$('<input type="radio" value="1" name="" value="">').attr("name","context-menu-input-"+item.radio).val(item.value||"").prop("checked",!!item.selected).prependTo($label);break;case"select":$input=$('<select name="">').attr("name","context-menu-input-"+key).appendTo($label);if(item.options){$.each(item.options,function(value,text){$("<option></option>").val(value).text(text).appendTo($input)});$input.val(item.selected)}break;case"sub":$("<span></span>").text(item._name||item.name).appendTo($t);item.appendTo=item.$node;op.create(item,root);$t.data("contextMenu",item).addClass("context-menu-submenu");item.callback=null;break;case"html":$(item.html).appendTo($t);break;default:$.each([opt,root],function(i,k){k.commands[key]=item;if($.isFunction(item.callback)){k.callbacks[key]=item.callback}});$("<span></span>").text(item._name||item.name||"").appendTo($t);break}if(item.type&&item.type!="sub"&&item.type!="html"){$input.on("focus",handle.focusInput).on("blur",handle.blurInput);if(item.events){$input.on(item.events,opt)}}if(item.icon){$t.addClass("icon icon-"+item.icon)}}}item.$input=$input;item.$label=$label;$t.appendTo(opt.$menu);if(!opt.hasTypes&&$.support.eventSelectstart){$t.on("selectstart.disableTextSelect",handle.abortevent)}});if(!opt.$node){opt.$menu.css("display","none").addClass("context-menu-root")}opt.$menu.appendTo(opt.appendTo||document.body)},resize:function($menu,nested){$menu.css({position:"absolute",display:"block"});$menu.data("width",Math.ceil($menu.width())+1);$menu.css({position:"static",minWidth:"0px",maxWidth:"100000px"});$menu.find("> li > ul").each(function(){op.resize($(this),true)});if(!nested){$menu.find("ul").addBack().css({position:"",display:"",minWidth:"",maxWidth:""}).width(function(){return $(this).data("width")})}},update:function(opt,root){var $trigger=this;if(root===undefined){root=opt;op.resize(opt.$menu)}opt.$menu.children().each(function(){var $item=$(this),key=$item.data("contextMenuKey"),item=opt.items[key],disabled=($.isFunction(item.disabled)&&item.disabled.call($trigger,key,root))||item.disabled===true;$item[disabled?"addClass":"removeClass"]("disabled");if(item.type){$item.find("input, select, textarea").prop("disabled",disabled);switch(item.type){case"text":case"textarea":item.$input.val(item.value||"");break;case"checkbox":case"radio":item.$input.val(item.value||"").prop("checked",!!item.selected);break;case"select":item.$input.val(item.selected||"");break}}if(item.$menu){op.update.call($trigger,item,root)}})},layer:function(opt,zIndex){var $layer=opt.$layer=$('<div id="context-menu-layer" style="position:fixed; z-index:'+zIndex+'; top:0; left:0; opacity: 0; filter: alpha(opacity=0); background-color: #000;"></div>').css({height:$win.height(),width:$win.width(),display:"block"}).data("contextMenuRoot",opt).insertBefore(this).on("contextmenu",handle.abortevent).on("mousedown",handle.layerClick);if(document.body.style.maxWidth===undefined){$layer.css({position:"absolute",height:$(document).height()})}return $layer}};function splitAccesskey(val){var t=val.split(/\s+/),keys=[];for(var i=0,k;k=t[i];i++){k=k.charAt(0).toUpperCase();keys.push(k)}return keys}$.fn.contextMenu=function(operation){if(operation===undefined){this.first().trigger("contextmenu")}else{if(operation.x&&operation.y){this.first().trigger($.Event("contextmenu",{pageX:operation.x,pageY:operation.y}))}else{if(operation==="hide"){var $menu=this.first().data("contextMenu")?this.first().data("contextMenu").$menu:null;$menu&&$menu.trigger("contextmenu:hide")}else{if(operation==="destroy"){$.contextMenu("destroy",{context:this})}else{if($.isPlainObject(operation)){operation.context=this;$.contextMenu("create",operation)}else{if(operation){this.removeClass("context-menu-disabled")}else{if(!operation){this.addClass("context-menu-disabled")}}}}}}}return this};$.contextMenu=function(operation,options){if(typeof operation!="string"){options=operation;operation="create"}if(typeof options=="string"){options={selector:options}}else{if(options===undefined){options={}}}var o=$.extend(true,{},defaults,options||{});var $document=$(document);var $context=$document;var _hasContext=false;if(!o.context||!o.context.length){o.context=document}else{$context=$(o.context).first();o.context=$context.get(0);_hasContext=o.context!==document}switch(operation){case"create":if(!o.selector){throw new Error("No selector specified")}if(o.selector.match(/.context-menu-(list|item|input)($|\s)/)){throw new Error('Cannot bind to selector "'+o.selector+'" as it contains a reserved className')}if(!o.build&&(!o.items||$.isEmptyObject(o.items))){throw new Error("No Items specified")}counter++;o.ns=".contextMenu"+counter;if(!_hasContext){namespaces[o.selector]=o.ns}menus[o.ns]=o;if(!o.trigger){o.trigger="right"}if(!initialized){$document.on({"contextmenu:hide.contextMenu":handle.hideMenu,"prevcommand.contextMenu":handle.prevItem,"nextcommand.contextMenu":handle.nextItem,"contextmenu.contextMenu":handle.abortevent,"mouseenter.contextMenu":handle.menuMouseenter,"mouseleave.contextMenu":handle.menuMouseleave},".context-menu-list").on("mouseup.contextMenu",".context-menu-input",handle.inputClick).on({"mouseup.contextMenu":handle.itemClick,"contextmenu:focus.contextMenu":handle.focusItem,"contextmenu:blur.contextMenu":handle.blurItem,"contextmenu.contextMenu":handle.abortevent,"mouseenter.contextMenu":handle.itemMouseenter,"mouseleave.contextMenu":handle.itemMouseleave},".context-menu-item");initialized=true}$context.on("contextmenu"+o.ns,o.selector,o,handle.contextmenu);if(_hasContext){$context.on("remove"+o.ns,function(){$(this).contextMenu("destroy")})}switch(o.trigger){case"hover":$context.on("mouseenter"+o.ns,o.selector,o,handle.mouseenter).on("mouseleave"+o.ns,o.selector,o,handle.mouseleave);break;case"left":$context.on("click"+o.ns,o.selector,o,handle.click);break}if(!o.build){op.create(o)}break;case"destroy":var $visibleMenu;if(_hasContext){var context=o.context;$.each(menus,function(ns,o){if(o.context!==context){return true}$visibleMenu=$(".context-menu-list").filter(":visible");if($visibleMenu.length&&$visibleMenu.data().contextMenuRoot.$trigger.is($(o.context).find(o.selector))){$visibleMenu.trigger("contextmenu:hide",{force:true})}try{if(menus[o.ns].$menu){menus[o.ns].$menu.remove()}delete menus[o.ns]}catch(e){menus[o.ns]=null}$(o.context).off(o.ns);return true})}else{if(!o.selector){$document.off(".contextMenu .contextMenuAutoHide");$.each(menus,function(ns,o){$(o.context).off(o.ns)});namespaces={};menus={};counter=0;initialized=false;$("#context-menu-layer, .context-menu-list").remove()}else{if(namespaces[o.selector]){$visibleMenu=$(".context-menu-list").filter(":visible");if($visibleMenu.length&&$visibleMenu.data().contextMenuRoot.$trigger.is(o.selector)){$visibleMenu.trigger("contextmenu:hide",{force:true})}try{if(menus[namespaces[o.selector]].$menu){menus[namespaces[o.selector]].$menu.remove()}delete menus[namespaces[o.selector]]}catch(e){menus[namespaces[o.selector]]=null}$document.off(namespaces[o.selector])}}}break;case"html5":if((!$.support.htmlCommand&&!$.support.htmlMenuitem)||(typeof options=="boolean"&&options)){$('menu[type="context"]').each(function(){if(this.id){$.contextMenu({selector:"[contextmenu="+this.id+"]",items:$.contextMenu.fromMenu(this)})}}).css("display","none")}break;default:throw new Error('Unknown operation "'+operation+'"')}return this};$.contextMenu.setInputValues=function(opt,data){if(data===undefined){data={}}$.each(opt.inputs,function(key,item){switch(item.type){case"text":case"textarea":item.value=data[key]||"";break;case"checkbox":item.selected=data[key]?true:false;break;case"radio":item.selected=(data[item.radio]||"")==item.value?true:false;break;case"select":item.selected=data[key]||"";break}})};$.contextMenu.getInputValues=function(opt,data){if(data===undefined){data={}}$.each(opt.inputs,function(key,item){switch(item.type){case"text":case"textarea":case"select":data[key]=item.$input.val();break;case"checkbox":data[key]=item.$input.prop("checked");break;case"radio":if(item.$input.prop("checked")){data[item.radio]=item.value}break}});return data};function inputLabel(node){return(node.id&&$('label[for="'+node.id+'"]').val())||node.name}function menuChildren(items,$children,counter){if(!counter){counter=0}$children.each(function(){var $node=$(this),node=this,nodeName=this.nodeName.toLowerCase(),label,item;if(nodeName=="label"&&$node.find("input, textarea, select").length){label=$node.text();$node=$node.children().first();node=$node.get(0);nodeName=node.nodeName.toLowerCase()}switch(nodeName){case"menu":item={name:$node.attr("label"),items:{}};counter=menuChildren(item.items,$node.children(),counter);break;case"a":case"button":item={name:$node.text(),disabled:!!$node.attr("disabled"),callback:(function(){return function(){$node.click()}})()};break;case"menuitem":case"command":switch($node.attr("type")){case undefined:case"command":case"menuitem":item={name:$node.attr("label"),disabled:!!$node.attr("disabled"),callback:(function(){return function(){$node.click()}})()};break;case"checkbox":item={type:"checkbox",disabled:!!$node.attr("disabled"),name:$node.attr("label"),selected:!!$node.attr("checked")};break;case"radio":item={type:"radio",disabled:!!$node.attr("disabled"),name:$node.attr("label"),radio:$node.attr("radiogroup"),value:$node.attr("id"),selected:!!$node.attr("checked")};break;default:item=undefined}break;case"hr":item="-------";break;case"input":switch($node.attr("type")){case"text":item={type:"text",name:label||inputLabel(node),disabled:!!$node.attr("disabled"),value:$node.val()};break;case"checkbox":item={type:"checkbox",name:label||inputLabel(node),disabled:!!$node.attr("disabled"),selected:!!$node.attr("checked")};break;case"radio":item={type:"radio",name:label||inputLabel(node),disabled:!!$node.attr("disabled"),radio:!!$node.attr("name"),value:$node.val(),selected:!!$node.attr("checked")};break;default:item=undefined;break}break;case"select":item={type:"select",name:label||inputLabel(node),disabled:!!$node.attr("disabled"),selected:$node.val(),options:{}};$node.children().each(function(){item.options[this.value]=$(this).text()});break;case"textarea":item={type:"textarea",name:label||inputLabel(node),disabled:!!$node.attr("disabled"),value:$node.val()};break;case"label":break;default:item={type:"html",html:$node.clone(true)};break}if(item){counter++;items["key"+counter]=item}});return counter}$.contextMenu.fromMenu=function(element){var $this=$(element),items={};menuChildren(items,$this.children());return items};$.contextMenu.defaults=defaults;$.contextMenu.types=types;$.contextMenu.handle=handle;$.contextMenu.op=op;$.contextMenu.menus=menus})(jQuery); \ No newline at end of file
+!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,s){return s||(s=0),o.each(function(){var o,i,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":i={name:c.attr("label"),items:{}},s=a(i.items,c.children(),s);break;case"a":case"button":i={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":i={name:c.attr("label"),disabled:!!c.attr("disabled"),icon:c.attr("icon"),callback:function(){return function(){c.click()}}()};break;case"checkbox":i={type:"checkbox",disabled:!!c.attr("disabled"),name:c.attr("label"),selected:!!c.attr("checked")};break;case"radio":i={type:"radio",disabled:!!c.attr("disabled"),name:c.attr("label"),radio:c.attr("radiogroup"),value:c.attr("id"),selected:!!c.attr("checked")};break;default:i=void 0}break;case"hr":i="-------";break;case"input":switch(c.attr("type")){case"text":i={type:"text",name:o||n(r),disabled:!!c.attr("disabled"),value:c.val()};break;case"checkbox":i={type:"checkbox",name:o||n(r),disabled:!!c.attr("disabled"),selected:!!c.attr("checked")};break;case"radio":i={type:"radio",name:o||n(r),disabled:!!c.attr("disabled"),radio:!!c.attr("name"),value:c.val(),selected:!!c.attr("checked")};break;default:i=void 0}break;case"select":i={type:"select",name:o||n(r),disabled:!!c.attr("disabled"),selected:c.val(),options:{}},c.children().each(function(){i.options[this.value]=e(this).text()});break;case"textarea":i={type:"textarea",name:o||n(r),disabled:!!c.attr("disabled"),value:c.val()};break;case"label":break;default:i={type:"html",html:c.clone(!0)}}i&&(s++,t["key"+s]=i)}),s}e.support.htmlMenuitem="HTMLMenuItemElement"in window,e.support.htmlCommand="HTMLCommandElement"in window,e.support.eventSelectstart="onselectstart"in document.documentElement,e.ui&&e.widget||(e.cleanData=function(t){return function(n){var a,o,s;for(s=0;null!=n[s];s++){o=n[s];try{a=e._data(o,"events"),a&&a.remove&&e(o).triggerHandler("remove")}catch(i){}}t(n)}}(e.cleanData));var o=null,s=!1,i=e(window),c=0,r={},l={},u={},d={selector:null,appendTo:null,trigger:"right",autoHide:!1,delay:200,reposition:!0,classNames:{hover:"context-menu-hover",disabled:"context-menu-disabled",visible:"context-menu-visible",notSelectable:"context-menu-not-selectable",icon:"context-menu-icon",iconEdit:"context-menu-icon-edit",iconCut:"context-menu-icon-cut",iconCopy:"context-menu-icon-copy",iconPaste:"context-menu-icon-paste",iconDelete:"context-menu-icon-delete",iconAdd:"context-menu-icon-add",iconQuit:"context-menu-icon-quit"},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=i.scrollTop()+i.height(),s=i.scrollLeft()+i.width(),c=e.$menu.outerHeight(),r=e.$menu.outerWidth();a.top+c>o&&(a.top-=c),a.top<0&&(a.top=0),a.left+r>s&&(a.left-=r),a.left<0&&(a.left=0),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:{}},m={timer:null,pageX:null,pageY:null},p=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},f={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||!(void 0===t.mouseButton||!t.data||"left"===t.data.trigger&&0===t.mouseButton||"right"===t.data.trigger&&2===t.mouseButton)||n.hasClass("context-menu-active")||n.hasClass("context-menu-disabled"))){if(o=n,t.data.build){var a=t.data.build(o,t);if(a===!1)return;if(t.data=e.extend(!0,{},d,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=o,h.create(t.data)}var s=!1;for(var i in t.data.items)if(t.data.items.hasOwnProperty(i)){var c;c=e.isFunction(t.data.items[i].visible)?t.data.items[i].visible.call(e(t.currentTarget),i,t.data):"undefined"==typeof i.visible||t.data.items[i].visible===!0,c&&(s=!0)}s&&h.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);o&&o.length&&!o.is(n)&&o.data("contextMenu").$menu.trigger("contextmenu:hide"),2===t.button&&(o=n.data("contextMenuActive",!0))},mouseup:function(t){var n=e(this);n.data("contextMenuActive")&&o&&o.length&&o.is(n)&&!n.hasClass("context-menu-disabled")&&(t.preventDefault(),t.stopImmediatePropagation(),o=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),s=e(document);a.is(".context-menu-list")||a.closest(".context-menu-list").length||o&&o.length||(m.pageX=t.pageX,m.pageY=t.pageY,m.data=t.data,s.on("mousemove.contextMenuShow",f.mousemove),m.timer=setTimeout(function(){m.timer=null,s.off("mousemove.contextMenuShow"),o=n,n.trigger(e.Event("contextmenu",{data:m.data,pageX:m.pageX,pageY:m.pageY}))},t.data.delay))},mousemove:function(e){m.pageX=e.pageX,m.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(m.timer)}catch(t){}m.timer=null}},layerClick:function(t){var n,a,o=e(this),s=o.data("contextMenuRoot"),c=t.button,r=t.pageX,l=t.pageY;t.preventDefault(),t.stopImmediatePropagation(),setTimeout(function(){var o,u="left"===s.trigger&&0===c||"right"===s.trigger&&2===c;if(document.elementFromPoint&&s.$layer&&(s.$layer.hide(),n=document.elementFromPoint(r-i.scrollLeft(),l-i.scrollTop()),s.$layer.show()),s.reposition&&u)if(document.elementFromPoint){if(s.$trigger.is(n)||s.$trigger.has(n).length)return void s.position.call(s.$trigger,s,r,l)}else if(a=s.$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+s.$trigger.outerHeight(),a.bottom>=t.pageY&&(a.right=a.left+s.$trigger.outerWidth(),a.right>=t.pageX))))return void s.position.call(s.$trigger,s,r,l);n&&u&&s.$trigger.one("contextmenu:hidden",function(){e(n).contextMenu({x:r,y:l,button:c})}),null!=s&&null!=s.$menu&&s.$menu.trigger("contextmenu:hide")},50)},keyStop:function(e,t){t.isInput||e.preventDefault(),e.stopPropagation()},key:function(e){var t={};o&&(t=o.data("contextMenu")||{}),void 0===t.zIndex&&(t.zIndex=0);var n=0,a=function(e){""!==e.style.zIndex?n=e.style.zIndex:null!==e.offsetParent&&void 0!==e.offsetParent?a(e.offsetParent):null!==e.parentElement&&void 0!==e.parentElement&&a(e.parentElement)};if(a(e.target),!(n>t.zIndex)){switch(e.keyCode){case 9:case 38:if(f.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");break;case 40:if(f.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(f.keyStop(e,t),t.isInput||!t.$selected||!t.$selected.length)break;if(!t.$selected.parent().hasClass("context-menu-root")){var s=t.$selected.parent().parent();return t.$selected.trigger("contextmenu:blur"),void(t.$selected=s)}break;case 39:if(f.keyStop(e,t),t.isInput||!t.$selected||!t.$selected.length)break;var i=t.$selected.data("contextMenu")||{};if(i.$menu&&t.$selected.hasClass("context-menu-submenu"))return t.$selected=null,i.$selected=null,void i.$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(."+t.classNames.disabled+", ."+t.classNames.notSelectable+")")[36===e.keyCode?"first":"last"]().trigger("contextmenu:focus"),void e.preventDefault());case 13:if(f.keyStop(e,t),t.isInput){if(t.$selected&&!t.$selected.is("textarea, select"))return void e.preventDefault();break}return void("undefined"!=typeof t.$selected&&null!==t.$selected&&t.$selected.trigger("mouseup"));case 32:case 33:case 34:return void f.keyStop(e,t);case 27:return f.keyStop(e,t),void t.$menu.trigger("contextmenu:hide");default:var c=String.fromCharCode(e.keyCode).toUpperCase();if(t.accesskeys&&t.accesskeys[c])return void t.accesskeys[c].$node.trigger(t.accesskeys[c].$menu?"contextmenu:focus":"mouseup")}e.stopPropagation(),"undefined"!=typeof t.$selected&&null!==t.$selected&&t.$selected.trigger(e)}},prevItem:function(t){t.stopPropagation();var n=e(this).data("contextMenu")||{},a=e(this).data("contextMenuRoot")||{};if(n.$selected){var o=n.$selected;n=n.$selected.parent().data("contextMenu")||{},n.$selected=o}for(var s=n.$menu.children(),i=n.$selected&&n.$selected.prev().length?n.$selected.prev():s.last(),c=i;i.hasClass(a.classNames.disabled)||i.hasClass(a.classNames.notSelectable)||i.is(":hidden");)if(i=i.prev().length?i.prev():s.last(),i.is(c))return;n.$selected&&f.itemMouseleave.call(n.$selected.get(0),t),f.itemMouseenter.call(i.get(0),t);var r=i.find("input, textarea, select");r.length&&r.focus()},nextItem:function(t){t.stopPropagation();var n=e(this).data("contextMenu")||{},a=e(this).data("contextMenuRoot")||{};if(n.$selected){var o=n.$selected;n=n.$selected.parent().data("contextMenu")||{},n.$selected=o}for(var s=n.$menu.children(),i=n.$selected&&n.$selected.next().length?n.$selected.next():s.first(),c=i;i.hasClass(a.classNames.disabled)||i.hasClass(a.classNames.notSelectable)||i.is(":hidden");)if(i=i.next().length?i.next():s.first(),i.is(c))return;n.$selected&&f.itemMouseleave.call(n.$selected.get(0),t),f.itemMouseenter.call(i.get(0),t);var r=i.find("input, textarea, select");r.length&&r.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,s=a.contextMenuRoot;return s.hovering=!0,t&&s.$layer&&s.$layer.is(t.relatedTarget)&&(t.preventDefault(),t.stopImmediatePropagation()),(o.$menu?o:s).$menu.children("."+s.classNames.hover).trigger("contextmenu:blur").children(".hover").trigger("contextmenu:blur"),n.hasClass(s.classNames.disabled)||n.hasClass(s.classNames.notSelectable)?void(o.$selected=null):void n.trigger("contextmenu:focus")},itemMouseleave:function(t){var n=e(this),a=n.data(),o=a.contextMenu,s=a.contextMenuRoot;return s!==o&&s.$layer&&s.$layer.is(t.relatedTarget)?("undefined"!=typeof s.$selected&&null!==s.$selected&&s.$selected.trigger("contextmenu:blur"),t.preventDefault(),t.stopImmediatePropagation(),void(s.$selected=o.$selected=o.$node)):void n.trigger("contextmenu:blur")},itemClick:function(t){var n,a=e(this),o=a.data(),s=o.contextMenu,i=o.contextMenuRoot,c=o.contextMenuKey;if(s.items[c]&&!a.is("."+i.classNames.disabled+", .context-menu-submenu, .context-menu-separator, ."+i.classNames.notSelectable)){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(i.callback))return;n=i.callback}n.call(i.$trigger,c,i)!==!1?i.$menu.trigger("contextmenu:hide"):i.$menu.parent().length&&h.update.call(i.$trigger,i)}},inputClick:function(e){e.stopImmediatePropagation()},hideMenu:function(t,n){var a=e(this).data("contextMenuRoot");h.hide.call(a.$trigger,a,n&&n.force)},focusItem:function(t){t.stopPropagation();var n=e(this),a=n.data(),o=a.contextMenu,s=a.contextMenuRoot;n.hasClass(s.classNames.disabled)||n.hasClass(s.classNames.notSelectable)||(n.addClass([s.classNames.hover,s.classNames.visible].join(" ")).parent().find(".context-menu-item").not(n).removeClass(s.classNames.visible).filter("."+s.classNames.hover).trigger("contextmenu:blur"),o.$selected=s.$selected=n,o.$node&&s.positionSubmenu.call(o.$node,o.$menu))},blurItem:function(t){t.stopPropagation();var n=e(this),a=n.data(),o=a.contextMenu,s=a.contextMenuRoot;o.autoHide&&n.removeClass(s.classNames.visible),n.removeClass(s.classNames.hover),o.$selected=null}},h={show:function(t,n,a){var s=e(this),i={};if(e("#context-menu-layer").trigger("mousedown"),t.$trigger=s,t.events.show.call(s,t)===!1)return void(o=null);if(h.update.call(s,t),t.position.call(s,t,n,a),t.zIndex){var c=t.zIndex;"function"==typeof t.zIndex&&(c=t.zIndex.call(s,t)),i.zIndex=p(s)+c}h.layer.call(t.$menu,t,i.zIndex),t.$menu.find("ul").css("zIndex",i.zIndex+1),t.$menu.css(i)[t.animation.show](t.animation.duration,function(){s.trigger("contextmenu:visible")}),s.data("contextMenu",t).addClass("context-menu-active"),e(document).off("keydown.contextMenu").on("keydown.contextMenu",f.key),t.autoHide&&e(document).on("mousemove.contextMenuAutoHide",function(e){var n=s.offset();n.right=n.left+s.outerWidth(),n.bottom=n.top+s.outerHeight(),!t.$layer||t.hovering||e.pageX>=n.left&&e.pageX<=n.right&&e.pageY>=n.top&&e.pageY<=n.bottom||setTimeout(function(){t.hovering||null==t.$menu||t.$menu.trigger("contextmenu:hide")},50)})},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(s){t.$layer=null}}o=null,t.$menu.find("."+t.classNames.hover).trigger("contextmenu:blur"),t.$selected=null,t.$menu.find("."+t.classNames.visible).removeClass(t.classNames.visible),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){function o(t){var n=e("<span></span>");if(t._accesskey)t._beforeAccesskey&&n.append(document.createTextNode(t._beforeAccesskey)),e("<span></span>").addClass("context-menu-accesskey").text(t._accesskey).appendTo(n),t._afterAccesskey&&n.append(document.createTextNode(t._afterAccesskey));else if(t.isHtmlName){if("undefined"!=typeof t.accesskey)throw new Error("accesskeys are not compatible with HTML names and cannot be used together in the same item");n.html(t.name)}else n.text(t.name);return n}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(s,i){var c=e('<li class="context-menu-item"></li>').addClass(i.className||""),r=null,l=null;if(c.on("click",e.noop),"string"!=typeof i&&"cm_separator"!==i.type||(i={type:"cm_seperator"}),i.$node=c.data({contextMenu:n,contextMenuRoot:a,contextMenuKey:s}),"undefined"!=typeof i.accesskey)for(var d,m=t(i.accesskey),p=0;d=m[p];p++)if(!a.accesskeys[d]){a.accesskeys[d]=i;var x=i.name.match(new RegExp("^(.*?)("+d+")(.*)$","i"));x&&(i._beforeAccesskey=x[1],i._accesskey=x[2],i._afterAccesskey=x[3]);break}if(i.type&&u[i.type])u[i.type].call(c,i,n,a),e.each([n,a],function(t,a){a.commands[s]=i,!e.isFunction(i.callback)||void 0!==a.callbacks[s]&&void 0!==n.type||(a.callbacks[s]=i.callback)});else{switch("cm_seperator"===i.type?c.addClass("context-menu-separator "+a.classNames.notSelectable):"html"===i.type?c.addClass("context-menu-html "+a.classNames.notSelectable):i.type?(r=e("<label></label>").appendTo(c),o(i).appendTo(r),c.addClass("context-menu-input"),n.hasTypes=!0,e.each([n,a],function(e,t){t.commands[s]=i,t.inputs[s]=i})):i.items&&(i.type="sub"),i.type){case"cm_seperator":break;case"text":l=e('<input type="text" value="1" name="" value="">').attr("name","context-menu-input-"+s).val(i.value||"").appendTo(r);break;case"textarea":l=e('<textarea name=""></textarea>').attr("name","context-menu-input-"+s).val(i.value||"").appendTo(r),i.height&&l.height(i.height);break;case"checkbox":l=e('<input type="checkbox" value="1" name="" value="">').attr("name","context-menu-input-"+s).val(i.value||"").prop("checked",!!i.selected).prependTo(r);break;case"radio":l=e('<input type="radio" value="1" name="" value="">').attr("name","context-menu-input-"+i.radio).val(i.value||"").prop("checked",!!i.selected).prependTo(r);break;case"select":l=e('<select name="">').attr("name","context-menu-input-"+s).appendTo(r),i.options&&(e.each(i.options,function(t,n){e("<option></option>").val(t).text(n).appendTo(l)}),l.val(i.selected));break;case"sub":o(i).appendTo(c),i.appendTo=i.$node,h.create(i,a),c.data("contextMenu",i).addClass("context-menu-submenu"),i.callback=null;break;case"html":e(i.html).appendTo(c);break;default:e.each([n,a],function(t,a){a.commands[s]=i,!e.isFunction(i.callback)||void 0!==a.callbacks[s]&&void 0!==n.type||(a.callbacks[s]=i.callback)}),o(i).appendTo(c)}i.type&&"sub"!==i.type&&"html"!==i.type&&"cm_seperator"!==i.type&&(l.on("focus",f.focusInput).on("blur",f.blurInput),i.events&&l.on(i.events,n)),i.icon&&(e.isFunction(i.icon)?i._icon=i.icon.call(this,this,c,s,i):"string"==typeof i.icon&&"fa-"==i.icon.substring(0,3)?i._icon=a.classNames.icon+" "+a.classNames.icon+"--fa fa "+i.icon:i._icon=a.classNames.icon+" "+a.classNames.icon+"-"+i.icon,c.addClass(i._icon))}i.$input=l,i.$label=r,c.appendTo(n.$menu),!n.hasTypes&&e.support.eventSelectstart&&c.on("selectstart.disableTextSelect",f.abortevent)}),n.$node||n.$menu.css("display","none").addClass("context-menu-root"),n.$menu.appendTo(n.appendTo||document.body)},resize:function(t,n){var a;t.css({position:"absolute",display:"block"}),t.data("width",(a=t.get(0)).getBoundingClientRect?Math.ceil(a.getBoundingClientRect().width):t.outerWidth()+1),t.css({position:"static",minWidth:"0px",maxWidth:"100000px"}),t.find("> li > ul").each(function(){h.resize(e(this),!0)}),n||t.find("ul").addBack().css({position:"",display:"",minWidth:"",maxWidth:""}).outerWidth(function(){return e(this).data("width")})},update:function(t,n){var a=this;void 0===n&&(n=t,h.resize(t.$menu)),t.$menu.children().each(function(){var o,s=e(this),i=s.data("contextMenuKey"),c=t.items[i],r=e.isFunction(c.disabled)&&c.disabled.call(a,i,n)||c.disabled===!0;if(o=e.isFunction(c.visible)?c.visible.call(a,i,n):"undefined"==typeof c.visible||c.visible===!0,s[o?"show":"hide"](),s[r?"addClass":"removeClass"](n.classNames.disabled),e.isFunction(c.icon)&&(s.removeClass(c._icon),c._icon=c.icon.call(this,a,s,i,c),s.addClass(c._icon)),c.type)switch(s.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&&h.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:i.height(),width:i.width(),display:"block"}).data("contextMenuRoot",t).insertBefore(this).on("contextmenu",f.abortevent).on("mousedown",f.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(void 0!==t.x&&void 0!==t.y)this.first().trigger(e.Event("contextmenu",{pageX:t.x,pageY:t.y,mouseButton:t.button}));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(l,function(){this.selector===n.selector&&(a.data=this,e.extend(a.data,{trigger:"demand"}))}),f.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,{},d,n||{}),o=e(document),i=o,u=!1;switch(a.context&&a.context.length?(i=e(a.context).first(),a.context=i.get(0),u=!e(a.context).is(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");if(c++,a.ns=".contextMenu"+c,u||(r[a.selector]=a.ns),l[a.ns]=a,a.trigger||(a.trigger="right"),!s){var m="click"===a.itemClickEvent?"click.contextMenu":"mouseup.contextMenu",p={"contextmenu:focus.contextMenu":f.focusItem,"contextmenu:blur.contextMenu":f.blurItem,"contextmenu.contextMenu":f.abortevent,"mouseenter.contextMenu":f.itemMouseenter,"mouseleave.contextMenu":f.itemMouseleave};p[m]=f.itemClick,o.on({"contextmenu:hide.contextMenu":f.hideMenu,"prevcommand.contextMenu":f.prevItem,"nextcommand.contextMenu":f.nextItem,"contextmenu.contextMenu":f.abortevent,"mouseenter.contextMenu":f.menuMouseenter,"mouseleave.contextMenu":f.menuMouseleave},".context-menu-list").on("mouseup.contextMenu",".context-menu-input",f.inputClick).on(p,".context-menu-item"),s=!0}switch(i.on("contextmenu"+a.ns,a.selector,a,f.contextmenu),u&&i.on("remove"+a.ns,function(){e(this).contextMenu("destroy")}),a.trigger){case"hover":i.on("mouseenter"+a.ns,a.selector,a,f.mouseenter).on("mouseleave"+a.ns,a.selector,a,f.mouseleave);break;case"left":i.on("click"+a.ns,a.selector,a,f.click)}a.build||h.create(a);break;case"destroy":var x;if(u){var v=a.context;e.each(l,function(t,n){if(!e(v).is(n.selector))return!0;x=e(".context-menu-list").filter(":visible"),x.length&&x.data().contextMenuRoot.$trigger.is(e(n.context).find(n.selector))&&x.trigger("contextmenu:hide",{force:!0});try{l[n.ns].$menu&&l[n.ns].$menu.remove(),delete l[n.ns]}catch(a){l[n.ns]=null}return e(n.context).off(n.ns),!0})}else if(a.selector){if(r[a.selector]){x=e(".context-menu-list").filter(":visible"),x.length&&x.data().contextMenuRoot.$trigger.is(a.selector)&&x.trigger("contextmenu:hide",{force:!0});try{l[r[a.selector]].$menu&&l[r[a.selector]].$menu.remove(),delete l[r[a.selector]]}catch(g){l[r[a.selector]]=null}o.off(r[a.selector])}}else o.off(".contextMenu .contextMenuAutoHide"),e.each(l,function(t,n){e(n.context).off(n.ns)}),r={},l={},c=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];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=d,e.contextMenu.types=u,e.contextMenu.handle=f,e.contextMenu.op=h,e.contextMenu.menus=l});