mirror of
https://github.com/zadam/trilium.git
synced 2024-12-27 01:34:05 +08:00
4 lines
9.2 KiB
JavaScript
4 lines
9.2 KiB
JavaScript
|
/*! jQuery UI context menu plugin - v1.18.1 - 2017-08-28 | https://github.com/mar10/jquery-ui-contextmenu | Copyright (c) 2013 -2017 Martin Wendt; Licensed MIT */
|
||
|
|
||
|
!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery","jquery-ui/ui/widgets/menu"],a):a(jQuery)}(function(a){"use strict";var b="onselectstart"in document.createElement("div"),c=a.ui.menu.version.match(/^(\d)\.(\d+)/),d={major:parseInt(c[1],10),minor:parseInt(c[2],10)},e=d.major<2&&d.minor<=10,f=d.major<2&&d.minor<=11;a.widget("moogle.contextmenu",{version:"1.18.1",options:{addClass:"ui-contextmenu",closeOnWindowBlur:!0,autoFocus:!1,autoTrigger:!0,delegate:null,hide:{effect:"fadeOut",duration:"fast"},ignoreParentSelect:!0,menu:null,position:null,preventContextMenuForPopup:!1,preventSelect:!1,show:{effect:"slideDown",duration:"fast"},taphold:!1,uiMenuOptions:{},beforeOpen:a.noop,blur:a.noop,close:a.noop,create:a.noop,createMenu:a.noop,focus:a.noop,open:a.noop,select:a.noop},_create:function(){var c,d,e,f=this.options;if(this.$headStyle=null,this.$menu=null,this.menuIsTemp=!1,this.currentTarget=null,this.extraData={},this.previousFocus=null,null==f.delegate&&a.error("ui-contextmenu: Missing required option `delegate`."),f.preventSelect){e=(a(this.element).is(document)?a("body"):this.element).uniqueId().attr("id"),c="#"+e+" "+f.delegate+" { -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }",this.$headStyle=a("<style class='moogle-contextmenu-style' />").prop("type","text/css").appendTo("head");try{this.$headStyle.html(c)}catch(g){this.$headStyle[0].styleSheet.cssText=c}b&&this.element.on("selectstart"+this.eventNamespace,f.delegate,function(a){a.preventDefault()})}this._createUiMenu(f.menu),d="contextmenu"+this.eventNamespace,f.taphold&&(d+=" taphold"+this.eventNamespace),this.element.on(d,f.delegate,a.proxy(this._openMenu,this))},_destroy:function(){this.element.off(this.eventNamespace),this._createUiMenu(null),this.$headStyle&&(this.$headStyle.remove(),this.$headStyle=null)},_createUiMenu:function(b){var c,d,e=this.options;this.isOpen()&&(c=this.currentTarget,d=this.extraData,this._closeMenu(!0),this.currentTarget=c,this.extraData=d),this.menuIsTemp?this.$menu.remove():this.$menu&&this.$menu.menu("destroy").removeClass(this.options.addClass).hide(),this.$menu=null,this.menuIsTemp=!1,b&&(a.isArray(b)?(this.$menu=a.moogle.contextmenu.createMenuMarkup(b),this.menuIsTemp=!0):"string"==typeof b?this.$menu=a(b):this.$menu=b,this.$menu.hide().addClass(e.addClass).menu(a.extend(!0,{},e.uiMenuOptions,{items:"> :not(.ui-widget-header)",blur:a.proxy(e.blur,this),create:a.proxy(e.createMenu,this),focus:a.proxy(e.focus,this),select:a.proxy(function(b,c){var d,f=a.moogle.contextmenu.isMenu(c.item),g=c.item.data("actionHandler");c.cmd=c.item.attr("data-command"),c.target=a(this.currentTarget),c.extraData=this.extraData,f&&e.ignoreParentSelect||(d=this._trigger.call(this,"select",b,c),g&&(d=g.call(this,b,c)),d!==!1&&this._closeMenu.call(this),b.preventDefault())},this)})))},_openMenu:function(b,c){var d,e,f,g=this.options,h=g.position,i=this,j=!!b.isTrigger;if(g.autoTrigger||j){if(b.preventDefault(),this.currentTarget=b.target,this.extraData=b._extraData||{},f={menu:this.$menu,target:a(this.currentTarget),extraData:this.extraData,originalEvent:b,result:null},!c){if(d=this._trigger("beforeOpen",b,f),e=f.result&&a.isFunction(f.result.promise)?f.result:null,f.result=null,d===!1)return this.currentTarget=null,!1;if(e)return e.done(function(){i._openMenu(b,!0)}),this.currentTarget=null,!1;f.menu=this.$menu}a(document).on("keydown"+this.eventNamespace,function(b){b.which===a.ui.keyCode.ESCAPE&&i._closeMenu()}).on("mousedown"+this.eventNamespace+" touchstart"+this.eventNamespace,function(b){a(b.target).closest(".ui-menu-item").length||i._closeMenu()}),a(window).on("blur"+this.eventNamespace,function(a){g.closeOnWindowBlur&&i._closeMenu()}),a.isFunction(h)&&(h=h(b,f)),h=a.extend({my:"left top",at:"left bottom",of:void 0===b.pageX?b.target:b,collision:"fit"},h),this._updateEntries(this.$menu),this.$menu.show().css({position:"absolute",left:0,top:0}).position(h).hide(),g.preventContextMenuForPopup&&this.$menu.on("contextmenu"+this.eventNamespace,func
|
||
|
//# sourceMappingURL=jquery.ui-contextmenu.min.js.map
|