diff --git a/dist/jquery.contextMenu.js b/dist/jquery.contextMenu.js index 87d7f2e5..7ad2caa3 100755 --- a/dist/jquery.contextMenu.js +++ b/dist/jquery.contextMenu.js @@ -6,12 +6,12 @@ * Authors: Björn Brala (SWIS.nl), Rodney Rehm, Addy Osmani (patches for FF) * Web: http://swisnl.github.io/jQuery-contextMenu/ * - * Copyright (c) 2011-2017 SWIS BV and contributors + * Copyright (c) 2011-2018 SWIS BV and contributors * * Licensed under * MIT License http://www.opensource.org/licenses/mit-license * - * Date: 2017-12-15T13:56:37.241Z + * Date: 2018-01-12T06:55:23.374Z */ // jscs:disable @@ -116,7 +116,7 @@ // flag denoting if a second trigger should simply move (true) or rebuild (false) an open menu // as long as the trigger happened on one of the trigger-element's child nodes reposition: true, - // Flag denoting if a second trigger should close the menu, as long as + // Flag denoting if a second trigger should close the menu, as long as // the trigger happened on one of the trigger-element's child nodes. // This overrides the reposition option. hideOnSecondTrigger: false, @@ -476,12 +476,12 @@ $(target).trigger(e); root.$layer.show(); } - + if (root.hideOnSecondTrigger && triggerAction && root.$menu !== null && typeof root.$menu !== 'undefined') { root.$menu.trigger('contextmenu:hide'); return; } - + if (root.reposition && triggerAction) { if (document.elementFromPoint) { if (root.$trigger.is(target)) { @@ -1007,7 +1007,7 @@ // position and show context menu opt.$menu.css(css)[opt.animation.show](opt.animation.duration, function () { $trigger.trigger('contextmenu:visible'); - + op.activated(opt); opt.events.activated(opt); }); @@ -1121,6 +1121,9 @@ 'contextMenu': opt, 'contextMenuRoot': root }); + if(opt.dataAttr){ + opt.$menu.attr(opt.dataAttr); + } $.each(['callbacks', 'commands', 'inputs'], function (i, k) { opt[k] = {}; @@ -1559,7 +1562,7 @@ $menu.css({ 'top': '0px' }); - } + } } }; diff --git a/dist/jquery.contextMenu.min.js b/dist/jquery.contextMenu.min.js index d29265dd..66f04eda 100755 --- a/dist/jquery.contextMenu.min.js +++ b/dist/jquery.contextMenu.min.js @@ -1,2 +1,2 @@ -!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):jQuery)}(function(e){"use strict";function t(t){return t.id&&e('label[for="'+t.id+'"]').val()||t.name}function n(a,o,s){return s||(s=0),o.each(function(){var o,i,c=e(this),l=this,r=this.nodeName.toLowerCase();switch("label"===r&&c.find("input, textarea, select").length&&(o=c.text(),r=(l=(c=c.children().first()).get(0)).nodeName.toLowerCase()),r){case"menu":i={name:c.attr("label"),items:{}},s=n(i.items,c.children(),s);break;case"a":case"button":i={name:c.text(),disabled:!!c.attr("disabled"),callback:function(){c.get(0).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(){c.get(0).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||t(l),disabled:!!c.attr("disabled"),value:c.val()};break;case"checkbox":i={type:"checkbox",name:o||t(l),disabled:!!c.attr("disabled"),selected:!!c.attr("checked")};break;case"radio":i={type:"radio",name:o||t(l),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||t(l),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||t(l),disabled:!!c.attr("disabled"),value:c.val()};break;case"label":break;default:i={type:"html",html:c.clone(!0)}}i&&(a["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.remove&&e(o).triggerHandler("remove")}catch(e){}}t(n)}}(e.cleanData));var a=null,o=!1,s=e(window),i=0,c={},l={},r={},u={selector:null,appendTo:null,trigger:"right",autoHide:!1,delay:200,reposition:!0,hideOnSecondTrigger:!1,selectableSubMenu:!1,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",iconLoadingClass:"context-menu-icon-loading"},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){if("maintain"===t&&"maintain"===n)a=e.$menu.position();else{var o=e.$menu.offsetParent().offset();a={top:n-o.top,left:t-o.left}}var i=s.scrollTop()+s.height(),c=s.scrollLeft()+s.width(),l=e.$menu.outerHeight(),r=e.$menu.outerWidth();a.top+l>i&&(a.top-=l),a.top<0&&(a.top=0),a.left+r>c&&(a.left-=r),a.left<0&&(a.left=0),e.$menu.css(a)}else e.determinePosition.call(this,e.$menu)},positionSubmenu:function(t){if(void 0!==t)if(e.ui&&e.ui.position)t.css("display","block").position({my:"left top-5",at:"right top",of:this,collision:"flipfit fit"}).css("display","");else{var n={top:-9,left:this.outerWidth()-5};t.css(n)}},zIndex:1,animation:{duration:50,show:"slideDown",hide:"slideUp"},events:{show:e.noop,hide:e.noop,activated:e.noop},callback:null,items:{}},d={timer:null,pageX:null,pageY:null},m={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(a=n,t.data.build){var o=t.data.build(a,t);if(!1===o)return;if(t.data=e.extend(!0,{},u,t.data,o||{}),!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=a,p.create(t.data)}var s=!1;for(var i in t.data.items)if(t.data.items.hasOwnProperty(i)){(e.isFunction(t.data.items[i].visible)?t.data.items[i].visible.call(e(t.currentTarget),i,t.data):void 0===t.data.items[i]||!t.data.items[i].visible||!0===t.data.items[i].visible)&&(s=!0)}s&&p.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);a&&a.length&&!a.is(n)&&a.data("contextMenu").$menu.trigger("contextmenu:hide"),2===t.button&&(a=n.data("contextMenuActive",!0))},mouseup:function(t){var n=e(this);n.data("contextMenuActive")&&a&&a.length&&a.is(n)&&!n.hasClass("context-menu-disabled")&&(t.preventDefault(),t.stopImmediatePropagation(),a=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),o=e(t.relatedTarget),s=e(document);o.is(".context-menu-list")||o.closest(".context-menu-list").length||a&&a.length||(d.pageX=t.pageX,d.pageY=t.pageY,d.data=t.data,s.on("mousemove.contextMenuShow",m.mousemove),d.timer=setTimeout(function(){d.timer=null,s.off("mousemove.contextMenuShow"),a=n,n.trigger(e.Event("contextmenu",{data:d.data,pageX:d.pageX,pageY:d.pageY}))},t.data.delay))},mousemove:function(e){d.pageX=e.pageX,d.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(d.timer)}catch(t){}d.timer=null}},layerClick:function(t){var n,a,o=e(this).data("contextMenuRoot"),i=t.button,c=t.pageX,l=t.pageY;t.preventDefault(),setTimeout(function(){var r,u="left"===o.trigger&&0===i||"right"===o.trigger&&2===i;if(document.elementFromPoint&&o.$layer){if(o.$layer.hide(),(n=document.elementFromPoint(c-s.scrollLeft(),l-s.scrollTop())).isContentEditable){var d=document.createRange(),m=window.getSelection();d.selectNode(n),d.collapse(!0),m.removeAllRanges(),m.addRange(d)}e(n).trigger(t),o.$layer.show()}if(o.hideOnSecondTrigger&&u&&null!==o.$menu&&void 0!==o.$menu)o.$menu.trigger("contextmenu:hide");else{if(o.reposition&&u)if(document.elementFromPoint){if(o.$trigger.is(n))return void o.position.call(o.$trigger,o,c,l)}else if(a=o.$trigger.offset(),r=e(window),a.top+=r.scrollTop(),a.top<=t.pageY&&(a.left+=r.scrollLeft(),a.left<=t.pageX&&(a.bottom=a.top+o.$trigger.outerHeight(),a.bottom>=t.pageY&&(a.right=a.left+o.$trigger.outerWidth(),a.right>=t.pageX))))return void o.position.call(o.$trigger,o,c,l);n&&u&&o.$trigger.one("contextmenu:hidden",function(){e(n).contextMenu({x:c,y:l,button:i})}),null!==o&&void 0!==o&&null!==o.$menu&&void 0!==o.$menu&&o.$menu.trigger("contextmenu:hide")}},50)},keyStop:function(e,t){t.isInput||e.preventDefault(),e.stopPropagation()},key:function(e){var t={};a&&(t=a.data("contextMenu")||{}),void 0===t.zIndex&&(t.zIndex=0);var n=0,o=function(e){""!==e.style.zIndex?n=e.style.zIndex:null!==e.offsetParent&&void 0!==e.offsetParent?o(e.offsetParent):null!==e.parentElement&&void 0!==e.parentElement&&o(e.parentElement)};if(o(e.target),!(t.$menu&&parseInt(n,10)>parseInt(t.$menu.css("zIndex"),10))){switch(e.keyCode){case 9:case 38:if(m.keyStop(e,t),t.isInput){if(9===e.keyCode&&e.shiftKey)return e.preventDefault(),t.$selected&&t.$selected.find("input, textarea, select").blur(),void(null!==t.$menu&&void 0!==t.$menu&&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(null!==t.$menu&&void 0!==t.$menu&&t.$menu.trigger("prevcommand"));break;case 40:if(m.keyStop(e,t),!t.isInput)return void(null!==t.$menu&&void 0!==t.$menu&&t.$menu.trigger("nextcommand"));if(9===e.keyCode)return e.preventDefault(),t.$selected&&t.$selected.find("input, textarea, select").blur(),void(null!==t.$menu&&void 0!==t.$menu&&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(m.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(m.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(m.keyStop(e,t),t.isInput){if(t.$selected&&!t.$selected.is("textarea, select"))return void e.preventDefault();break}return void(void 0!==t.$selected&&null!==t.$selected&&t.$selected.trigger("mouseup"));case 32:case 33:case 34:return void m.keyStop(e,t);case 27:return m.keyStop(e,t),void(null!==t.$menu&&void 0!==t.$menu&&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(),void 0!==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")||{}).$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()).is(c))return;n.$selected&&m.itemMouseleave.call(n.$selected.get(0),t),m.itemMouseenter.call(i.get(0),t);var l=i.find("input, textarea, select");l.length&&l.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")||{}).$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()).is(c))return;n.$selected&&m.itemMouseleave.call(n.$selected.get(0),t),m.itemMouseenter.call(i.get(0),t);var l=i.find("input, textarea, select");l.length&&l.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").data(),n=t.contextMenu;t.contextMenuRoot.isInput=n.isInput=!1},menuMouseenter:function(){e(this).data().contextMenuRoot.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;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)?o.$selected=null:n.trigger("contextmenu:focus")},itemMouseleave:function(t){var n=e(this),a=n.data(),o=a.contextMenu,s=a.contextMenuRoot;if(s!==o&&s.$layer&&s.$layer.is(t.relatedTarget))return void 0!==s.$selected&&null!==s.$selected&&s.$selected.trigger("contextmenu:blur"),t.preventDefault(),t.stopImmediatePropagation(),void(s.$selected=o.$selected=o.$node);o&&o.$menu&&o.$menu.hasClass("context-menu-visible")||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-separator, ."+i.classNames.notSelectable)||a.is(".context-menu-submenu")&&!1===i.selectableSubMenu)){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}!1!==n.call(i.$trigger,c,i,t)?i.$menu.trigger("contextmenu:hide"):i.$menu.parent().length&&p.update.call(i.$trigger,i)}},inputClick:function(e){e.stopImmediatePropagation()},hideMenu:function(t,n){var a=e(this).data("contextMenuRoot");p.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&&o.$node&&o.$node.hasClass("context-menu-submenu")&&o.$node.addClass(s.classNames.hover),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}},p={show:function(t,n,o){var s=e(this),i={};if(e("#context-menu-layer").trigger("mousedown"),t.$trigger=s,!1!==t.events.show.call(s,t)){if(p.update.call(s,t),t.position.call(s,t,n,o),t.zIndex){var c=t.zIndex;"function"==typeof t.zIndex&&(c=t.zIndex.call(s,t)),i.zIndex=function(e){for(var t=0,n=e;t=Math.max(t,parseInt(n.css("z-index"),10)||0),(n=n.parent())&&n.length&&!("html body".indexOf(n.prop("nodeName").toLowerCase())>-1););return t}(s)+c}p.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"),p.activated(t),t.events.activated(t)}),s.data("contextMenu",t).addClass("context-menu-active"),e(document).off("keydown.contextMenu").on("keydown.contextMenu",m.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||void 0===t.$menu||t.$menu.trigger("contextmenu:hide")},50)})}else a=null},hide:function(t,n){var o=e(this);if(t||(t=o.data("contextMenu")||{}),n||!t.events||!1!==t.events.hide.call(o,t)){if(o.removeData("contextMenu").removeClass("context-menu-active"),t.$layer){setTimeout(function(e){return function(){e.remove()}}(t.$layer),10);try{delete t.$layer}catch(e){t.$layer=null}}a=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(e){}return!0}})),setTimeout(function(){o.trigger("contextmenu:hidden")},10)})}},create:function(t,n){function a(t){var n=e("");if(t._accesskey)t._beforeAccesskey&&n.append(document.createTextNode(t._beforeAccesskey)),e("").addClass("context-menu-accesskey").text(t._accesskey).appendTo(n),t._afterAccesskey&&n.append(document.createTextNode(t._afterAccesskey));else if(t.isHtmlName){if(void 0!==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===n&&(n=t),t.$menu=e('').addClass(t.className||"").data({contextMenu:t,contextMenuRoot:n}),e.each(["callbacks","commands","inputs"],function(e,a){t[a]={},n[a]||(n[a]={})}),n.accesskeys||(n.accesskeys={}),e.each(t.items,function(o,s){var i=e('
  • ').addClass(s.className||""),c=null,l=null;if(i.on("click",e.noop),"string"!=typeof s&&"cm_separator"!==s.type||(s={type:"cm_seperator"}),s.$node=i.data({contextMenu:t,contextMenuRoot:n,contextMenuKey:o}),void 0!==s.accesskey)for(var u,d=function(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}(s.accesskey),f=0;u=d[f];f++)if(!n.accesskeys[u]){n.accesskeys[u]=s;var h=s.name.match(new RegExp("^(.*?)("+u+")(.*)$","i"));h&&(s._beforeAccesskey=h[1],s._accesskey=h[2],s._afterAccesskey=h[3]);break}if(s.type&&r[s.type])r[s.type].call(i,s,t,n),e.each([t,n],function(n,a){a.commands[o]=s,!e.isFunction(s.callback)||void 0!==a.callbacks[o]&&void 0!==t.type||(a.callbacks[o]=s.callback)});else{switch("cm_seperator"===s.type?i.addClass("context-menu-separator "+n.classNames.notSelectable):"html"===s.type?i.addClass("context-menu-html "+n.classNames.notSelectable):"sub"===s.type||(s.type?(c=e("").appendTo(i),a(s).appendTo(c),i.addClass("context-menu-input"),t.hasTypes=!0,e.each([t,n],function(e,t){t.commands[o]=s,t.inputs[o]=s})):s.items&&(s.type="sub")),s.type){case"cm_seperator":break;case"text":l=e('').attr("name","context-menu-input-"+o).val(s.value||"").appendTo(c);break;case"textarea":l=e('').attr("name","context-menu-input-"+o).val(s.value||"").appendTo(c),s.height&&l.height(s.height);break;case"checkbox":l=e('').attr("name","context-menu-input-"+o).val(s.value||"").prop("checked",!!s.selected).prependTo(c);break;case"radio":l=e('').attr("name","context-menu-input-"+s.radio).val(s.value||"").prop("checked",!!s.selected).prependTo(c);break;case"select":l=e('').attr("name","context-menu-input-"+o).appendTo(c),s.options&&(e.each(s.options,function(t,n){e("").val(t).text(n).appendTo(l)}),l.val(s.selected));break;case"sub":a(s).appendTo(i),s.appendTo=s.$node,i.data("contextMenu",s).addClass("context-menu-submenu"),s.callback=null,"function"==typeof s.items.then?p.processPromises(s,n,s.items):p.create(s,n);break;case"html":e(s.html).appendTo(i);break;default:e.each([t,n],function(n,a){a.commands[o]=s,!e.isFunction(s.callback)||void 0!==a.callbacks[o]&&void 0!==t.type||(a.callbacks[o]=s.callback)}),a(s).appendTo(i)}s.type&&"sub"!==s.type&&"html"!==s.type&&"cm_seperator"!==s.type&&(l.on("focus",m.focusInput).on("blur",m.blurInput),s.events&&l.on(s.events,t)),s.icon&&(e.isFunction(s.icon)?s._icon=s.icon.call(this,this,i,o,s):"string"==typeof s.icon&&"fa-"===s.icon.substring(0,3)?s._icon=n.classNames.icon+" "+n.classNames.icon+"--fa fa "+s.icon:s._icon=n.classNames.icon+" "+n.classNames.icon+"-"+s.icon,i.addClass(s._icon))}s.$input=l,s.$label=c,i.appendTo(t.$menu),!t.hasTypes&&e.support.eventSelectstart&&i.on("selectstart.disableTextSelect",m.abortevent)}),t.$node||t.$menu.css("display","none").addClass("context-menu-root"),t.$menu.appendTo(t.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(){p.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,p.resize(t.$menu)),t.$menu.children().each(function(){var o,s=e(this),i=s.data("contextMenuKey"),c=t.items[i],l=e.isFunction(c.disabled)&&c.disabled.call(a,i,n)||!0===c.disabled;if(o=e.isFunction(c.visible)?c.visible.call(a,i,n):void 0===c.visible||!0===c.visible,s[o?"show":"hide"](),s[l?"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",l),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((0===c.selected?"0":c.selected)||"")}c.$menu&&p.update.call(a,c,n)})},layer:function(t,n){var a=t.$layer=e('
    ').css({height:s.height(),width:s.width(),display:"block",position:"fixed","z-index":n,top:0,left:0,opacity:0,filter:"alpha(opacity=0)","background-color":"#000"}).data("contextMenuRoot",t).insertBefore(this).on("contextmenu",m.abortevent).on("mousedown",m.layerClick);return void 0===document.body.style.maxWidth&&a.css({position:"absolute",height:e(document).height()}),a},processPromises:function(e,t,n){function a(e,t,n){void 0===n?(n={error:{name:"No items and no error item",icon:"context-menu-icon context-menu-icon-quit"}},window.console&&(console.error||console.log).call(console,'When you reject a promise, provide an "items" object, equal to normal sub-menu items')):"string"==typeof n&&(n={error:{name:n}}),o(e,t,n)}function o(e,t,n){void 0!==t.$menu&&t.$menu.is(":visible")&&(e.$node.removeClass(t.classNames.iconLoadingClass),e.items=n,p.create(e,t,!0),p.update(e,t),t.positionSubmenu.call(e.$node,e.$menu))}e.$node.addClass(t.classNames.iconLoadingClass),n.then(function(e,t,n){void 0===n&&a(void 0),o(e,t,n)}.bind(this,e,t),a.bind(this,e,t))},activated:function(t){var n=t.$menu,a=n.offset(),o=e(window).height(),s=e(window).scrollTop(),i=n.height();i>o?n.css({height:o+"px","overflow-x":"hidden","overflow-y":"auto",top:s+"px"}):(a.tops+o)&&n.css({top:"0px"})}};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"}))}),m.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,{},u,n||{}),s=e(document),r=s,d=!1;switch(a.context&&a.context.length?(r=e(a.context).first(),a.context=r.get(0),d=!e(a.context).is(document)):a.context=document,t){case"update":if(d)p.update(r);else for(var f in l)l.hasOwnProperty(f)&&p.update(l[f]);break;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(i++,a.ns=".contextMenu"+i,d||(c[a.selector]=a.ns),l[a.ns]=a,a.trigger||(a.trigger="right"),!o){var h="click"===a.itemClickEvent?"click.contextMenu":"mouseup.contextMenu",v={"contextmenu:focus.contextMenu":m.focusItem,"contextmenu:blur.contextMenu":m.blurItem,"contextmenu.contextMenu":m.abortevent,"mouseenter.contextMenu":m.itemMouseenter,"mouseleave.contextMenu":m.itemMouseleave};v[h]=m.itemClick,s.on({"contextmenu:hide.contextMenu":m.hideMenu,"prevcommand.contextMenu":m.prevItem,"nextcommand.contextMenu":m.nextItem,"contextmenu.contextMenu":m.abortevent,"mouseenter.contextMenu":m.menuMouseenter,"mouseleave.contextMenu":m.menuMouseleave},".context-menu-list").on("mouseup.contextMenu",".context-menu-input",m.inputClick).on(v,".context-menu-item"),o=!0}switch(r.on("contextmenu"+a.ns,a.selector,a,m.contextmenu),d&&r.on("remove"+a.ns,function(){e(this).contextMenu("destroy")}),a.trigger){case"hover":r.on("mouseenter"+a.ns,a.selector,a,m.mouseenter).on("mouseleave"+a.ns,a.selector,a,m.mouseleave);break;case"left":r.on("click"+a.ns,a.selector,a,m.click);break;case"touchstart":r.on("touchstart"+a.ns,a.selector,a,m.click)}a.build||p.create(a);break;case"destroy":var x;if(d){var g=a.context;e.each(l,function(t,n){if(!n)return!0;if(!e(g).is(n.selector))return!0;(x=e(".context-menu-list").filter(":visible")).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(e){l[n.ns]=null}return e(n.context).off(n.ns),!0})}else if(a.selector){if(c[a.selector]){(x=e(".context-menu-list").filter(":visible")).length&&x.data().contextMenuRoot.$trigger.is(a.selector)&&x.trigger("contextmenu:hide",{force:!0});try{l[c[a.selector]].$menu&&l[c[a.selector]].$menu.remove(),delete l[c[a.selector]]}catch(e){l[c[a.selector]]=null}s.off(c[a.selector])}}else s.off(".contextMenu .contextMenuAutoHide"),e.each(l,function(t,n){e(n.context).off(n.ns)}),c={},l={},i=0,o=!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 a={};return n(a,e(t).children()),a},e.contextMenu.defaults=u,e.contextMenu.types=r,e.contextMenu.handle=m,e.contextMenu.op=p,e.contextMenu.menus=l}); +!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)}(function(e){"use strict";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=(t=e.cleanData,function(n){var a,o,s;for(s=0;null!=n[s];s++){o=n[s];try{(a=e._data(o,"events"))&&a.remove&&e(o).triggerHandler("remove")}catch(e){}}t(n)}));var t,n=null,a=!1,o=e(window),s=0,i={},c={},l={},r={selector:null,appendTo:null,trigger:"right",autoHide:!1,delay:200,reposition:!0,hideOnSecondTrigger:!1,selectableSubMenu:!1,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",iconLoadingClass:"context-menu-icon-loading"},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){if("maintain"===t&&"maintain"===n)a=e.$menu.position();else{var s=e.$menu.offsetParent().offset();a={top:n-s.top,left:t-s.left}}var i=o.scrollTop()+o.height(),c=o.scrollLeft()+o.width(),l=e.$menu.outerHeight(),r=e.$menu.outerWidth();a.top+l>i&&(a.top-=l),a.top<0&&(a.top=0),a.left+r>c&&(a.left-=r),a.left<0&&(a.left=0),e.$menu.css(a)}else e.determinePosition.call(this,e.$menu)},positionSubmenu:function(t){if(void 0!==t)if(e.ui&&e.ui.position)t.css("display","block").position({my:"left top-5",at:"right top",of:this,collision:"flipfit fit"}).css("display","");else{var n={top:-9,left:this.outerWidth()-5};t.css(n)}},zIndex:1,animation:{duration:50,show:"slideDown",hide:"slideUp"},events:{show:e.noop,hide:e.noop,activated:e.noop},callback:null,items:{}},u={timer:null,pageX:null,pageY:null},d={abortevent:function(e){e.preventDefault(),e.stopImmediatePropagation()},contextmenu:function(t){var a=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)||a.hasClass("context-menu-active")||a.hasClass("context-menu-disabled"))){if(n=a,t.data.build){var o=t.data.build(n,t);if(!1===o)return;if(t.data=e.extend(!0,{},r,t.data,o||{}),!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=n,m.create(t.data)}var s=!1;for(var i in t.data.items)if(t.data.items.hasOwnProperty(i)){(e.isFunction(t.data.items[i].visible)?t.data.items[i].visible.call(e(t.currentTarget),i,t.data):void 0===t.data.items[i]||!t.data.items[i].visible||!0===t.data.items[i].visible)&&(s=!0)}s&&m.show.call(a,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 a=e(this);n&&n.length&&!n.is(a)&&n.data("contextMenu").$menu.trigger("contextmenu:hide"),2===t.button&&(n=a.data("contextMenuActive",!0))},mouseup:function(t){var a=e(this);a.data("contextMenuActive")&&n&&n.length&&n.is(a)&&!a.hasClass("context-menu-disabled")&&(t.preventDefault(),t.stopImmediatePropagation(),n=a,a.trigger(e.Event("contextmenu",{data:t.data,pageX:t.pageX,pageY:t.pageY}))),a.removeData("contextMenuActive")},mouseenter:function(t){var a=e(this),o=e(t.relatedTarget),s=e(document);o.is(".context-menu-list")||o.closest(".context-menu-list").length||n&&n.length||(u.pageX=t.pageX,u.pageY=t.pageY,u.data=t.data,s.on("mousemove.contextMenuShow",d.mousemove),u.timer=setTimeout(function(){u.timer=null,s.off("mousemove.contextMenuShow"),n=a,a.trigger(e.Event("contextmenu",{data:u.data,pageX:u.pageX,pageY:u.pageY}))},t.data.delay))},mousemove:function(e){u.pageX=e.pageX,u.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(u.timer)}catch(t){}u.timer=null}},layerClick:function(t){var n,a,s=e(this).data("contextMenuRoot"),i=t.button,c=t.pageX,l=t.pageY;t.preventDefault(),setTimeout(function(){var r,u="left"===s.trigger&&0===i||"right"===s.trigger&&2===i;if(document.elementFromPoint&&s.$layer){if(s.$layer.hide(),(n=document.elementFromPoint(c-o.scrollLeft(),l-o.scrollTop())).isContentEditable){var d=document.createRange(),m=window.getSelection();d.selectNode(n),d.collapse(!0),m.removeAllRanges(),m.addRange(d)}e(n).trigger(t),s.$layer.show()}if(s.hideOnSecondTrigger&&u&&null!==s.$menu&&void 0!==s.$menu)s.$menu.trigger("contextmenu:hide");else{if(s.reposition&&u)if(document.elementFromPoint){if(s.$trigger.is(n))return void s.position.call(s.$trigger,s,c,l)}else if(a=s.$trigger.offset(),r=e(window),a.top+=r.scrollTop(),a.top<=t.pageY&&(a.left+=r.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,c,l);n&&u&&s.$trigger.one("contextmenu:hidden",function(){e(n).contextMenu({x:c,y:l,button:i})}),null!==s&&void 0!==s&&null!==s.$menu&&void 0!==s.$menu&&s.$menu.trigger("contextmenu:hide")}},50)},keyStop:function(e,t){t.isInput||e.preventDefault(),e.stopPropagation()},key:function(e){var t={};n&&(t=n.data("contextMenu")||{}),void 0===t.zIndex&&(t.zIndex=0);var a=0,o=function(e){""!==e.style.zIndex?a=e.style.zIndex:null!==e.offsetParent&&void 0!==e.offsetParent?o(e.offsetParent):null!==e.parentElement&&void 0!==e.parentElement&&o(e.parentElement)};if(o(e.target),!(t.$menu&&parseInt(a,10)>parseInt(t.$menu.css("zIndex"),10))){switch(e.keyCode){case 9:case 38:if(d.keyStop(e,t),t.isInput){if(9===e.keyCode&&e.shiftKey)return e.preventDefault(),t.$selected&&t.$selected.find("input, textarea, select").blur(),void(null!==t.$menu&&void 0!==t.$menu&&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(null!==t.$menu&&void 0!==t.$menu&&t.$menu.trigger("prevcommand"));break;case 40:if(d.keyStop(e,t),!t.isInput)return void(null!==t.$menu&&void 0!==t.$menu&&t.$menu.trigger("nextcommand"));if(9===e.keyCode)return e.preventDefault(),t.$selected&&t.$selected.find("input, textarea, select").blur(),void(null!==t.$menu&&void 0!==t.$menu&&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(d.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(d.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(d.keyStop(e,t),t.isInput){if(t.$selected&&!t.$selected.is("textarea, select"))return void e.preventDefault();break}return void(void 0!==t.$selected&&null!==t.$selected&&t.$selected.trigger("mouseup"));case 32:case 33:case 34:return void d.keyStop(e,t);case 27:return d.keyStop(e,t),void(null!==t.$menu&&void 0!==t.$menu&&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(),void 0!==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")||{}).$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()).is(c))return;n.$selected&&d.itemMouseleave.call(n.$selected.get(0),t),d.itemMouseenter.call(i.get(0),t);var l=i.find("input, textarea, select");l.length&&l.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")||{}).$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()).is(c))return;n.$selected&&d.itemMouseleave.call(n.$selected.get(0),t),d.itemMouseenter.call(i.get(0),t);var l=i.find("input, textarea, select");l.length&&l.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").data(),n=t.contextMenu;t.contextMenuRoot.isInput=n.isInput=!1},menuMouseenter:function(){e(this).data().contextMenuRoot.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;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)?o.$selected=null:n.trigger("contextmenu:focus")},itemMouseleave:function(t){var n=e(this),a=n.data(),o=a.contextMenu,s=a.contextMenuRoot;if(s!==o&&s.$layer&&s.$layer.is(t.relatedTarget))return void 0!==s.$selected&&null!==s.$selected&&s.$selected.trigger("contextmenu:blur"),t.preventDefault(),t.stopImmediatePropagation(),void(s.$selected=o.$selected=o.$node);o&&o.$menu&&o.$menu.hasClass("context-menu-visible")||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-separator, ."+i.classNames.notSelectable)||a.is(".context-menu-submenu")&&!1===i.selectableSubMenu)){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}!1!==n.call(i.$trigger,c,i,t)?i.$menu.trigger("contextmenu:hide"):i.$menu.parent().length&&m.update.call(i.$trigger,i)}},inputClick:function(e){e.stopImmediatePropagation()},hideMenu:function(t,n){var a=e(this).data("contextMenuRoot");m.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&&o.$node&&o.$node.hasClass("context-menu-submenu")&&o.$node.addClass(s.classNames.hover),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}},m={show:function(t,a,o){var s=e(this),i={};if(e("#context-menu-layer").trigger("mousedown"),t.$trigger=s,!1!==t.events.show.call(s,t)){if(m.update.call(s,t),t.position.call(s,t,a,o),t.zIndex){var c=t.zIndex;"function"==typeof t.zIndex&&(c=t.zIndex.call(s,t)),i.zIndex=function(e){for(var t=0,n=e;t=Math.max(t,parseInt(n.css("z-index"),10)||0),(n=n.parent())&&n.length&&!("html body".indexOf(n.prop("nodeName").toLowerCase())>-1););return t}(s)+c}m.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"),m.activated(t),t.events.activated(t)}),s.data("contextMenu",t).addClass("context-menu-active"),e(document).off("keydown.contextMenu").on("keydown.contextMenu",d.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||void 0===t.$menu||t.$menu.trigger("contextmenu:hide")},50)})}else n=null},hide:function(t,a){var o=e(this);if(t||(t=o.data("contextMenu")||{}),a||!t.events||!1!==t.events.hide.call(o,t)){if(o.removeData("contextMenu").removeClass("context-menu-active"),t.$layer){setTimeout((s=t.$layer,function(){s.remove()}),10);try{delete t.$layer}catch(e){t.$layer=null}}var s;n=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(e){}return!0}})),setTimeout(function(){o.trigger("contextmenu:hidden")},10)})}},create:function(t,n){void 0===n&&(n=t),t.$menu=e('').addClass(t.className||"").data({contextMenu:t,contextMenuRoot:n}),t.dataAttr&&t.$menu.attr(t.dataAttr),e.each(["callbacks","commands","inputs"],function(e,a){t[a]={},n[a]||(n[a]={})}),n.accesskeys||(n.accesskeys={});function a(t){var n=e("");if(t._accesskey)t._beforeAccesskey&&n.append(document.createTextNode(t._beforeAccesskey)),e("").addClass("context-menu-accesskey").text(t._accesskey).appendTo(n),t._afterAccesskey&&n.append(document.createTextNode(t._afterAccesskey));else if(t.isHtmlName){if(void 0!==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}e.each(t.items,function(o,s){var i=e('
  • ').addClass(s.className||""),c=null,r=null;if(i.on("click",e.noop),"string"!=typeof s&&"cm_separator"!==s.type||(s={type:"cm_seperator"}),s.$node=i.data({contextMenu:t,contextMenuRoot:n,contextMenuKey:o}),void 0!==s.accesskey)for(var u,p=function(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}(s.accesskey),f=0;u=p[f];f++)if(!n.accesskeys[u]){n.accesskeys[u]=s;var h=s.name.match(new RegExp("^(.*?)("+u+")(.*)$","i"));h&&(s._beforeAccesskey=h[1],s._accesskey=h[2],s._afterAccesskey=h[3]);break}if(s.type&&l[s.type])l[s.type].call(i,s,t,n),e.each([t,n],function(n,a){a.commands[o]=s,!e.isFunction(s.callback)||void 0!==a.callbacks[o]&&void 0!==t.type||(a.callbacks[o]=s.callback)});else{switch("cm_seperator"===s.type?i.addClass("context-menu-separator "+n.classNames.notSelectable):"html"===s.type?i.addClass("context-menu-html "+n.classNames.notSelectable):"sub"===s.type||(s.type?(c=e("").appendTo(i),a(s).appendTo(c),i.addClass("context-menu-input"),t.hasTypes=!0,e.each([t,n],function(e,t){t.commands[o]=s,t.inputs[o]=s})):s.items&&(s.type="sub")),s.type){case"cm_seperator":break;case"text":r=e('').attr("name","context-menu-input-"+o).val(s.value||"").appendTo(c);break;case"textarea":r=e('').attr("name","context-menu-input-"+o).val(s.value||"").appendTo(c),s.height&&r.height(s.height);break;case"checkbox":r=e('').attr("name","context-menu-input-"+o).val(s.value||"").prop("checked",!!s.selected).prependTo(c);break;case"radio":r=e('').attr("name","context-menu-input-"+s.radio).val(s.value||"").prop("checked",!!s.selected).prependTo(c);break;case"select":r=e('').attr("name","context-menu-input-"+o).appendTo(c),s.options&&(e.each(s.options,function(t,n){e("").val(t).text(n).appendTo(r)}),r.val(s.selected));break;case"sub":a(s).appendTo(i),s.appendTo=s.$node,i.data("contextMenu",s).addClass("context-menu-submenu"),s.callback=null,"function"==typeof s.items.then?m.processPromises(s,n,s.items):m.create(s,n);break;case"html":e(s.html).appendTo(i);break;default:e.each([t,n],function(n,a){a.commands[o]=s,!e.isFunction(s.callback)||void 0!==a.callbacks[o]&&void 0!==t.type||(a.callbacks[o]=s.callback)}),a(s).appendTo(i)}s.type&&"sub"!==s.type&&"html"!==s.type&&"cm_seperator"!==s.type&&(r.on("focus",d.focusInput).on("blur",d.blurInput),s.events&&r.on(s.events,t)),s.icon&&(e.isFunction(s.icon)?s._icon=s.icon.call(this,this,i,o,s):"string"==typeof s.icon&&"fa-"===s.icon.substring(0,3)?s._icon=n.classNames.icon+" "+n.classNames.icon+"--fa fa "+s.icon:s._icon=n.classNames.icon+" "+n.classNames.icon+"-"+s.icon,i.addClass(s._icon))}s.$input=r,s.$label=c,i.appendTo(t.$menu),!t.hasTypes&&e.support.eventSelectstart&&i.on("selectstart.disableTextSelect",d.abortevent)}),t.$node||t.$menu.css("display","none").addClass("context-menu-root"),t.$menu.appendTo(t.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(){m.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,m.resize(t.$menu)),t.$menu.children().each(function(){var o=e(this),s=o.data("contextMenuKey"),i=t.items[s],c=e.isFunction(i.disabled)&&i.disabled.call(a,s,n)||!0===i.disabled;if(o[(e.isFunction(i.visible)?i.visible.call(a,s,n):void 0===i.visible||!0===i.visible)?"show":"hide"](),o[c?"addClass":"removeClass"](n.classNames.disabled),e.isFunction(i.icon)&&(o.removeClass(i._icon),i._icon=i.icon.call(this,a,o,s,i),o.addClass(i._icon)),i.type)switch(o.find("input, select, textarea").prop("disabled",c),i.type){case"text":case"textarea":i.$input.val(i.value||"");break;case"checkbox":case"radio":i.$input.val(i.value||"").prop("checked",!!i.selected);break;case"select":i.$input.val((0===i.selected?"0":i.selected)||"")}i.$menu&&m.update.call(a,i,n)})},layer:function(t,n){var a=t.$layer=e('
    ').css({height:o.height(),width:o.width(),display:"block",position:"fixed","z-index":n,top:0,left:0,opacity:0,filter:"alpha(opacity=0)","background-color":"#000"}).data("contextMenuRoot",t).insertBefore(this).on("contextmenu",d.abortevent).on("mousedown",d.layerClick);return void 0===document.body.style.maxWidth&&a.css({position:"absolute",height:e(document).height()}),a},processPromises:function(e,t,n){e.$node.addClass(t.classNames.iconLoadingClass);function a(e,t,n){void 0===n?(n={error:{name:"No items and no error item",icon:"context-menu-icon context-menu-icon-quit"}},window.console&&(console.error||console.log).call(console,'When you reject a promise, provide an "items" object, equal to normal sub-menu items')):"string"==typeof n&&(n={error:{name:n}}),o(e,t,n)}function o(e,t,n){void 0!==t.$menu&&t.$menu.is(":visible")&&(e.$node.removeClass(t.classNames.iconLoadingClass),e.items=n,m.create(e,t,!0),m.update(e,t),t.positionSubmenu.call(e.$node,e.$menu))}n.then(function(e,t,n){void 0===n&&a(void 0),o(e,t,n)}.bind(this,e,t),a.bind(this,e,t))},activated:function(t){var n=t.$menu,a=n.offset(),o=e(window).height(),s=e(window).scrollTop(),i=n.height();i>o?n.css({height:o+"px","overflow-x":"hidden","overflow-y":"auto",top:s+"px"}):(a.tops+o)&&n.css({top:"0px"})}};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(c,function(){this.selector===n.selector&&(a.data=this,e.extend(a.data,{trigger:"demand"}))}),d.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 o=e.extend(!0,{},r,n||{}),l=e(document),u=l,p=!1;switch(o.context&&o.context.length?(u=e(o.context).first(),o.context=u.get(0),p=!e(o.context).is(document)):o.context=document,t){case"update":if(p)m.update(u);else for(var f in c)c.hasOwnProperty(f)&&m.update(c[f]);break;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||e.isEmptyObject(o.items)))throw new Error("No Items specified");if(s++,o.ns=".contextMenu"+s,p||(i[o.selector]=o.ns),c[o.ns]=o,o.trigger||(o.trigger="right"),!a){var h="click"===o.itemClickEvent?"click.contextMenu":"mouseup.contextMenu",v={"contextmenu:focus.contextMenu":d.focusItem,"contextmenu:blur.contextMenu":d.blurItem,"contextmenu.contextMenu":d.abortevent,"mouseenter.contextMenu":d.itemMouseenter,"mouseleave.contextMenu":d.itemMouseleave};v[h]=d.itemClick,l.on({"contextmenu:hide.contextMenu":d.hideMenu,"prevcommand.contextMenu":d.prevItem,"nextcommand.contextMenu":d.nextItem,"contextmenu.contextMenu":d.abortevent,"mouseenter.contextMenu":d.menuMouseenter,"mouseleave.contextMenu":d.menuMouseleave},".context-menu-list").on("mouseup.contextMenu",".context-menu-input",d.inputClick).on(v,".context-menu-item"),a=!0}switch(u.on("contextmenu"+o.ns,o.selector,o,d.contextmenu),p&&u.on("remove"+o.ns,function(){e(this).contextMenu("destroy")}),o.trigger){case"hover":u.on("mouseenter"+o.ns,o.selector,o,d.mouseenter).on("mouseleave"+o.ns,o.selector,o,d.mouseleave);break;case"left":u.on("click"+o.ns,o.selector,o,d.click);break;case"touchstart":u.on("touchstart"+o.ns,o.selector,o,d.click)}o.build||m.create(o);break;case"destroy":var x;if(p){var g=o.context;e.each(c,function(t,n){if(!n)return!0;if(!e(g).is(n.selector))return!0;(x=e(".context-menu-list").filter(":visible")).length&&x.data().contextMenuRoot.$trigger.is(e(n.context).find(n.selector))&&x.trigger("contextmenu:hide",{force:!0});try{c[n.ns].$menu&&c[n.ns].$menu.remove(),delete c[n.ns]}catch(e){c[n.ns]=null}return e(n.context).off(n.ns),!0})}else if(o.selector){if(i[o.selector]){(x=e(".context-menu-list").filter(":visible")).length&&x.data().contextMenuRoot.$trigger.is(o.selector)&&x.trigger("contextmenu:hide",{force:!0});try{c[i[o.selector]].$menu&&c[i[o.selector]].$menu.remove(),delete c[i[o.selector]]}catch(e){c[i[o.selector]]=null}l.off(i[o.selector])}}else l.off(".contextMenu .contextMenuAutoHide"),e.each(c,function(t,n){e(n.context).off(n.ns)}),i={},c={},s=0,a=!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};function p(t){return t.id&&e('label[for="'+t.id+'"]').val()||t.name}e.contextMenu.fromMenu=function(t){var n={};return function t(n,a,o){return o||(o=0),a.each(function(){var a,s,i=e(this),c=this,l=this.nodeName.toLowerCase();switch("label"===l&&i.find("input, textarea, select").length&&(a=i.text(),l=(c=(i=i.children().first()).get(0)).nodeName.toLowerCase()),l){case"menu":s={name:i.attr("label"),items:{}},o=t(s.items,i.children(),o);break;case"a":case"button":s={name:i.text(),disabled:!!i.attr("disabled"),callback:function(){i.get(0).click()}};break;case"menuitem":case"command":switch(i.attr("type")){case void 0:case"command":case"menuitem":s={name:i.attr("label"),disabled:!!i.attr("disabled"),icon:i.attr("icon"),callback:function(){i.get(0).click()}};break;case"checkbox":s={type:"checkbox",disabled:!!i.attr("disabled"),name:i.attr("label"),selected:!!i.attr("checked")};break;case"radio":s={type:"radio",disabled:!!i.attr("disabled"),name:i.attr("label"),radio:i.attr("radiogroup"),value:i.attr("id"),selected:!!i.attr("checked")};break;default:s=void 0}break;case"hr":s="-------";break;case"input":switch(i.attr("type")){case"text":s={type:"text",name:a||p(c),disabled:!!i.attr("disabled"),value:i.val()};break;case"checkbox":s={type:"checkbox",name:a||p(c),disabled:!!i.attr("disabled"),selected:!!i.attr("checked")};break;case"radio":s={type:"radio",name:a||p(c),disabled:!!i.attr("disabled"),radio:!!i.attr("name"),value:i.val(),selected:!!i.attr("checked")};break;default:s=void 0}break;case"select":s={type:"select",name:a||p(c),disabled:!!i.attr("disabled"),selected:i.val(),options:{}},i.children().each(function(){s.options[this.value]=e(this).text()});break;case"textarea":s={type:"textarea",name:a||p(c),disabled:!!i.attr("disabled"),value:i.val()};break;case"label":break;default:s={type:"html",html:i.clone(!0)}}s&&(n["key"+ ++o]=s)}),o}(n,e(t).children()),n},e.contextMenu.defaults=r,e.contextMenu.types=l,e.contextMenu.handle=d,e.contextMenu.op=m,e.contextMenu.menus=c}); //# sourceMappingURL=jquery.contextMenu.min.js.map diff --git a/dist/jquery.contextMenu.min.js.map b/dist/jquery.contextMenu.min.js.map index 2af12267..5eaf8de0 100644 --- a/dist/jquery.contextMenu.min.js.map +++ b/dist/jquery.contextMenu.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["jquery.contextMenu.min.js"],"names":["factory","define","amd","exports","require","jQuery","$","inputLabel","node","id","val","name","menuChildren","items","$children","counter","each","label","item","$node","this","nodeName","toLowerCase","find","length","text","children","first","get","attr","disabled","callback","click","undefined","icon","type","selected","radio","value","options","html","clone","support","htmlMenuitem","window","htmlCommand","eventSelectstart","document","documentElement","ui","widget","cleanData","orig","elems","events","elem","i","_data","remove","triggerHandler","e","$currentTrigger","initialized","$win","namespaces","menus","types","defaults","selector","appendTo","trigger","autoHide","delay","reposition","hideOnSecondTrigger","selectableSubMenu","classNames","hover","visible","notSelectable","iconEdit","iconCut","iconCopy","iconPaste","iconDelete","iconAdd","iconQuit","iconLoadingClass","determinePosition","$menu","position","css","my","at","of","offset","collision","top","outerHeight","left","outerWidth","opt","x","y","offsetParentOffset","offsetParent","bottom","scrollTop","height","right","scrollLeft","width","call","positionSubmenu","zIndex","animation","duration","show","hide","noop","activated","hoveract","timer","pageX","pageY","handle","abortevent","preventDefault","stopImmediatePropagation","contextmenu","$this","data","originalEvent","mouseButton","hasClass","build","built","extend","isEmptyObject","console","error","log","Error","$trigger","op","create","showMenu","hasOwnProperty","isFunction","currentTarget","Event","mousedown","is","button","mouseup","removeData","mouseenter","$related","relatedTarget","$document","closest","on","mousemove","setTimeout","off","mouseleave","clearTimeout","layerClick","target","root","$window","triggerAction","elementFromPoint","$layer","isContentEditable","range","createRange","sel","getSelection","selectNode","collapse","removeAllRanges","addRange","one","contextMenu","keyStop","isInput","stopPropagation","key","targetZIndex","getZIndexOfTriggerTarget","style","parentElement","parseInt","keyCode","shiftKey","$selected","blur","prop","parent","$parent","itemdata","k","String","fromCharCode","toUpperCase","accesskeys","prevItem","$s","$prev","prev","last","$round","itemMouseleave","itemMouseenter","$input","focus","nextItem","$next","next","focusInput","contextMenuRoot","blurInput","menuMouseenter","hovering","menuMouseleave","itemClick","contextMenuKey","callbacks","Object","prototype","update","inputClick","hideMenu","force","focusItem","addClass","join","not","removeClass","filter","blurItem","additionalZValue","$t","zin","$tt","Math","max","indexOf","zindex","layer","pos","createNameNode","$name","_accesskey","_beforeAccesskey","append","createTextNode","_afterAccesskey","isHtmlName","accesskey","className","$label","ak","aks","t","split","keys","charAt","push","splitAccesskey","matched","match","RegExp","commands","hasTypes","inputs","prependTo","then","processPromises","_icon","substring","body","resize","nested","domMenu","display","getBoundingClientRect","ceil","minWidth","maxWidth","addBack","$item","z-index","opacity","background-color","insertBefore","promise","errorPromise","errorItem","finishPromiseProcess","bind","$menuOffset","winHeight","winScrollTop","menuHeight","overflow-x","overflow-y","fn","operation","$o","context","isPlainObject","o","$context","_hasContext","menu","ns","itemClickEvent","contextMenuItemObj","contextmenu:focus.contextMenu","contextmenu:blur.contextMenu","contextmenu.contextMenu","mouseenter.contextMenu","mouseleave.contextMenu","contextmenu:hide.contextMenu","prevcommand.contextMenu","nextcommand.contextMenu","$visibleMenu","fromMenu","setInputValues","getInputValues","element"],"mappings":"CAkBA,SAAWA,GACe,mBAAXC,QAAyBA,OAAOC,IAEvCD,QAAQ,UAAWD,GAGnBA,EAF0B,iBAAZG,QAENC,QAAQ,UAGRC,QAThB,CAWG,SAAUC,GAET,aAk1DA,SAASC,EAAWC,GAChB,OAAQA,EAAKC,IAAMH,EAAE,cAAgBE,EAAKC,GAAK,MAAMC,OAAUF,EAAKG,KAIxE,SAASC,EAAaC,EAAOC,EAAWC,GA0KpC,OAzKKA,IACDA,EAAU,GAGdD,EAAUE,KAAK,WACX,I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GAAO1K,EAAKqM,OAAO7M,MACxB,MAEJ,IAAK,WACDyH,EAAKyD,GAAO1K,EAAKqM,OAAOjB,KAAK,WAC7B,MAEJ,IAAK,QACGpL,EAAKqM,OAAOjB,KAAK,aACjBnE,EAAKjH,EAAKmB,OAASnB,EAAKoB,UAMjC6F,GAuLX7H,EAAEkL,YAAYiJ,SAAW,SAAUG,GAC/B,IACI/T,KAIJ,OAFAD,EAAaC,EAHDP,EAAEsU,GAGYlT,YAEnBb,GAIXP,EAAEkL,YAAYrH,SAAWA,EACzB7D,EAAEkL,YAAYtH,MAAQA,EAEtB5D,EAAEkL,YAAY3D,OAASA,EACvBvH,EAAEkL,YAAYxC,GAAKA,EACnB1I,EAAEkL,YAAYvH,MAAQA","file":"jquery.contextMenu.min.js","sourcesContent":["/**\r\n * jQuery contextMenu v2.6.3 - Plugin for simple contextMenu handling\r\n *\r\n * Version: v2.6.3\r\n *\r\n * Authors: Björn Brala (SWIS.nl), Rodney Rehm, Addy Osmani (patches for FF)\r\n * Web: http://swisnl.github.io/jQuery-contextMenu/\r\n *\r\n * Copyright (c) 2011-2017 SWIS BV and contributors\r\n *\r\n * Licensed under\r\n * MIT License http://www.opensource.org/licenses/mit-license\r\n *\r\n * Date: 2017-12-15T13:56:37.241Z\r\n */\r\n\r\n// jscs:disable\r\n/* jshint ignore:start */\r\n(function (factory) {\r\n if (typeof define === 'function' && define.amd) {\r\n // AMD. Register as anonymous module.\r\n define(['jquery'], factory);\r\n } else if (typeof exports === 'object') {\r\n // Node / CommonJS\r\n factory(require('jquery'));\r\n } else {\r\n // Browser globals.\r\n factory(jQuery);\r\n }\r\n})(function ($) {\r\n\r\n 'use strict';\r\n\r\n // TODO: -\r\n // ARIA stuff: menuitem, menuitemcheckbox und menuitemradio\r\n // create structure if $.support[htmlCommand || htmlMenuitem] and !opt.disableNative\r\n\r\n // determine html5 compatibility\r\n $.support.htmlMenuitem = ('HTMLMenuItemElement' in window);\r\n $.support.htmlCommand = ('HTMLCommandElement' in window);\r\n $.support.eventSelectstart = ('onselectstart' in document.documentElement);\r\n /* // should the need arise, test for css user-select\r\n $.support.cssUserSelect = (function(){\r\n var t = false,\r\n e = document.createElement('div');\r\n\r\n $.each('Moz|Webkit|Khtml|O|ms|Icab|'.split('|'), function(i, prefix) {\r\n var propCC = prefix + (prefix ? 'U' : 'u') + 'serSelect',\r\n prop = (prefix ? ('-' + prefix.toLowerCase() + '-') : '') + 'user-select';\r\n\r\n e.style.cssText = prop + ': text;';\r\n if (e.style[propCC] == 'text') {\r\n t = true;\r\n return false;\r\n }\r\n\r\n return true;\r\n });\r\n\r\n return t;\r\n })();\r\n */\r\n\r\n\r\n if (!$.ui || !$.widget) {\r\n // duck punch $.cleanData like jQueryUI does to get that remove event\r\n $.cleanData = (function (orig) {\r\n return function (elems) {\r\n var events, elem, i;\r\n for (i = 0; elems[i] != null; i++) {\r\n elem = elems[i];\r\n try {\r\n // Only trigger remove when necessary to save time\r\n events = $._data(elem, 'events');\r\n if (events && events.remove) {\r\n $(elem).triggerHandler('remove');\r\n }\r\n\r\n // Http://bugs.jquery.com/ticket/8235\r\n } catch (e) {\r\n }\r\n }\r\n orig(elems);\r\n };\r\n })($.cleanData);\r\n }\r\n /* jshint ignore:end */\r\n // jscs:enable\r\n\r\n var // currently active contextMenu trigger\r\n $currentTrigger = null,\r\n // is contextMenu initialized with at least one menu?\r\n initialized = false,\r\n // window handle\r\n $win = $(window),\r\n // number of registered menus\r\n counter = 0,\r\n // mapping selector to namespace\r\n namespaces = {},\r\n // mapping namespace to options\r\n menus = {},\r\n // custom command type handlers\r\n types = {},\r\n // default values\r\n defaults = {\r\n // selector of contextMenu trigger\r\n selector: null,\r\n // where to append the menu to\r\n appendTo: null,\r\n // method to trigger context menu [\"right\", \"left\", \"hover\"]\r\n trigger: 'right',\r\n // hide menu when mouse leaves trigger / menu elements\r\n autoHide: false,\r\n // ms to wait before showing a hover-triggered context menu\r\n delay: 200,\r\n // flag denoting if a second trigger should simply move (true) or rebuild (false) an open menu\r\n // as long as the trigger happened on one of the trigger-element's child nodes\r\n reposition: true,\r\n // Flag denoting if a second trigger should close the menu, as long as \r\n // the trigger happened on one of the trigger-element's child nodes.\r\n // This overrides the reposition option.\r\n hideOnSecondTrigger: false,\r\n\r\n //ability to select submenu\r\n selectableSubMenu: false,\r\n\r\n // Default classname configuration to be able avoid conflicts in frameworks\r\n classNames: {\r\n hover: 'context-menu-hover', // Item hover\r\n disabled: 'context-menu-disabled', // Item disabled\r\n visible: 'context-menu-visible', // Item visible\r\n notSelectable: 'context-menu-not-selectable', // Item not selectable\r\n\r\n icon: 'context-menu-icon',\r\n iconEdit: 'context-menu-icon-edit',\r\n iconCut: 'context-menu-icon-cut',\r\n iconCopy: 'context-menu-icon-copy',\r\n iconPaste: 'context-menu-icon-paste',\r\n iconDelete: 'context-menu-icon-delete',\r\n iconAdd: 'context-menu-icon-add',\r\n iconQuit: 'context-menu-icon-quit',\r\n iconLoadingClass: 'context-menu-icon-loading'\r\n },\r\n\r\n // determine position to show menu at\r\n determinePosition: function ($menu) {\r\n // position to the lower middle of the trigger element\r\n if ($.ui && $.ui.position) {\r\n // .position() is provided as a jQuery UI utility\r\n // (...and it won't work on hidden elements)\r\n $menu.css('display', 'block').position({\r\n my: 'center top',\r\n at: 'center bottom',\r\n of: this,\r\n offset: '0 5',\r\n collision: 'fit'\r\n }).css('display', 'none');\r\n } else {\r\n // determine contextMenu position\r\n var offset = this.offset();\r\n offset.top += this.outerHeight();\r\n offset.left += this.outerWidth() / 2 - $menu.outerWidth() / 2;\r\n $menu.css(offset);\r\n }\r\n },\r\n // position menu\r\n position: function (opt, x, y) {\r\n var offset;\r\n // determine contextMenu position\r\n if (!x && !y) {\r\n opt.determinePosition.call(this, opt.$menu);\r\n return;\r\n } else if (x === 'maintain' && y === 'maintain') {\r\n // x and y must not be changed (after re-show on command click)\r\n offset = opt.$menu.position();\r\n } else {\r\n // x and y are given (by mouse event)\r\n var offsetParentOffset = opt.$menu.offsetParent().offset();\r\n offset = {top: y - offsetParentOffset.top, left: x -offsetParentOffset.left};\r\n }\r\n\r\n // correct offset if viewport demands it\r\n var bottom = $win.scrollTop() + $win.height(),\r\n right = $win.scrollLeft() + $win.width(),\r\n height = opt.$menu.outerHeight(),\r\n width = opt.$menu.outerWidth();\r\n\r\n if (offset.top + height > bottom) {\r\n offset.top -= height;\r\n }\r\n\r\n if (offset.top < 0) {\r\n offset.top = 0;\r\n }\r\n\r\n if (offset.left + width > right) {\r\n offset.left -= width;\r\n }\r\n\r\n if (offset.left < 0) {\r\n offset.left = 0;\r\n }\r\n\r\n opt.$menu.css(offset);\r\n },\r\n // position the sub-menu\r\n positionSubmenu: function ($menu) {\r\n if (typeof $menu === 'undefined') {\r\n // When user hovers over item (which has sub items) handle.focusItem will call this.\r\n // but the submenu does not exist yet if opt.items is a promise. just return, will\r\n // call positionSubmenu after promise is completed.\r\n return;\r\n }\r\n if ($.ui && $.ui.position) {\r\n // .position() is provided as a jQuery UI utility\r\n // (...and it won't work on hidden elements)\r\n $menu.css('display', 'block').position({\r\n my: 'left top-5',\r\n at: 'right top',\r\n of: this,\r\n collision: 'flipfit fit'\r\n }).css('display', '');\r\n } else {\r\n // determine contextMenu position\r\n var offset = {\r\n top: -9,\r\n left: this.outerWidth() - 5\r\n };\r\n $menu.css(offset);\r\n }\r\n },\r\n // offset to add to zIndex\r\n zIndex: 1,\r\n // show hide animation settings\r\n animation: {\r\n duration: 50,\r\n show: 'slideDown',\r\n hide: 'slideUp'\r\n },\r\n // events\r\n events: {\r\n show: $.noop,\r\n hide: $.noop,\r\n activated: $.noop\r\n },\r\n // default callback\r\n callback: null,\r\n // list of contextMenu items\r\n items: {}\r\n },\r\n // mouse position for hover activation\r\n hoveract = {\r\n timer: null,\r\n pageX: null,\r\n pageY: null\r\n },\r\n // determine zIndex\r\n zindex = function ($t) {\r\n var zin = 0,\r\n $tt = $t;\r\n\r\n while (true) {\r\n zin = Math.max(zin, parseInt($tt.css('z-index'), 10) || 0);\r\n $tt = $tt.parent();\r\n if (!$tt || !$tt.length || 'html body'.indexOf($tt.prop('nodeName').toLowerCase()) > -1) {\r\n break;\r\n }\r\n }\r\n return zin;\r\n },\r\n // event handlers\r\n handle = {\r\n // abort anything\r\n abortevent: function (e) {\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n },\r\n // contextmenu show dispatcher\r\n contextmenu: function (e) {\r\n var $this = $(this);\r\n\r\n // disable actual context-menu if we are using the right mouse button as the trigger\r\n if (e.data.trigger === 'right') {\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n }\r\n\r\n // abort native-triggered events unless we're triggering on right click\r\n if ((e.data.trigger !== 'right' && e.data.trigger !== 'demand') && e.originalEvent) {\r\n return;\r\n }\r\n\r\n // Let the current contextmenu decide if it should show or not based on its own trigger settings\r\n if (typeof e.mouseButton !== 'undefined' && e.data) {\r\n if (!(e.data.trigger === 'left' && e.mouseButton === 0) && !(e.data.trigger === 'right' && e.mouseButton === 2)) {\r\n // Mouse click is not valid.\r\n return;\r\n }\r\n }\r\n\r\n // abort event if menu is visible for this trigger\r\n if ($this.hasClass('context-menu-active')) {\r\n return;\r\n }\r\n\r\n if (!$this.hasClass('context-menu-disabled')) {\r\n // theoretically need to fire a show event at \r\n // http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#context-menus\r\n // var evt = jQuery.Event(\"show\", { data: data, pageX: e.pageX, pageY: e.pageY, relatedTarget: this });\r\n // e.data.$menu.trigger(evt);\r\n\r\n $currentTrigger = $this;\r\n if (e.data.build) {\r\n var built = e.data.build($currentTrigger, e);\r\n // abort if build() returned false\r\n if (built === false) {\r\n return;\r\n }\r\n\r\n // dynamically build menu on invocation\r\n e.data = $.extend(true, {}, defaults, e.data, built || {});\r\n\r\n // abort if there are no items to display\r\n if (!e.data.items || $.isEmptyObject(e.data.items)) {\r\n // Note: jQuery captures and ignores errors from event handlers\r\n if (window.console) {\r\n (console.error || console.log).call(console, 'No items specified to show in contextMenu');\r\n }\r\n\r\n throw new Error('No Items specified');\r\n }\r\n\r\n // backreference for custom command type creation\r\n e.data.$trigger = $currentTrigger;\r\n\r\n op.create(e.data);\r\n }\r\n var showMenu = false;\r\n for (var item in e.data.items) {\r\n if (e.data.items.hasOwnProperty(item)) {\r\n var visible;\r\n if ($.isFunction(e.data.items[item].visible)) {\r\n visible = e.data.items[item].visible.call($(e.currentTarget), item, e.data);\r\n } else if (typeof e.data.items[item] !== 'undefined' && e.data.items[item].visible) {\r\n visible = e.data.items[item].visible === true;\r\n } else {\r\n visible = true;\r\n }\r\n if (visible) {\r\n showMenu = true;\r\n }\r\n }\r\n }\r\n if (showMenu) {\r\n // show menu\r\n op.show.call($this, e.data, e.pageX, e.pageY);\r\n }\r\n }\r\n },\r\n // contextMenu left-click trigger\r\n click: function (e) {\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n $(this).trigger($.Event('contextmenu', {data: e.data, pageX: e.pageX, pageY: e.pageY}));\r\n },\r\n // contextMenu right-click trigger\r\n mousedown: function (e) {\r\n // register mouse down\r\n var $this = $(this);\r\n\r\n // hide any previous menus\r\n if ($currentTrigger && $currentTrigger.length && !$currentTrigger.is($this)) {\r\n $currentTrigger.data('contextMenu').$menu.trigger('contextmenu:hide');\r\n }\r\n\r\n // activate on right click\r\n if (e.button === 2) {\r\n $currentTrigger = $this.data('contextMenuActive', true);\r\n }\r\n },\r\n // contextMenu right-click trigger\r\n mouseup: function (e) {\r\n // show menu\r\n var $this = $(this);\r\n if ($this.data('contextMenuActive') && $currentTrigger && $currentTrigger.length && $currentTrigger.is($this) && !$this.hasClass('context-menu-disabled')) {\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n $currentTrigger = $this;\r\n $this.trigger($.Event('contextmenu', {data: e.data, pageX: e.pageX, pageY: e.pageY}));\r\n }\r\n\r\n $this.removeData('contextMenuActive');\r\n },\r\n // contextMenu hover trigger\r\n mouseenter: function (e) {\r\n var $this = $(this),\r\n $related = $(e.relatedTarget),\r\n $document = $(document);\r\n\r\n // abort if we're coming from a menu\r\n if ($related.is('.context-menu-list') || $related.closest('.context-menu-list').length) {\r\n return;\r\n }\r\n\r\n // abort if a menu is shown\r\n if ($currentTrigger && $currentTrigger.length) {\r\n return;\r\n }\r\n\r\n hoveract.pageX = e.pageX;\r\n hoveract.pageY = e.pageY;\r\n hoveract.data = e.data;\r\n $document.on('mousemove.contextMenuShow', handle.mousemove);\r\n hoveract.timer = setTimeout(function () {\r\n hoveract.timer = null;\r\n $document.off('mousemove.contextMenuShow');\r\n $currentTrigger = $this;\r\n $this.trigger($.Event('contextmenu', {\r\n data: hoveract.data,\r\n pageX: hoveract.pageX,\r\n pageY: hoveract.pageY\r\n }));\r\n }, e.data.delay);\r\n },\r\n // contextMenu hover trigger\r\n mousemove: function (e) {\r\n hoveract.pageX = e.pageX;\r\n hoveract.pageY = e.pageY;\r\n },\r\n // contextMenu hover trigger\r\n mouseleave: function (e) {\r\n // abort if we're leaving for a menu\r\n var $related = $(e.relatedTarget);\r\n if ($related.is('.context-menu-list') || $related.closest('.context-menu-list').length) {\r\n return;\r\n }\r\n\r\n try {\r\n clearTimeout(hoveract.timer);\r\n } catch (e) {\r\n }\r\n\r\n hoveract.timer = null;\r\n },\r\n // click on layer to hide contextMenu\r\n layerClick: function (e) {\r\n var $this = $(this),\r\n root = $this.data('contextMenuRoot'),\r\n button = e.button,\r\n x = e.pageX,\r\n y = e.pageY,\r\n target,\r\n offset;\r\n\r\n e.preventDefault();\r\n\r\n setTimeout(function () {\r\n var $window;\r\n var triggerAction = ((root.trigger === 'left' && button === 0) || (root.trigger === 'right' && button === 2));\r\n\r\n // find the element that would've been clicked, wasn't the layer in the way\r\n if (document.elementFromPoint && root.$layer) {\r\n root.$layer.hide();\r\n target = document.elementFromPoint(x - $win.scrollLeft(), y - $win.scrollTop());\r\n\r\n // also need to try and focus this element if we're in a contenteditable area,\r\n // as the layer will prevent the browser mouse action we want\r\n if (target.isContentEditable) {\r\n var range = document.createRange(),\r\n sel = window.getSelection();\r\n range.selectNode(target);\r\n range.collapse(true);\r\n sel.removeAllRanges();\r\n sel.addRange(range);\r\n }\r\n $(target).trigger(e);\r\n root.$layer.show();\r\n }\r\n \r\n if (root.hideOnSecondTrigger && triggerAction && root.$menu !== null && typeof root.$menu !== 'undefined') {\r\n root.$menu.trigger('contextmenu:hide');\r\n return;\r\n }\r\n \r\n if (root.reposition && triggerAction) {\r\n if (document.elementFromPoint) {\r\n if (root.$trigger.is(target)) {\r\n root.position.call(root.$trigger, root, x, y);\r\n return;\r\n }\r\n } else {\r\n offset = root.$trigger.offset();\r\n $window = $(window);\r\n // while this looks kinda awful, it's the best way to avoid\r\n // unnecessarily calculating any positions\r\n offset.top += $window.scrollTop();\r\n if (offset.top <= e.pageY) {\r\n offset.left += $window.scrollLeft();\r\n if (offset.left <= e.pageX) {\r\n offset.bottom = offset.top + root.$trigger.outerHeight();\r\n if (offset.bottom >= e.pageY) {\r\n offset.right = offset.left + root.$trigger.outerWidth();\r\n if (offset.right >= e.pageX) {\r\n // reposition\r\n root.position.call(root.$trigger, root, x, y);\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (target && triggerAction) {\r\n root.$trigger.one('contextmenu:hidden', function () {\r\n $(target).contextMenu({x: x, y: y, button: button});\r\n });\r\n }\r\n\r\n if (root !== null && typeof root !== 'undefined' && root.$menu !== null && typeof root.$menu !== 'undefined') {\r\n root.$menu.trigger('contextmenu:hide');\r\n }\r\n }, 50);\r\n },\r\n // key handled :hover\r\n keyStop: function (e, opt) {\r\n if (!opt.isInput) {\r\n e.preventDefault();\r\n }\r\n\r\n e.stopPropagation();\r\n },\r\n key: function (e) {\r\n\r\n var opt = {};\r\n\r\n // Only get the data from $currentTrigger if it exists\r\n if ($currentTrigger) {\r\n opt = $currentTrigger.data('contextMenu') || {};\r\n }\r\n // If the trigger happen on a element that are above the contextmenu do this\r\n if (typeof opt.zIndex === 'undefined') {\r\n opt.zIndex = 0;\r\n }\r\n var targetZIndex = 0;\r\n var getZIndexOfTriggerTarget = function (target) {\r\n if (target.style.zIndex !== '') {\r\n targetZIndex = target.style.zIndex;\r\n } else {\r\n if (target.offsetParent !== null && typeof target.offsetParent !== 'undefined') {\r\n getZIndexOfTriggerTarget(target.offsetParent);\r\n }\r\n else if (target.parentElement !== null && typeof target.parentElement !== 'undefined') {\r\n getZIndexOfTriggerTarget(target.parentElement);\r\n }\r\n }\r\n };\r\n getZIndexOfTriggerTarget(e.target);\r\n // If targetZIndex is heigher then opt.zIndex dont progress any futher.\r\n // This is used to make sure that if you are using a dialog with a input / textarea / contenteditable div\r\n // and its above the contextmenu it wont steal keys events\r\n if (opt.$menu && parseInt(targetZIndex,10) > parseInt(opt.$menu.css(\"zIndex\"),10)) {\r\n return;\r\n }\r\n switch (e.keyCode) {\r\n case 9:\r\n case 38: // up\r\n handle.keyStop(e, opt);\r\n // if keyCode is [38 (up)] or [9 (tab) with shift]\r\n if (opt.isInput) {\r\n if (e.keyCode === 9 && e.shiftKey) {\r\n e.preventDefault();\r\n if (opt.$selected) {\r\n opt.$selected.find('input, textarea, select').blur();\r\n }\r\n if (opt.$menu !== null && typeof opt.$menu !== 'undefined') {\r\n opt.$menu.trigger('prevcommand');\r\n }\r\n return;\r\n } else if (e.keyCode === 38 && opt.$selected.find('input, textarea, select').prop('type') === 'checkbox') {\r\n // checkboxes don't capture this key\r\n e.preventDefault();\r\n return;\r\n }\r\n } else if (e.keyCode !== 9 || e.shiftKey) {\r\n if (opt.$menu !== null && typeof opt.$menu !== 'undefined') {\r\n opt.$menu.trigger('prevcommand');\r\n }\r\n return;\r\n }\r\n break;\r\n // omitting break;\r\n // case 9: // tab - reached through omitted break;\r\n case 40: // down\r\n handle.keyStop(e, opt);\r\n if (opt.isInput) {\r\n if (e.keyCode === 9) {\r\n e.preventDefault();\r\n if (opt.$selected) {\r\n opt.$selected.find('input, textarea, select').blur();\r\n }\r\n if (opt.$menu !== null && typeof opt.$menu !== 'undefined') {\r\n opt.$menu.trigger('nextcommand');\r\n }\r\n return;\r\n } else if (e.keyCode === 40 && opt.$selected.find('input, textarea, select').prop('type') === 'checkbox') {\r\n // checkboxes don't capture this key\r\n e.preventDefault();\r\n return;\r\n }\r\n } else {\r\n if (opt.$menu !== null && typeof opt.$menu !== 'undefined') {\r\n opt.$menu.trigger('nextcommand');\r\n }\r\n return;\r\n }\r\n break;\r\n\r\n case 37: // left\r\n handle.keyStop(e, opt);\r\n if (opt.isInput || !opt.$selected || !opt.$selected.length) {\r\n break;\r\n }\r\n\r\n if (!opt.$selected.parent().hasClass('context-menu-root')) {\r\n var $parent = opt.$selected.parent().parent();\r\n opt.$selected.trigger('contextmenu:blur');\r\n opt.$selected = $parent;\r\n return;\r\n }\r\n break;\r\n\r\n case 39: // right\r\n handle.keyStop(e, opt);\r\n if (opt.isInput || !opt.$selected || !opt.$selected.length) {\r\n break;\r\n }\r\n\r\n var itemdata = opt.$selected.data('contextMenu') || {};\r\n if (itemdata.$menu && opt.$selected.hasClass('context-menu-submenu')) {\r\n opt.$selected = null;\r\n itemdata.$selected = null;\r\n itemdata.$menu.trigger('nextcommand');\r\n return;\r\n }\r\n break;\r\n\r\n case 35: // end\r\n case 36: // home\r\n if (opt.$selected && opt.$selected.find('input, textarea, select').length) {\r\n return;\r\n } else {\r\n (opt.$selected && opt.$selected.parent() || opt.$menu)\r\n .children(':not(.' + opt.classNames.disabled + ', .' + opt.classNames.notSelectable + ')')[e.keyCode === 36 ? 'first' : 'last']()\r\n .trigger('contextmenu:focus');\r\n e.preventDefault();\r\n return;\r\n }\r\n break;\r\n\r\n case 13: // enter\r\n handle.keyStop(e, opt);\r\n if (opt.isInput) {\r\n if (opt.$selected && !opt.$selected.is('textarea, select')) {\r\n e.preventDefault();\r\n return;\r\n }\r\n break;\r\n }\r\n if (typeof opt.$selected !== 'undefined' && opt.$selected !== null) {\r\n opt.$selected.trigger('mouseup');\r\n }\r\n return;\r\n\r\n case 32: // space\r\n case 33: // page up\r\n case 34: // page down\r\n // prevent browser from scrolling down while menu is visible\r\n handle.keyStop(e, opt);\r\n return;\r\n\r\n case 27: // esc\r\n handle.keyStop(e, opt);\r\n if (opt.$menu !== null && typeof opt.$menu !== 'undefined') {\r\n opt.$menu.trigger('contextmenu:hide');\r\n }\r\n return;\r\n\r\n default: // 0-9, a-z\r\n var k = (String.fromCharCode(e.keyCode)).toUpperCase();\r\n if (opt.accesskeys && opt.accesskeys[k]) {\r\n // according to the specs accesskeys must be invoked immediately\r\n opt.accesskeys[k].$node.trigger(opt.accesskeys[k].$menu ? 'contextmenu:focus' : 'mouseup');\r\n return;\r\n }\r\n break;\r\n }\r\n // pass event to selected item,\r\n // stop propagation to avoid endless recursion\r\n e.stopPropagation();\r\n if (typeof opt.$selected !== 'undefined' && opt.$selected !== null) {\r\n opt.$selected.trigger(e);\r\n }\r\n },\r\n // select previous possible command in menu\r\n prevItem: function (e) {\r\n e.stopPropagation();\r\n var opt = $(this).data('contextMenu') || {};\r\n var root = $(this).data('contextMenuRoot') || {};\r\n\r\n // obtain currently selected menu\r\n if (opt.$selected) {\r\n var $s = opt.$selected;\r\n opt = opt.$selected.parent().data('contextMenu') || {};\r\n opt.$selected = $s;\r\n }\r\n\r\n var $children = opt.$menu.children(),\r\n $prev = !opt.$selected || !opt.$selected.prev().length ? $children.last() : opt.$selected.prev(),\r\n $round = $prev;\r\n\r\n // skip disabled or hidden elements\r\n while ($prev.hasClass(root.classNames.disabled) || $prev.hasClass(root.classNames.notSelectable) || $prev.is(':hidden')) {\r\n if ($prev.prev().length) {\r\n $prev = $prev.prev();\r\n } else {\r\n $prev = $children.last();\r\n }\r\n if ($prev.is($round)) {\r\n // break endless loop\r\n return;\r\n }\r\n }\r\n\r\n // leave current\r\n if (opt.$selected) {\r\n handle.itemMouseleave.call(opt.$selected.get(0), e);\r\n }\r\n\r\n // activate next\r\n handle.itemMouseenter.call($prev.get(0), e);\r\n\r\n // focus input\r\n var $input = $prev.find('input, textarea, select');\r\n if ($input.length) {\r\n $input.focus();\r\n }\r\n },\r\n // select next possible command in menu\r\n nextItem: function (e) {\r\n e.stopPropagation();\r\n var opt = $(this).data('contextMenu') || {};\r\n var root = $(this).data('contextMenuRoot') || {};\r\n\r\n // obtain currently selected menu\r\n if (opt.$selected) {\r\n var $s = opt.$selected;\r\n opt = opt.$selected.parent().data('contextMenu') || {};\r\n opt.$selected = $s;\r\n }\r\n\r\n var $children = opt.$menu.children(),\r\n $next = !opt.$selected || !opt.$selected.next().length ? $children.first() : opt.$selected.next(),\r\n $round = $next;\r\n\r\n // skip disabled\r\n while ($next.hasClass(root.classNames.disabled) || $next.hasClass(root.classNames.notSelectable) || $next.is(':hidden')) {\r\n if ($next.next().length) {\r\n $next = $next.next();\r\n } else {\r\n $next = $children.first();\r\n }\r\n if ($next.is($round)) {\r\n // break endless loop\r\n return;\r\n }\r\n }\r\n\r\n // leave current\r\n if (opt.$selected) {\r\n handle.itemMouseleave.call(opt.$selected.get(0), e);\r\n }\r\n\r\n // activate next\r\n handle.itemMouseenter.call($next.get(0), e);\r\n\r\n // focus input\r\n var $input = $next.find('input, textarea, select');\r\n if ($input.length) {\r\n $input.focus();\r\n }\r\n },\r\n // flag that we're inside an input so the key handler can act accordingly\r\n focusInput: function () {\r\n var $this = $(this).closest('.context-menu-item'),\r\n data = $this.data(),\r\n opt = data.contextMenu,\r\n root = data.contextMenuRoot;\r\n\r\n root.$selected = opt.$selected = $this;\r\n root.isInput = opt.isInput = true;\r\n },\r\n // flag that we're inside an input so the key handler can act accordingly\r\n blurInput: function () {\r\n var $this = $(this).closest('.context-menu-item'),\r\n data = $this.data(),\r\n opt = data.contextMenu,\r\n root = data.contextMenuRoot;\r\n\r\n root.isInput = opt.isInput = false;\r\n },\r\n // :hover on menu\r\n menuMouseenter: function () {\r\n var root = $(this).data().contextMenuRoot;\r\n root.hovering = true;\r\n },\r\n // :hover on menu\r\n menuMouseleave: function (e) {\r\n var root = $(this).data().contextMenuRoot;\r\n if (root.$layer && root.$layer.is(e.relatedTarget)) {\r\n root.hovering = false;\r\n }\r\n },\r\n // :hover done manually so key handling is possible\r\n itemMouseenter: function (e) {\r\n var $this = $(this),\r\n data = $this.data(),\r\n opt = data.contextMenu,\r\n root = data.contextMenuRoot;\r\n\r\n root.hovering = true;\r\n\r\n // abort if we're re-entering\r\n if (e && root.$layer && root.$layer.is(e.relatedTarget)) {\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n }\r\n\r\n // make sure only one item is selected\r\n (opt.$menu ? opt : root).$menu\r\n .children('.' + root.classNames.hover).trigger('contextmenu:blur')\r\n .children('.hover').trigger('contextmenu:blur');\r\n\r\n if ($this.hasClass(root.classNames.disabled) || $this.hasClass(root.classNames.notSelectable)) {\r\n opt.$selected = null;\r\n return;\r\n }\r\n\r\n\r\n $this.trigger('contextmenu:focus');\r\n },\r\n // :hover done manually so key handling is possible\r\n itemMouseleave: function (e) {\r\n var $this = $(this),\r\n data = $this.data(),\r\n opt = data.contextMenu,\r\n root = data.contextMenuRoot;\r\n\r\n if (root !== opt && root.$layer && root.$layer.is(e.relatedTarget)) {\r\n if (typeof root.$selected !== 'undefined' && root.$selected !== null) {\r\n root.$selected.trigger('contextmenu:blur');\r\n }\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n root.$selected = opt.$selected = opt.$node;\r\n return;\r\n }\r\n\r\n if(opt && opt.$menu && opt.$menu.hasClass('context-menu-visible')){\r\n return;\r\n }\r\n\r\n $this.trigger('contextmenu:blur');\r\n },\r\n // contextMenu item click\r\n itemClick: function (e) {\r\n var $this = $(this),\r\n data = $this.data(),\r\n opt = data.contextMenu,\r\n root = data.contextMenuRoot,\r\n key = data.contextMenuKey,\r\n callback;\r\n\r\n // abort if the key is unknown or disabled or is a menu\r\n if (!opt.items[key] || $this.is('.' + root.classNames.disabled + ', .context-menu-separator, .' + root.classNames.notSelectable) || ($this.is('.context-menu-submenu') && root.selectableSubMenu === false )) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n e.stopImmediatePropagation();\r\n\r\n if ($.isFunction(opt.callbacks[key]) && Object.prototype.hasOwnProperty.call(opt.callbacks, key)) {\r\n // item-specific callback\r\n callback = opt.callbacks[key];\r\n } else if ($.isFunction(root.callback)) {\r\n // default callback\r\n callback = root.callback;\r\n } else {\r\n // no callback, no action\r\n return;\r\n }\r\n\r\n // hide menu if callback doesn't stop that\r\n if (callback.call(root.$trigger, key, root, e) !== false) {\r\n root.$menu.trigger('contextmenu:hide');\r\n } else if (root.$menu.parent().length) {\r\n op.update.call(root.$trigger, root);\r\n }\r\n },\r\n // ignore click events on input elements\r\n inputClick: function (e) {\r\n e.stopImmediatePropagation();\r\n },\r\n // hide \r\n hideMenu: function (e, data) {\r\n var root = $(this).data('contextMenuRoot');\r\n op.hide.call(root.$trigger, root, data && data.force);\r\n },\r\n // focus \r\n focusItem: function (e) {\r\n e.stopPropagation();\r\n var $this = $(this),\r\n data = $this.data(),\r\n opt = data.contextMenu,\r\n root = data.contextMenuRoot;\r\n\r\n if ($this.hasClass(root.classNames.disabled) || $this.hasClass(root.classNames.notSelectable)) {\r\n return;\r\n }\r\n\r\n $this\r\n .addClass([root.classNames.hover, root.classNames.visible].join(' '))\r\n // select other items and included items\r\n .parent().find('.context-menu-item').not($this)\r\n .removeClass(root.classNames.visible)\r\n .filter('.' + root.classNames.hover)\r\n .trigger('contextmenu:blur');\r\n\r\n // remember selected\r\n opt.$selected = root.$selected = $this;\r\n\r\n\r\n if(opt && opt.$node && opt.$node.hasClass('context-menu-submenu')){\r\n opt.$node.addClass(root.classNames.hover);\r\n }\r\n\r\n // position sub-menu - do after show so dumb $.ui.position can keep up\r\n if (opt.$node) {\r\n root.positionSubmenu.call(opt.$node, opt.$menu);\r\n }\r\n },\r\n // blur \r\n blurItem: function (e) {\r\n e.stopPropagation();\r\n var $this = $(this),\r\n data = $this.data(),\r\n opt = data.contextMenu,\r\n root = data.contextMenuRoot;\r\n\r\n if (opt.autoHide) { // for tablets and touch screens this needs to remain\r\n $this.removeClass(root.classNames.visible);\r\n }\r\n $this.removeClass(root.classNames.hover);\r\n opt.$selected = null;\r\n }\r\n },\r\n // operations\r\n op = {\r\n show: function (opt, x, y) {\r\n var $trigger = $(this),\r\n css = {};\r\n\r\n // hide any open menus\r\n $('#context-menu-layer').trigger('mousedown');\r\n\r\n // backreference for callbacks\r\n opt.$trigger = $trigger;\r\n\r\n // show event\r\n if (opt.events.show.call($trigger, opt) === false) {\r\n $currentTrigger = null;\r\n return;\r\n }\r\n\r\n // create or update context menu\r\n op.update.call($trigger, opt);\r\n\r\n // position menu\r\n opt.position.call($trigger, opt, x, y);\r\n\r\n // make sure we're in front\r\n if (opt.zIndex) {\r\n var additionalZValue = opt.zIndex;\r\n // If opt.zIndex is a function, call the function to get the right zIndex.\r\n if (typeof opt.zIndex === 'function') {\r\n additionalZValue = opt.zIndex.call($trigger, opt);\r\n }\r\n css.zIndex = zindex($trigger) + additionalZValue;\r\n }\r\n\r\n // add layer\r\n op.layer.call(opt.$menu, opt, css.zIndex);\r\n\r\n // adjust sub-menu zIndexes\r\n opt.$menu.find('ul').css('zIndex', css.zIndex + 1);\r\n\r\n // position and show context menu\r\n opt.$menu.css(css)[opt.animation.show](opt.animation.duration, function () {\r\n $trigger.trigger('contextmenu:visible');\r\n \r\n op.activated(opt);\r\n opt.events.activated(opt);\r\n });\r\n // make options available and set state\r\n $trigger\r\n .data('contextMenu', opt)\r\n .addClass('context-menu-active');\r\n\r\n // register key handler\r\n $(document).off('keydown.contextMenu').on('keydown.contextMenu', handle.key);\r\n // register autoHide handler\r\n if (opt.autoHide) {\r\n // mouse position handler\r\n $(document).on('mousemove.contextMenuAutoHide', function (e) {\r\n // need to capture the offset on mousemove,\r\n // since the page might've been scrolled since activation\r\n var pos = $trigger.offset();\r\n pos.right = pos.left + $trigger.outerWidth();\r\n pos.bottom = pos.top + $trigger.outerHeight();\r\n\r\n if (opt.$layer && !opt.hovering && (!(e.pageX >= pos.left && e.pageX <= pos.right) || !(e.pageY >= pos.top && e.pageY <= pos.bottom))) {\r\n /* Additional hover check after short time, you might just miss the edge of the menu */\r\n setTimeout(function () {\r\n if (!opt.hovering && opt.$menu !== null && typeof opt.$menu !== 'undefined') {\r\n opt.$menu.trigger('contextmenu:hide');\r\n }\r\n }, 50);\r\n }\r\n });\r\n }\r\n },\r\n hide: function (opt, force) {\r\n var $trigger = $(this);\r\n if (!opt) {\r\n opt = $trigger.data('contextMenu') || {};\r\n }\r\n\r\n // hide event\r\n if (!force && opt.events && opt.events.hide.call($trigger, opt) === false) {\r\n return;\r\n }\r\n\r\n // remove options and revert state\r\n $trigger\r\n .removeData('contextMenu')\r\n .removeClass('context-menu-active');\r\n\r\n if (opt.$layer) {\r\n // keep layer for a bit so the contextmenu event can be aborted properly by opera\r\n setTimeout((function ($layer) {\r\n return function () {\r\n $layer.remove();\r\n };\r\n })(opt.$layer), 10);\r\n\r\n try {\r\n delete opt.$layer;\r\n } catch (e) {\r\n opt.$layer = null;\r\n }\r\n }\r\n\r\n // remove handle\r\n $currentTrigger = null;\r\n // remove selected\r\n opt.$menu.find('.' + opt.classNames.hover).trigger('contextmenu:blur');\r\n opt.$selected = null;\r\n // collapse all submenus\r\n opt.$menu.find('.' + opt.classNames.visible).removeClass(opt.classNames.visible);\r\n // unregister key and mouse handlers\r\n // $(document).off('.contextMenuAutoHide keydown.contextMenu'); // http://bugs.jquery.com/ticket/10705\r\n $(document).off('.contextMenuAutoHide').off('keydown.contextMenu');\r\n // hide menu\r\n if (opt.$menu) {\r\n opt.$menu[opt.animation.hide](opt.animation.duration, function () {\r\n // tear down dynamically built menu after animation is completed.\r\n if (opt.build) {\r\n opt.$menu.remove();\r\n $.each(opt, function (key) {\r\n switch (key) {\r\n case 'ns':\r\n case 'selector':\r\n case 'build':\r\n case 'trigger':\r\n return true;\r\n\r\n default:\r\n opt[key] = undefined;\r\n try {\r\n delete opt[key];\r\n } catch (e) {\r\n }\r\n return true;\r\n }\r\n });\r\n }\r\n\r\n setTimeout(function () {\r\n $trigger.trigger('contextmenu:hidden');\r\n }, 10);\r\n });\r\n }\r\n },\r\n create: function (opt, root) {\r\n if (typeof root === 'undefined') {\r\n root = opt;\r\n }\r\n\r\n // create contextMenu\r\n opt.$menu = $('
      ').addClass(opt.className || '').data({\r\n 'contextMenu': opt,\r\n 'contextMenuRoot': root\r\n });\r\n\r\n $.each(['callbacks', 'commands', 'inputs'], function (i, k) {\r\n opt[k] = {};\r\n if (!root[k]) {\r\n root[k] = {};\r\n }\r\n });\r\n\r\n if (!root.accesskeys) {\r\n root.accesskeys = {};\r\n }\r\n\r\n function createNameNode(item) {\r\n var $name = $('');\r\n if (item._accesskey) {\r\n if (item._beforeAccesskey) {\r\n $name.append(document.createTextNode(item._beforeAccesskey));\r\n }\r\n $('')\r\n .addClass('context-menu-accesskey')\r\n .text(item._accesskey)\r\n .appendTo($name);\r\n if (item._afterAccesskey) {\r\n $name.append(document.createTextNode(item._afterAccesskey));\r\n }\r\n } else {\r\n if (item.isHtmlName) {\r\n // restrict use with access keys\r\n if (typeof item.accesskey !== 'undefined') {\r\n throw new Error('accesskeys are not compatible with HTML names and cannot be used together in the same item');\r\n }\r\n $name.html(item.name);\r\n } else {\r\n $name.text(item.name);\r\n }\r\n }\r\n return $name;\r\n }\r\n\r\n // create contextMenu items\r\n $.each(opt.items, function (key, item) {\r\n var $t = $('
    • ').addClass(item.className || ''),\r\n $label = null,\r\n $input = null;\r\n\r\n // iOS needs to see a click-event bound to an element to actually\r\n // have the TouchEvents infrastructure trigger the click event\r\n $t.on('click', $.noop);\r\n\r\n // Make old school string seperator a real item so checks wont be\r\n // akward later.\r\n // And normalize 'cm_separator' into 'cm_seperator'.\r\n if (typeof item === 'string' || item.type === 'cm_separator') {\r\n item = {type: 'cm_seperator'};\r\n }\r\n\r\n item.$node = $t.data({\r\n 'contextMenu': opt,\r\n 'contextMenuRoot': root,\r\n 'contextMenuKey': key\r\n });\r\n\r\n // register accesskey\r\n // NOTE: the accesskey attribute should be applicable to any element, but Safari5 and Chrome13 still can't do that\r\n if (typeof item.accesskey !== 'undefined') {\r\n var aks = splitAccesskey(item.accesskey);\r\n for (var i = 0, ak; ak = aks[i]; i++) {\r\n if (!root.accesskeys[ak]) {\r\n root.accesskeys[ak] = item;\r\n var matched = item.name.match(new RegExp('^(.*?)(' + ak + ')(.*)$', 'i'));\r\n if (matched) {\r\n item._beforeAccesskey = matched[1];\r\n item._accesskey = matched[2];\r\n item._afterAccesskey = matched[3];\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (item.type && types[item.type]) {\r\n // run custom type handler\r\n types[item.type].call($t, item, opt, root);\r\n // register commands\r\n $.each([opt, root], function (i, k) {\r\n k.commands[key] = item;\r\n // Overwrite only if undefined or the item is appended to the root. This so it\r\n // doesn't overwrite callbacks of root elements if the name is the same.\r\n if ($.isFunction(item.callback) && (typeof k.callbacks[key] === 'undefined' || typeof opt.type === 'undefined')) {\r\n k.callbacks[key] = item.callback;\r\n }\r\n });\r\n } else {\r\n // add label for input\r\n if (item.type === 'cm_seperator') {\r\n $t.addClass('context-menu-separator ' + root.classNames.notSelectable);\r\n } else if (item.type === 'html') {\r\n $t.addClass('context-menu-html ' + root.classNames.notSelectable);\r\n } else if (item.type === 'sub') {\r\n // We don't want to execute the next else-if if it is a sub.\r\n } else if (item.type) {\r\n $label = $('').appendTo($t);\r\n createNameNode(item).appendTo($label);\r\n\r\n $t.addClass('context-menu-input');\r\n opt.hasTypes = true;\r\n $.each([opt, root], function (i, k) {\r\n k.commands[key] = item;\r\n k.inputs[key] = item;\r\n });\r\n } else if (item.items) {\r\n item.type = 'sub';\r\n }\r\n\r\n switch (item.type) {\r\n case 'cm_seperator':\r\n break;\r\n\r\n case 'text':\r\n $input = $('')\r\n .attr('name', 'context-menu-input-' + key)\r\n .val(item.value || '')\r\n .appendTo($label);\r\n break;\r\n\r\n case 'textarea':\r\n $input = $('')\r\n .attr('name', 'context-menu-input-' + key)\r\n .val(item.value || '')\r\n .appendTo($label);\r\n\r\n if (item.height) {\r\n $input.height(item.height);\r\n }\r\n break;\r\n\r\n case 'checkbox':\r\n $input = $('')\r\n .attr('name', 'context-menu-input-' + key)\r\n .val(item.value || '')\r\n .prop('checked', !!item.selected)\r\n .prependTo($label);\r\n break;\r\n\r\n case 'radio':\r\n $input = $('')\r\n .attr('name', 'context-menu-input-' + item.radio)\r\n .val(item.value || '')\r\n .prop('checked', !!item.selected)\r\n .prependTo($label);\r\n break;\r\n\r\n case 'select':\r\n $input = $('')\r\n .attr('name', 'context-menu-input-' + key)\r\n .appendTo($label);\r\n if (item.options) {\r\n $.each(item.options, function (value, text) {\r\n $('').val(value).text(text).appendTo($input);\r\n });\r\n $input.val(item.selected);\r\n }\r\n break;\r\n\r\n case 'sub':\r\n createNameNode(item).appendTo($t);\r\n item.appendTo = item.$node;\r\n $t.data('contextMenu', item).addClass('context-menu-submenu');\r\n item.callback = null;\r\n\r\n // If item contains items, and this is a promise, we should create it later\r\n // check if subitems is of type promise. If it is a promise we need to create\r\n // it later, after promise has been resolved.\r\n if ('function' === typeof item.items.then) {\r\n // probably a promise, process it, when completed it will create the sub menu's.\r\n op.processPromises(item, root, item.items);\r\n } else {\r\n // normal submenu.\r\n op.create(item, root);\r\n }\r\n break;\r\n\r\n case 'html':\r\n $(item.html).appendTo($t);\r\n break;\r\n\r\n default:\r\n $.each([opt, root], function (i, k) {\r\n k.commands[key] = item;\r\n // Overwrite only if undefined or the item is appended to the root. This so it\r\n // doesn't overwrite callbacks of root elements if the name is the same.\r\n if ($.isFunction(item.callback) && (typeof k.callbacks[key] === 'undefined' || typeof opt.type === 'undefined')) {\r\n k.callbacks[key] = item.callback;\r\n }\r\n });\r\n createNameNode(item).appendTo($t);\r\n break;\r\n }\r\n\r\n // disable key listener in \r\n if (item.type && item.type !== 'sub' && item.type !== 'html' && item.type !== 'cm_seperator') {\r\n $input\r\n .on('focus', handle.focusInput)\r\n .on('blur', handle.blurInput);\r\n\r\n if (item.events) {\r\n $input.on(item.events, opt);\r\n }\r\n }\r\n\r\n // add icons\r\n if (item.icon) {\r\n if ($.isFunction(item.icon)) {\r\n item._icon = item.icon.call(this, this, $t, key, item);\r\n } else {\r\n if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {\r\n // to enable font awesome\r\n item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;\r\n } else {\r\n item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;\r\n }\r\n }\r\n $t.addClass(item._icon);\r\n }\r\n }\r\n\r\n // cache contained elements\r\n item.$input = $input;\r\n item.$label = $label;\r\n\r\n // attach item to menu\r\n $t.appendTo(opt.$menu);\r\n\r\n // Disable text selection\r\n if (!opt.hasTypes && $.support.eventSelectstart) {\r\n // browsers support user-select: none,\r\n // IE has a special event for text-selection\r\n // browsers supporting neither will not be preventing text-selection\r\n $t.on('selectstart.disableTextSelect', handle.abortevent);\r\n }\r\n });\r\n // attach contextMenu to (to bypass any possible overflow:hidden issues on parents of the trigger element)\r\n if (!opt.$node) {\r\n opt.$menu.css('display', 'none').addClass('context-menu-root');\r\n }\r\n opt.$menu.appendTo(opt.appendTo || document.body);\r\n },\r\n resize: function ($menu, nested) {\r\n var domMenu;\r\n // determine widths of submenus, as CSS won't grow them automatically\r\n // position:absolute within position:absolute; min-width:100; max-width:200; results in width: 100;\r\n // kinda sucks hard...\r\n\r\n // determine width of absolutely positioned element\r\n $menu.css({position: 'absolute', display: 'block'});\r\n // don't apply yet, because that would break nested elements' widths\r\n $menu.data('width',\r\n (domMenu = $menu.get(0)).getBoundingClientRect ?\r\n Math.ceil(domMenu.getBoundingClientRect().width) :\r\n $menu.outerWidth() + 1); // outerWidth() returns rounded pixels\r\n // reset styles so they allow nested elements to grow/shrink naturally\r\n $menu.css({\r\n position: 'static',\r\n minWidth: '0px',\r\n maxWidth: '100000px'\r\n });\r\n // identify width of nested menus\r\n $menu.find('> li > ul').each(function () {\r\n op.resize($(this), true);\r\n });\r\n // reset and apply changes in the end because nested\r\n // elements' widths wouldn't be calculatable otherwise\r\n if (!nested) {\r\n $menu.find('ul').addBack().css({\r\n position: '',\r\n display: '',\r\n minWidth: '',\r\n maxWidth: ''\r\n }).outerWidth(function () {\r\n return $(this).data('width');\r\n });\r\n }\r\n },\r\n update: function (opt, root) {\r\n var $trigger = this;\r\n if (typeof root === 'undefined') {\r\n root = opt;\r\n op.resize(opt.$menu);\r\n }\r\n // re-check disabled for each item\r\n opt.$menu.children().each(function () {\r\n var $item = $(this),\r\n key = $item.data('contextMenuKey'),\r\n item = opt.items[key],\r\n disabled = ($.isFunction(item.disabled) && item.disabled.call($trigger, key, root)) || item.disabled === true,\r\n visible;\r\n if ($.isFunction(item.visible)) {\r\n visible = item.visible.call($trigger, key, root);\r\n } else if (typeof item.visible !== 'undefined') {\r\n visible = item.visible === true;\r\n } else {\r\n visible = true;\r\n }\r\n $item[visible ? 'show' : 'hide']();\r\n\r\n // dis- / enable item\r\n $item[disabled ? 'addClass' : 'removeClass'](root.classNames.disabled);\r\n\r\n if ($.isFunction(item.icon)) {\r\n $item.removeClass(item._icon);\r\n item._icon = item.icon.call(this, $trigger, $item, key, item);\r\n $item.addClass(item._icon);\r\n }\r\n\r\n if (item.type) {\r\n // dis- / enable input elements\r\n $item.find('input, select, textarea').prop('disabled', disabled);\r\n\r\n // update input states\r\n switch (item.type) {\r\n case 'text':\r\n case 'textarea':\r\n item.$input.val(item.value || '');\r\n break;\r\n\r\n case 'checkbox':\r\n case 'radio':\r\n item.$input.val(item.value || '').prop('checked', !!item.selected);\r\n break;\r\n\r\n case 'select':\r\n item.$input.val((item.selected === 0 ? \"0\" : item.selected) || '');\r\n break;\r\n }\r\n }\r\n\r\n if (item.$menu) {\r\n // update sub-menu\r\n op.update.call($trigger, item, root);\r\n }\r\n });\r\n },\r\n layer: function (opt, zIndex) {\r\n // add transparent layer for click area\r\n // filter and background for Internet Explorer, Issue #23\r\n var $layer = opt.$layer = $('
      ')\r\n .css({\r\n height: $win.height(),\r\n width: $win.width(),\r\n display: 'block',\r\n position: 'fixed',\r\n 'z-index': zIndex,\r\n top: 0,\r\n left: 0,\r\n opacity: 0,\r\n filter: 'alpha(opacity=0)',\r\n 'background-color': '#000'\r\n })\r\n .data('contextMenuRoot', opt)\r\n .insertBefore(this)\r\n .on('contextmenu', handle.abortevent)\r\n .on('mousedown', handle.layerClick);\r\n\r\n // IE6 doesn't know position:fixed;\r\n if (typeof document.body.style.maxWidth === 'undefined') { // IE6 doesn't support maxWidth\r\n $layer.css({\r\n 'position': 'absolute',\r\n 'height': $(document).height()\r\n });\r\n }\r\n\r\n return $layer;\r\n },\r\n processPromises: function (opt, root, promise) {\r\n // Start\r\n opt.$node.addClass(root.classNames.iconLoadingClass);\r\n\r\n function completedPromise(opt, root, items) {\r\n // Completed promise (dev called promise.resolve). We now have a list of items which can\r\n // be used to create the rest of the context menu.\r\n if (typeof items === 'undefined') {\r\n // Null result, dev should have checked\r\n errorPromise(undefined);//own error object\r\n }\r\n finishPromiseProcess(opt, root, items);\r\n }\r\n\r\n function errorPromise(opt, root, errorItem) {\r\n // User called promise.reject() with an error item, if not, provide own error item.\r\n if (typeof errorItem === 'undefined') {\r\n errorItem = {\r\n \"error\": {\r\n name: \"No items and no error item\",\r\n icon: \"context-menu-icon context-menu-icon-quit\"\r\n }\r\n };\r\n if (window.console) {\r\n (console.error || console.log).call(console, 'When you reject a promise, provide an \"items\" object, equal to normal sub-menu items');\r\n }\r\n } else if (typeof errorItem === 'string') {\r\n errorItem = {\"error\": {name: errorItem}};\r\n }\r\n finishPromiseProcess(opt, root, errorItem);\r\n }\r\n\r\n function finishPromiseProcess(opt, root, items) {\r\n if (typeof root.$menu === 'undefined' || !root.$menu.is(':visible')) {\r\n return;\r\n }\r\n opt.$node.removeClass(root.classNames.iconLoadingClass);\r\n opt.items = items;\r\n op.create(opt, root, true); // Create submenu\r\n op.update(opt, root); // Correctly update position if user is already hovered over menu item\r\n root.positionSubmenu.call(opt.$node, opt.$menu); // positionSubmenu, will only do anything if user already hovered over menu item that just got new subitems.\r\n }\r\n\r\n // Wait for promise completion. .then(success, error, notify) (we don't track notify). Bind the opt\r\n // and root to avoid scope problems\r\n promise.then(completedPromise.bind(this, opt, root), errorPromise.bind(this, opt, root));\r\n },\r\n // operation that will run after contextMenu showed on screen\r\n activated: function(opt){\r\n var $menu = opt.$menu;\r\n var $menuOffset = $menu.offset();\r\n var winHeight = $(window).height();\r\n var winScrollTop = $(window).scrollTop();\r\n var menuHeight = $menu.height();\r\n if(menuHeight > winHeight){\r\n $menu.css({\r\n 'height' : winHeight + 'px',\r\n 'overflow-x': 'hidden',\r\n 'overflow-y': 'auto',\r\n 'top': winScrollTop + 'px'\r\n });\r\n } else if(($menuOffset.top < winScrollTop) || ($menuOffset.top + menuHeight > winScrollTop + winHeight)){\r\n $menu.css({\r\n 'top': '0px'\r\n });\r\n } \r\n }\r\n };\r\n\r\n // split accesskey according to http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#assigned-access-key\r\n function splitAccesskey(val) {\r\n var t = val.split(/\\s+/);\r\n var keys = [];\r\n\r\n for (var i = 0, k; k = t[i]; i++) {\r\n k = k.charAt(0).toUpperCase(); // first character only\r\n // theoretically non-accessible characters should be ignored, but different systems, different keyboard layouts, ... screw it.\r\n // a map to look up already used access keys would be nice\r\n keys.push(k);\r\n }\r\n\r\n return keys;\r\n }\r\n\r\n// handle contextMenu triggers\r\n $.fn.contextMenu = function (operation) {\r\n var $t = this, $o = operation;\r\n if (this.length > 0) { // this is not a build on demand menu\r\n if (typeof operation === 'undefined') {\r\n this.first().trigger('contextmenu');\r\n } else if (typeof operation.x !== 'undefined' && typeof operation.y !== 'undefined') {\r\n this.first().trigger($.Event('contextmenu', {\r\n pageX: operation.x,\r\n pageY: operation.y,\r\n mouseButton: operation.button\r\n }));\r\n } else if (operation === 'hide') {\r\n var $menu = this.first().data('contextMenu') ? this.first().data('contextMenu').$menu : null;\r\n if ($menu) {\r\n $menu.trigger('contextmenu:hide');\r\n }\r\n } else if (operation === 'destroy') {\r\n $.contextMenu('destroy', {context: this});\r\n } else if ($.isPlainObject(operation)) {\r\n operation.context = this;\r\n $.contextMenu('create', operation);\r\n } else if (operation) {\r\n this.removeClass('context-menu-disabled');\r\n } else if (!operation) {\r\n this.addClass('context-menu-disabled');\r\n }\r\n } else {\r\n $.each(menus, function () {\r\n if (this.selector === $t.selector) {\r\n $o.data = this;\r\n\r\n $.extend($o.data, {trigger: 'demand'});\r\n }\r\n });\r\n\r\n handle.contextmenu.call($o.target, $o);\r\n }\r\n\r\n return this;\r\n };\r\n\r\n // manage contextMenu instances\r\n $.contextMenu = function (operation, options) {\r\n if (typeof operation !== 'string') {\r\n options = operation;\r\n operation = 'create';\r\n }\r\n\r\n if (typeof options === 'string') {\r\n options = {selector: options};\r\n } else if (typeof options === 'undefined') {\r\n options = {};\r\n }\r\n\r\n // merge with default options\r\n var o = $.extend(true, {}, defaults, options || {});\r\n var $document = $(document);\r\n var $context = $document;\r\n var _hasContext = false;\r\n\r\n if (!o.context || !o.context.length) {\r\n o.context = document;\r\n } else {\r\n // you never know what they throw at you...\r\n $context = $(o.context).first();\r\n o.context = $context.get(0);\r\n _hasContext = !$(o.context).is(document);\r\n }\r\n\r\n switch (operation) {\r\n\r\n case 'update':\r\n // Updates visibility and such\r\n if(_hasContext){\r\n op.update($context);\r\n } else {\r\n for(var menu in menus){\r\n if(menus.hasOwnProperty(menu)){\r\n op.update(menus[menu]);\r\n }\r\n }\r\n }\r\n break;\r\n\r\n case 'create':\r\n // no selector no joy\r\n if (!o.selector) {\r\n throw new Error('No selector specified');\r\n }\r\n // make sure internal classes are not bound to\r\n if (o.selector.match(/.context-menu-(list|item|input)($|\\s)/)) {\r\n throw new Error('Cannot bind to selector \"' + o.selector + '\" as it contains a reserved className');\r\n }\r\n if (!o.build && (!o.items || $.isEmptyObject(o.items))) {\r\n throw new Error('No Items specified');\r\n }\r\n counter++;\r\n o.ns = '.contextMenu' + counter;\r\n if (!_hasContext) {\r\n namespaces[o.selector] = o.ns;\r\n }\r\n menus[o.ns] = o;\r\n\r\n // default to right click\r\n if (!o.trigger) {\r\n o.trigger = 'right';\r\n }\r\n\r\n if (!initialized) {\r\n var itemClick = o.itemClickEvent === 'click' ? 'click.contextMenu' : 'mouseup.contextMenu';\r\n var contextMenuItemObj = {\r\n // 'mouseup.contextMenu': handle.itemClick,\r\n // 'click.contextMenu': handle.itemClick,\r\n 'contextmenu:focus.contextMenu': handle.focusItem,\r\n 'contextmenu:blur.contextMenu': handle.blurItem,\r\n 'contextmenu.contextMenu': handle.abortevent,\r\n 'mouseenter.contextMenu': handle.itemMouseenter,\r\n 'mouseleave.contextMenu': handle.itemMouseleave\r\n };\r\n contextMenuItemObj[itemClick] = handle.itemClick;\r\n // make sure item click is registered first\r\n $document\r\n .on({\r\n 'contextmenu:hide.contextMenu': handle.hideMenu,\r\n 'prevcommand.contextMenu': handle.prevItem,\r\n 'nextcommand.contextMenu': handle.nextItem,\r\n 'contextmenu.contextMenu': handle.abortevent,\r\n 'mouseenter.contextMenu': handle.menuMouseenter,\r\n 'mouseleave.contextMenu': handle.menuMouseleave\r\n }, '.context-menu-list')\r\n .on('mouseup.contextMenu', '.context-menu-input', handle.inputClick)\r\n .on(contextMenuItemObj, '.context-menu-item');\r\n\r\n initialized = true;\r\n }\r\n\r\n // engage native contextmenu event\r\n $context\r\n .on('contextmenu' + o.ns, o.selector, o, handle.contextmenu);\r\n\r\n if (_hasContext) {\r\n // add remove hook, just in case\r\n $context.on('remove' + o.ns, function () {\r\n $(this).contextMenu('destroy');\r\n });\r\n }\r\n\r\n switch (o.trigger) {\r\n case 'hover':\r\n $context\r\n .on('mouseenter' + o.ns, o.selector, o, handle.mouseenter)\r\n .on('mouseleave' + o.ns, o.selector, o, handle.mouseleave);\r\n break;\r\n\r\n case 'left':\r\n $context.on('click' + o.ns, o.selector, o, handle.click);\r\n break;\r\n\t\t\t\t case 'touchstart':\r\n $context.on('touchstart' + o.ns, o.selector, o, handle.click);\r\n break;\r\n /*\r\n default:\r\n // http://www.quirksmode.org/dom/events/contextmenu.html\r\n $document\r\n .on('mousedown' + o.ns, o.selector, o, handle.mousedown)\r\n .on('mouseup' + o.ns, o.selector, o, handle.mouseup);\r\n break;\r\n */\r\n }\r\n\r\n // create menu\r\n if (!o.build) {\r\n op.create(o);\r\n }\r\n break;\r\n\r\n case 'destroy':\r\n var $visibleMenu;\r\n if (_hasContext) {\r\n // get proper options\r\n var context = o.context;\r\n $.each(menus, function (ns, o) {\r\n\r\n if (!o) {\r\n return true;\r\n }\r\n\r\n // Is this menu equest to the context called from\r\n if (!$(context).is(o.selector)) {\r\n return true;\r\n }\r\n\r\n $visibleMenu = $('.context-menu-list').filter(':visible');\r\n if ($visibleMenu.length && $visibleMenu.data().contextMenuRoot.$trigger.is($(o.context).find(o.selector))) {\r\n $visibleMenu.trigger('contextmenu:hide', {force: true});\r\n }\r\n\r\n try {\r\n if (menus[o.ns].$menu) {\r\n menus[o.ns].$menu.remove();\r\n }\r\n\r\n delete menus[o.ns];\r\n } catch (e) {\r\n menus[o.ns] = null;\r\n }\r\n\r\n $(o.context).off(o.ns);\r\n\r\n return true;\r\n });\r\n } else if (!o.selector) {\r\n $document.off('.contextMenu .contextMenuAutoHide');\r\n $.each(menus, function (ns, o) {\r\n $(o.context).off(o.ns);\r\n });\r\n\r\n namespaces = {};\r\n menus = {};\r\n counter = 0;\r\n initialized = false;\r\n\r\n $('#context-menu-layer, .context-menu-list').remove();\r\n } else if (namespaces[o.selector]) {\r\n $visibleMenu = $('.context-menu-list').filter(':visible');\r\n if ($visibleMenu.length && $visibleMenu.data().contextMenuRoot.$trigger.is(o.selector)) {\r\n $visibleMenu.trigger('contextmenu:hide', {force: true});\r\n }\r\n\r\n try {\r\n if (menus[namespaces[o.selector]].$menu) {\r\n menus[namespaces[o.selector]].$menu.remove();\r\n }\r\n\r\n delete menus[namespaces[o.selector]];\r\n } catch (e) {\r\n menus[namespaces[o.selector]] = null;\r\n }\r\n\r\n $document.off(namespaces[o.selector]);\r\n }\r\n break;\r\n\r\n case 'html5':\r\n // if and are not handled by the browser,\r\n // or options was a bool true,\r\n // initialize $.contextMenu for them\r\n if ((!$.support.htmlCommand && !$.support.htmlMenuitem) || (typeof options === 'boolean' && options)) {\r\n $('menu[type=\"context\"]').each(function () {\r\n if (this.id) {\r\n $.contextMenu({\r\n selector: '[contextmenu=' + this.id + ']',\r\n items: $.contextMenu.fromMenu(this)\r\n });\r\n }\r\n }).css('display', 'none');\r\n }\r\n break;\r\n\r\n default:\r\n throw new Error('Unknown operation \"' + operation + '\"');\r\n }\r\n\r\n return this;\r\n };\r\n\r\n// import values into commands\r\n $.contextMenu.setInputValues = function (opt, data) {\r\n if (typeof data === 'undefined') {\r\n data = {};\r\n }\r\n\r\n $.each(opt.inputs, function (key, item) {\r\n switch (item.type) {\r\n case 'text':\r\n case 'textarea':\r\n item.value = data[key] || '';\r\n break;\r\n\r\n case 'checkbox':\r\n item.selected = data[key] ? true : false;\r\n break;\r\n\r\n case 'radio':\r\n item.selected = (data[item.radio] || '') === item.value;\r\n break;\r\n\r\n case 'select':\r\n item.selected = data[key] || '';\r\n break;\r\n }\r\n });\r\n };\r\n\r\n// export values from commands\r\n $.contextMenu.getInputValues = function (opt, data) {\r\n if (typeof data === 'undefined') {\r\n data = {};\r\n }\r\n\r\n $.each(opt.inputs, function (key, item) {\r\n switch (item.type) {\r\n case 'text':\r\n case 'textarea':\r\n case 'select':\r\n data[key] = item.$input.val();\r\n break;\r\n\r\n case 'checkbox':\r\n data[key] = item.$input.prop('checked');\r\n break;\r\n\r\n case 'radio':\r\n if (item.$input.prop('checked')) {\r\n data[item.radio] = item.value;\r\n }\r\n break;\r\n }\r\n });\r\n\r\n return data;\r\n };\r\n\r\n// find