diff --git a/common/modules/mixly-modules/common/app.js b/common/modules/mixly-modules/common/app.js index d88c620c..6bc392a0 100644 --- a/common/modules/mixly-modules/common/app.js +++ b/common/modules/mixly-modules/common/app.js @@ -1,13 +1,15 @@ goog.loadJs('common', () => { goog.require('path'); -goog.require('layui'); +goog.require('hotkeys'); goog.require('Mixly.Url'); goog.require('Mixly.Config'); goog.require('Mixly.Env'); goog.require('Mixly.Msg'); goog.require('Mixly.Drag'); goog.require('Mixly.Nav'); +goog.require('Mixly.Menu'); +goog.require('Mixly.ContextMenu'); goog.require('Mixly.Workspace'); goog.require('Mixly.FooterBar'); goog.require('Mixly.HTMLTemplate'); @@ -27,6 +29,7 @@ goog.require('Mixly.Web.BU'); goog.require('Mixly.Web.FS'); goog.require('Mixly.Web.File'); goog.require('Mixly.Web.Serial'); +goog.require('Mixly.WebCompiler.ArduShell'); goog.require('Mixly.WebSocket.File'); goog.require('Mixly.WebSocket.Serial'); goog.require('Mixly.WebSocket.ArduShell'); @@ -40,6 +43,8 @@ const { Msg, Drag, Nav, + Menu, + ContextMenu, Workspace, FooterBar, HTMLTemplate, @@ -49,6 +54,7 @@ const { EditorMix, Electron = {}, Web = {}, + WebCompiler = {}, WebSocket = {} } = Mixly; @@ -70,18 +76,20 @@ const { FS, File, LibManager, - ArduShell, BU, PythonShell, Serial } = currentObj; +let ArduShell = null; +if (!goog.isElectron && Env.hasCompiler) { + ArduShell = WebCompiler.ArduShell; +} else { + ArduShell = currentObj.ArduShell; +} + const { BOARD, SELECTED_BOARD } = Config; -const { layer } = layui; - -const electron = Mixly.require('electron'); - class App extends Component { static { @@ -116,7 +124,6 @@ class App extends Component { this.#footerbar_ = new FooterBar(); this.#footerbar_.mountOn($content.find('.mixly-footerbar')); this.#addEventsListenerForNav_(); - this.#addEventsListenerForWorkspace_(); this.#addObserver_(); Mixly.mainStatusBarTabs = this.#workspace_.getStatusBarsManager(); Serial.refreshPorts(); @@ -433,211 +440,202 @@ class App extends Component { $a.addClass('codicon-layout-panel'); }); + const fileMenu = new Menu(); + const settingMenu = new Menu(); + this.#nav_.register({ id: 'file', - displayText: Msg.Lang['nav.btn.file'], - preconditionFn: () => { - return true; - }, + displayText: `${Msg.Lang['nav.btn.file']}(F)`, scopeType: Nav.Scope.RIGHT, - weight: 1 - }); - - this.#nav_.register({ - icon: 'icon-doc-new', - id: ['file', 'new-file'], - displayText: Msg.Lang['nav.btn.file.new'], - preconditionFn: () => { - return true; - }, - callback: () => File.new(), - scopeType: Nav.Scope.RIGHT, - weight: 1 - }); - - this.#nav_.register({ - icon: 'icon-doc', - id: ['file', 'open-file'], - displayText: Msg.Lang['nav.btn.file.open'], - preconditionFn: () => { - return true; - }, - callback: (elem) => File.open(), - scopeType: Nav.Scope.RIGHT, - weight: 2 - }); - - this.#nav_.register({ - id: ['file', 'hr'], - scopeType: Nav.Scope.RIGHT, - weight: 3 - }); - - this.#nav_.register({ - icon: 'icon-floppy', - id: ['file', 'save-file'], - displayText: Msg.Lang['nav.btn.file.save'], - preconditionFn: () => { - return true; - }, - callback: (elem) => File.save(), - scopeType: Nav.Scope.RIGHT, - weight: 4 - }); - - this.#nav_.register({ - icon: 'icon-save-as', - id: ['file', 'save-as-file'], - displayText: Msg.Lang['nav.btn.file.saveAs'], - preconditionFn: () => { - return true; - }, - callback: () => File.saveAs(), - scopeType: Nav.Scope.RIGHT, - weight: 5 - }); - - this.#nav_.register({ - id: ['file', 'hr'], - preconditionFn: () => { - return goog.isElectron && BOARD?.nav?.setting?.thirdPartyLibrary; - }, - scopeType: Nav.Scope.RIGHT, - weight: 6 - }); - - this.#nav_.register({ - icon: 'icon-export', - id: ['file', 'export-file'], - displayText: Msg.Lang['nav.btn.file.exportAs'], - preconditionFn: () => { - return goog.isElectron && BOARD?.nav?.setting?.thirdPartyLibrary; - }, - callback: (elem) => File.exportLib(), - scopeType: Nav.Scope.RIGHT, - weight: 7 + weight: 1, + menu: fileMenu }); this.#nav_.register({ id: 'setting', - displayText: Msg.Lang['nav.btn.setting'], + displayText: `${Msg.Lang['nav.btn.setting']}(S)`, + scopeType: Nav.Scope.RIGHT, + weight: 2, + menu: settingMenu + }); + + fileMenu.add({ + weight: 0, + id: 'new', preconditionFn: () => { return true; }, - scopeType: Nav.Scope.RIGHT, - weight: 1 + data: { + isHtmlName: true, + name: ContextMenu.getItem(Msg.Lang['nav.btn.file.new'], 'Ctrl+N'), + callback: () => File.new() + } }); - this.#nav_.register({ - icon: 'icon-menu', - id: ['setting', 'manage-libs'], - displayText: Msg.Lang['nav.btn.setting.manageLibs'], + hotkeys('ctrl+n', function(event) { + event.preventDefault(); + event.stopImmediatePropagation(); + File.new(); + }); + + fileMenu.add({ + weight: 1, + id: 'open-file', + preconditionFn: () => { + return true; + }, + data: { + isHtmlName: true, + name: ContextMenu.getItem(Msg.Lang['nav.btn.file.open'], 'Ctrl+O'), + callback: (key, opt) => File.open() + } + }); + + hotkeys('ctrl+o', function(event) { + event.preventDefault(); + File.open(); + }); + + fileMenu.add({ + weight: 2, + id: 'sep1', + data: '---------' + }); + + fileMenu.add({ + weight: 3, + id: 'save', + preconditionFn: () => { + return true; + }, + data: { + isHtmlName: true, + name: ContextMenu.getItem(Msg.Lang['nav.btn.file.save'], 'Ctrl+S'), + callback: () => File.save() + } + }); + + hotkeys('ctrl+s', function(event) { + event.preventDefault(); + File.save(); + }); + + fileMenu.add({ + weight: 4, + id: 'save-as', + preconditionFn: () => { + return true; + }, + data: { + isHtmlName: true, + name: ContextMenu.getItem(Msg.Lang['nav.btn.file.saveAs'], 'Ctrl+Shift+S'), + callback: () => File.saveAs() + } + }); + + hotkeys('ctrl+shift+s', function(event) { + event.preventDefault(); + File.saveAs(); + }); + + fileMenu.add({ + weight: 5, + id: 'sep2', preconditionFn: () => { return goog.isElectron && BOARD?.nav?.setting?.thirdPartyLibrary; }, - callback: () => LibManager.showManageDialog(), - scopeType: Nav.Scope.RIGHT, - weight: 1 + data: '---------' }); - /*this.#nav_.register({ - icon: 'icon-upload-1', - id: ['setting', 'firmware'], - displayText: Msg.Lang['nav.btn.setting.firmware'], + fileMenu.add({ + weight: 6, + id: 'export', preconditionFn: () => { - if (goog.isElectron) { - return !!BOARD?.burn?.special; - } else { - return !!BOARD?.web?.burn?.special; - } + return goog.isElectron && BOARD?.nav?.setting?.thirdPartyLibrary; }, - callback: () => BU.burnWithSpecialBin(), - scopeType: Nav.Scope.RIGHT, - weight: 2 - });*/ + data: { + isHtmlName: true, + name: ContextMenu.getItem(Msg.Lang['nav.btn.file.exportAs'], 'Ctrl+E'), + callback: () => File.exportLib() + } + }); - this.#nav_.register({ - icon: 'icon-comment-1', - id: ['setting', 'feedback'], - displayText: Msg.Lang['nav.btn.setting.feedback'], + if (goog.isElectron && BOARD?.nav?.setting?.thirdPartyLibrary) { + hotkeys('ctrl+e', function(event) { + event.preventDefault(); + File.exportLib(); + }); + } + + settingMenu.add({ + weight: 0, + id: 'feedback', preconditionFn: () => { return true; }, - callback: (elem) => { - const href = 'https://gitee.com/mixly2/mixly2.0_src/issues'; - Url.open(href); + data: { + isHtmlName: true, + name: ContextMenu.getItem(Msg.Lang['nav.btn.setting.feedback'], 'Ctrl+Shift+F'), + callback: () => { + const href = 'https://gitee.com/bnu_mixly/mixly3/issues'; + Url.open(href); + } + } + }); + + hotkeys('ctrl+shift+f', function(event) { + const href = 'https://gitee.com/bnu_mixly/mixly3/issues'; + Url.open(href); + }); + + settingMenu.add({ + weight: 1, + id: 'wiki', + preconditionFn: () => { + return true; }, - scopeType: Nav.Scope.RIGHT, - weight: 2 - }); - } - - #addEventsListenerForWorkspace_() { - const editorsManager = this.#workspace_.getEditorsManager(); - const editorTabs = editorsManager.getTabs(); - - editorTabs.bind('tabCheckDestroy', (event) => { - const { tabEl } = event.detail; - const id = $(tabEl).attr('data-tab-id'); - const editor = editorsManager.get(id); - if (!editor) { - return; + data: { + isHtmlName: true, + name: ContextMenu.getItem('文档', 'Ctrl+H'), + callback: () => { + const href = 'https://mixly.readthedocs.io/zh-cn/latest/contents.html'; + Url.open(href); + } } - if (editor.isDirty()) { - layer.confirm(`是否保存对${path.basename(id)}的修改?`, { - title: false, - shade: LayerExt.SHADE_ALL, - resize: false, - btn: ['保存', '不保存', '取消'], - closeBtn: 1, - btn1: (index) => { - const $tab = editor.getTab(); - if ($tab.attr('data-link-file') === 'true') { - FS.writeFile($tab.attr('data-tab-id'), editor.getValue()) - .then(() => { - editor.removeDirty(); - editorsManager.remove(id); - layer.close(index); - layer.msg('已保存文件'); - }) - .catch(Debug.error); - } else { - FS.showSaveFilePicker(id, $tab.attr('data-tab-type')) - .then((filePath) => { - if (!filePath) { - return Promise.resolve(true); - } - return FS.writeFile(filePath, editor.getValue()); - }) - .then((status) => { - if (status) { - return; - } - editor.removeDirty(); - editorsManager.remove(id); - layer.close(index); - layer.msg('已保存文件'); - }) - .catch(Debug.error); - } - }, - btn2: (index) => { - editor.removeDirty(); - editorsManager.remove(id); - layer.close(index); - }, - btn3: (index) => { - layer.close(index); - }, - success: (layero) => { - const { classList } = layero[0].childNodes[1].childNodes[0]; - classList.remove('layui-layer-close2'); - classList.add('layui-layer-close1'); - } - }); - } - return !editor.isDirty(); }); + + hotkeys('ctrl+h', function(event) { + const href = 'https://mixly.readthedocs.io/zh-cn/latest/contents.html'; + Url.open(href); + }); + + settingMenu.add({ + weight: 2, + id: 'sep1', + preconditionFn: () => { + return goog.isElectron && BOARD?.nav?.setting?.thirdPartyLibrary; + }, + data: '---------' + }); + + settingMenu.add({ + weight: 3, + id: 'manage-libraries', + preconditionFn: () => { + return goog.isElectron && BOARD?.nav?.setting?.thirdPartyLibrary; + }, + data: { + isHtmlName: true, + name: ContextMenu.getItem(Msg.Lang['nav.btn.setting.manageLibs'], 'Ctrl+M'), + callback: () => LibManager.showManageDialog() + } + }); + + if (goog.isElectron && BOARD?.nav?.setting?.thirdPartyLibrary) { + hotkeys('ctrl+m', function(event) { + LibManager.showManageDialog(); + }); + } } #addObserver_() { @@ -653,7 +651,7 @@ class App extends Component { if (goog.isElectron) { Loader.onbeforeunload(); } else { - let href = Env.srcDirPath + 'index.html?' + Url.jsonToUrl({ boardType: BOARD.boardType }); + let href = path.join(Env.srcDirPath, 'index.html') + '?' + Url.jsonToUrl({ boardType: BOARD.boardType }); window.location.replace(href); } } diff --git a/common/modules/mixly-modules/common/dropdown-menu-group.js b/common/modules/mixly-modules/common/dropdown-menu-group.js new file mode 100644 index 00000000..9984832d --- /dev/null +++ b/common/modules/mixly-modules/common/dropdown-menu-group.js @@ -0,0 +1,211 @@ +goog.loadJs('common', () => { + +goog.require('tippy'); +goog.require('Mixly.Menu'); +goog.require('Mixly.Registry'); +goog.require('Mixly.IdGenerator'); +goog.require('Mixly.ContextMenu'); +goog.require('Mixly.DropdownMenu'); +goog.provide('Mixly.DropdownMenuGroup'); + +const { + Menu, + Registry, + IdGenerator, + ContextMenu, + DropdownMenu +} = Mixly; + + +class DropdownMenuGroup { + #shown_ = false; + #singleton_ = null; + #menuItems_ = []; + #ids_ = {}; + #instanceIds_ = {}; + #activeInstance_ = null; + #hided_ = false; + #trigged_ = false; + #$instancePopper_ = null; + #$instanceContent_ = null; + #$content_ = null; + constructor(elem) { + this.#$content_ = $(elem); + this.#$content_.css('z-index', 200); + this.#singleton_ = tippy.createSingleton([], { + interactive: true, + maxWidth: 'none', + offset: [0, 3], + appendTo: document.body, + arrow: false, + placement: 'bottom-end', + animation: 'shift-toward-extreme', + hideOnClick: false, + delay: [200, null], + onShow: () => { + if (this.#activeInstance_) { + this.show(this.#activeInstance_.id); + } + this.#shown_ = true; + }, + onTrigger: (_, event) => { + const id = $(event.currentTarget).attr('data-id'); + if (this.#shown_) { + if (this.#activeInstance_) { + this.#trigged_ = true; + this.hide(this.#activeInstance_.id); + this.#activeInstance_ = null; + } + this.show(id); + } + this.#activeInstance_ = this.#instanceIds_[id].instance; + }, + onHide: () => { + if (this.#hided_) { + this.#shown_ = false; + } + return this.#hided_; + } + }); + this.#$instancePopper_ = $(this.#singleton_.popper); + this.#$instancePopper_.addClass('mixly-drapdown-menu'); + this.#$instanceContent_ = this.#$instancePopper_.children().children(); + } + + add(item) { + if (!item.id) { + if (item.type) { + item.id = item.type; + } else { + item.id = IdGenerator.generate(); + } + } + if (!item.weight) { + item.weight = 0; + } + this.remove(item.id); + item.$elem = $(``); + const instance = tippy(item.$elem[0]); + item.$elem.attr('data-id', instance.id); + item.instance = instance; + const contextMenuId = IdGenerator.generate(); + const selector = `body > .mixly-dropdown-menus > div[m-id="${contextMenuId}"]`; + const contextMenu = new ContextMenu(selector, { + trigger: 'none', + appendTo: this.#$instanceContent_, + shadow: true, + autoHide: false, + async: false, + zIndex: 150, + position: (opt) => { + opt.$menu.css('margin', 0); + }, + events: { + show: (opt) => { + this.#hided_ = false; + this.#singleton_.setProps({}); + }, + hide: (opt) => { + if (this.trigged_) { + this.trigged_ = false; + return true; + } + this.#hided_ = true; + this.#singleton_.hide(); + } + } + }); + item.contextMenu = contextMenu; + contextMenu.register('menu', item.menu); + contextMenu.bind('getMenu', () => 'menu'); + item.$menu = $(`
`); + DropdownMenu.$container.append(item.$menu); + let i = 0; + for (; i < this.#menuItems_.length; i++) { + if (this.#menuItems_[i].weight <= item.weight) { + continue; + } + break; + } + if (i === this.#menuItems_.length) { + if (this.#menuItems_.length) { + this.#menuItems_[i - 1].$elem.after(item.$elem); + } else { + this.#$content_.append(item.$elem); + } + } else { + this.#menuItems_[i].$elem.before(item.$elem); + } + this.#menuItems_.splice(i, 0, item); + this.#ids_[item.id] = item; + this.#instanceIds_[instance.id] = item; + const instances = []; + for (let menuItem of this.#menuItems_) { + instances.push(menuItem.instance); + } + this.#singleton_.setInstances(instances); + return item.id; + } + + getContextMenu(id) { + if (!this.#ids_[id]) { + return null; + } + return this.#ids_[id].contextMenu; + } + + remove(id) { + let item = this.#ids_[id]; + if (!item) { + return; + } + delete this.#ids_[id]; + const instanceId = item.instance.id; + delete this.#instanceIds_[instanceId]; + for (let i in this.#menuItems_) { + if (this.#menuItems_[i].id !== id) { + continue; + } + this.#menuItems_.splice(i, 1); + break; + } + item.instance.destroy(); + item.contextMenu.dispose(); + item.$elem.remove(); + item.$menu.remove(); + item = null; + } + + show(instanceId) { + const item = this.#instanceIds_[instanceId]; + item.$menu.contextMenu(); + } + + hide(instanceId) { + const item = this.#instanceIds_[instanceId]; + item.$menu.contextMenu('hide'); + } + + dispose() { + super.dispose(); + this.#$instanceContent_.remove(); + this.#$instanceContent_ = null; + this.#$instancePopper_.remove(); + this.#$instancePopper_ = null; + this.#$content_.empty(); + this.#$content_ = null; + for (let id in this.#ids_) { + this.remove(id); + } + this.#singleton_.destroy(); + this.#singleton_ = null; + this.#menuItems_ = null; + this.#ids_ = null; + this.#instanceIds_ = null; + this.#activeInstance_ = null; + } +} + +Mixly.DropdownMenuGroup = DropdownMenuGroup; + +}); \ No newline at end of file diff --git a/common/modules/mixly-modules/common/nav.js b/common/modules/mixly-modules/common/nav.js index a5313075..acc1f8b3 100644 --- a/common/modules/mixly-modules/common/nav.js +++ b/common/modules/mixly-modules/common/nav.js @@ -7,6 +7,9 @@ goog.require('Mixly.XML'); goog.require('Mixly.Msg'); goog.require('Mixly.HTMLTemplate'); goog.require('Mixly.Component'); +goog.require('Mixly.Menu'); +goog.require('Mixly.ContextMenu'); +goog.require('Mixly.DropdownMenuGroup'); goog.provide('Mixly.Nav'); const { @@ -14,7 +17,10 @@ const { XML, Msg, HTMLTemplate, - Component + Component, + Menu, + ContextMenu, + DropdownMenuGroup } = Mixly; const { element } = layui; @@ -76,6 +82,15 @@ class Nav extends Component { new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/nav/port-selector-div.html'))) ); + /** + * 下拉菜单遮罩 + * @type {String} + */ + HTMLTemplate.add( + 'html/nav/shadow.html', + new HTMLTemplate(goog.readFileSync(path.join(Env.templatePath, 'html/nav/shadow.html'))) + ); + Nav.Scope = { 'LEFT': -1, 'CENTER': 0, @@ -123,8 +138,9 @@ class Nav extends Component { #$editorBtnsContainer_ = null; #$boardSelect_ = null; #$portSelect_ = null; - #$shadow_ = $('
'); + #$shadow_ = $(HTMLTemplate.get('html/nav/shadow.html').render()); #btns_ = []; + #rightDropdownMenuGroup_ = null; constructor() { super(); @@ -175,7 +191,9 @@ class Nav extends Component { this.#$shadow_.click(() => $merge.select2('close')); this.addEventsType(['changeBoard', 'changePort']); this.#addEventsListener_(); + this.#rightDropdownMenuGroup_ = new DropdownMenuGroup(this.#$rightMenuContainer_[0]); Nav.add(this); + this.list = []; } onMounted() { @@ -195,6 +213,22 @@ class Nav extends Component { return this.#$portSelect_; } + getBoardName() { + return this.#$boardSelect_.find(':selected').text(); + } + + getBoardKey() { + return this.#$boardSelect_.val(); + } + + getPortName() { + return this.#$portSelect_.find(':selected').text(); + } + + getPortKey() { + return this.#$portSelect_.val(); + } + /** * @function 注册函数 * @param config 选项 @@ -237,24 +271,6 @@ class Nav extends Component { text: displayText })); break; - case Nav.Scope.RIGHT: - if (typeof id === 'string') { - config.$btn = $(HTMLTemplate.get('html/nav/nav-item-container.html').render({ - mId: id, - text: displayText - })); - } else { - if (displayText) { - config.$btn = $(HTMLTemplate.get('html/nav/nav-item.html').render({ - mId: id.join('-'), - icon, - text: displayText - })); - } else { - config.$btn = $('
'); - } - } - break; } this.#add_(config); return config; @@ -277,14 +293,9 @@ class Nav extends Component { this.#addCenterBtn_(config); break; case Nav.Scope.RIGHT: - if (typeof id === 'string') { - this.#addRightMenu_(config); - } else { - this.#addRightMenuItem_(config); - } + this.#addRightBtn_(config); break; } - element.render('nav', 'nav-filter'); } /** @@ -373,10 +384,6 @@ class Nav extends Component { this.resize(); } - #removeLeftBtn_(config) { - - } - #addCenterBtn_(config) { const { id = '', weight = 0 } = config; let $btn = null; @@ -401,76 +408,15 @@ class Nav extends Component { this.resize(); } - #removeCenterBtn_(config) { - - } - - #addRightMenu_(config) { - const { id = '', weight = 0, preconditionFn } = config; + #addRightBtn_(config) { + const { preconditionFn } = config; if (!preconditionFn()) { return; } - const $btns = this.#$rightMenuContainer_.children('li'); - let $btn = null; - for (let i = 0; $btns[i]; i++) { - const mId = $($btns[i]).attr('m-id'); - if (!this.#btns_[mId]) { - continue; - } - if (weight < this.#btns_[mId].weight) { - $btn = this.#btns_[mId].$btn; - break; - } - } - if ($btn) { - $btn.before(config.$btn); - } else { - this.#$rightMenuContainer_.append(config.$btn); - } - config.width = this.#getElemWidth_(config.$btn); - this.#btns_[id] = config; + this.#rightDropdownMenuGroup_.add(config); this.resize(); } - #removeRightMenu_(config) { - - } - - #addRightMenuItem_(config) { - const { id = [], weight = 0, preconditionFn } = config; - if (!preconditionFn()) { - return; - } - const $li = this.#$rightMenuContainer_.children(`[m-id="${id[0]}"]`); - let $btn = null; - if (!$li.length) { - return; - } - const $container_ = $li.find('.layui-nav-child'); - const $btns = $container_.find('dd'); - for (let i = 0; $btns[i]; i++) { - const mId = $($btns[i]).attr('m-id'); - if (!this.#btns_[mId]) { - continue; - } - if (weight < this.#btns_[mId].weight) { - $btn = this.#btns_[mId].$btn; - break; - } - } - if ($btn) { - $btn.before(config.$btn); - } else { - $container_.append(config.$btn); - } - config.width = this.#getElemWidth_(config.$btn); - this.#btns_[id.join('-')] = config; - } - - #removeRightMenuItem_(config) { - - } - resize() { super.resize(); this.#$boardSelect_.select2('close'); diff --git a/common/modules/web-modules/jquery/jquery.contextMenu.min.js b/common/modules/web-modules/jquery/jquery.contextMenu.min.js index 5bc3c61e..967fb7a0 100644 --- a/common/modules/web-modules/jquery/jquery.contextMenu.min.js +++ b/common/modules/web-modules/jquery/jquery.contextMenu.min.js @@ -1 +1 @@ -!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)}(function(m){"use strict";var a;m.support.htmlMenuitem="HTMLMenuItemElement"in window,m.support.htmlCommand="HTMLCommandElement"in window,m.support.eventSelectstart="onselectstart"in document.documentElement,m.ui&&m.widget||(m.cleanData=(a=m.cleanData,function(e){var t,n,o;for(o=0;null!=e[o];o++){n=e[o];try{(t=m._data(n,"events"))&&t.remove&&m(n).triggerHandler("remove")}catch(e){}}a(e)}));var c=null,d=!1,p=m(window),f=0,h={},x={},v={},g={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(e){if(m.ui&&m.ui.position)e.css("display","block").position({my:"center top",at:"center bottom",of:this,offset:"0 5",collision:"fit"}).css("display","none");else{var t=this.offset();t.top+=this.outerHeight(),t.left+=this.outerWidth()/2-e.outerWidth()/2,e.css(t)}},position:function(e,t,n){var o;if(t||n){if("maintain"===t&&"maintain"===n)o=e.$menu.position();else{var a=e.$menu.offsetParent().offset();o={top:n-a.top,left:t-a.left}}var s=p.scrollTop()+p.height(),i=p.scrollLeft()+p.width(),c=e.$menu.outerHeight(),l=e.$menu.outerWidth();o.top+c>s&&(o.top-=c),o.top<0&&(o.top=0),o.left+l>i&&(o.left-=l),o.left<0&&(o.left=0),e.$menu.css(o)}else e.determinePosition.call(this,e.$menu)},positionSubmenu:function(e){if(void 0!==e)if(m.ui&&m.ui.position)e.css("display","block").position({my:"left top-5",at:"right top",of:this,collision:"flipfit fit"}).css("display","");else{var t={top:-9,left:this.outerWidth()-5};e.css(t)}},zIndex:1,animation:{duration:50,show:"slideDown",hide:"slideUp"},events:{preShow:m.noop,show:m.noop,hide:m.noop,activated:m.noop},callback:null,items:{}},s={timer:null,pageX:null,pageY:null},b={abortevent:function(e){e.preventDefault(),e.stopImmediatePropagation()},contextmenu:function(e){var t=m(this);if(!1!==e.data.events.preShow(t,e)&&("right"===e.data.trigger&&(e.preventDefault(),e.stopImmediatePropagation()),!("right"!==e.data.trigger&&"demand"!==e.data.trigger&&e.originalEvent||!(void 0===e.mouseButton||!e.data||"left"===e.data.trigger&&0===e.mouseButton||"right"===e.data.trigger&&2===e.mouseButton)||t.hasClass("context-menu-active")||t.hasClass("context-menu-disabled")))){if(c=t,e.data.build){var n=e.data.build(c,e);if(!1===n)return;if(e.data=m.extend(!0,{},g,e.data,n||{}),!e.data.items||m.isEmptyObject(e.data.items))throw window.console&&(console.error||console.log).call(console,"No items specified to show in contextMenu"),new Error("No Items specified");e.data.$trigger=c,$.create(e.data)}$.show.call(t,e.data,e.pageX,e.pageY)}},click:function(e){e.preventDefault(),e.stopImmediatePropagation(),m(this).trigger(m.Event("contextmenu",{data:e.data,pageX:e.pageX,pageY:e.pageY}))},mousedown:function(e){var t=m(this);c&&c.length&&!c.is(t)&&c.data("contextMenu").$menu.trigger("contextmenu:hide"),2===e.button&&(c=t.data("contextMenuActive",!0))},mouseup:function(e){var t=m(this);t.data("contextMenuActive")&&c&&c.length&&c.is(t)&&!t.hasClass("context-menu-disabled")&&(e.preventDefault(),e.stopImmediatePropagation(),(c=t).trigger(m.Event("contextmenu",{data:e.data,pageX:e.pageX,pageY:e.pageY}))),t.removeData("contextMenuActive")},mouseenter:function(e){var t=m(this),n=m(e.relatedTarget),o=m(document);n.is(".context-menu-list")||n.closest(".context-menu-list").length||c&&c.length||(s.pageX=e.pageX,s.pageY=e.pageY,s.data=e.data,o.on("mousemove.contextMenuShow",b.mousemove),s.timer=setTimeout(function(){s.timer=null,o.off("mousemove.contextMenuShow"),(c=t).trigger(m.Event("contextmenu",{data:s.data,pageX:s.pageX,pageY:s.pageY}))},e.data.delay))},mousemove:function(e){s.pageX=e.pageX,s.pageY=e.pageY},mouseleave:function(e){var t=m(e.relatedTarget);if(!t.is(".context-menu-list")&&!t.closest(".context-menu-list").length){try{clearTimeout(s.timer)}catch(e){}s.timer=null}},layerClick:function(a){var s,i,c=m(this).data("contextMenuRoot"),l=a.button,r=a.pageX,u=a.pageY,d=void 0===r;a.preventDefault(),setTimeout(function(){if(d)null!=c&&null!==c.$menu&&void 0!==c.$menu&&c.$menu.trigger("contextmenu:hide");else{var e,t="left"===c.trigger&&0===l||"right"===c.trigger&&2===l;if(document.elementFromPoint&&c.$layer){if(c.$layer.hide(),null!==(s=document.elementFromPoint(r-p.scrollLeft(),u-p.scrollTop()))&&s.isContentEditable){var n=document.createRange(),o=window.getSelection();n.selectNode(s),n.collapse(!0),o.removeAllRanges(),o.addRange(n)}m(s).trigger(a),c.$layer.show()}if(c.hideOnSecondTrigger&&t&&null!==c.$menu&&void 0!==c.$menu)c.$menu.trigger("contextmenu:hide");else{if(c.reposition&&t)if(document.elementFromPoint){if(c.$trigger.is(s))return void c.position.call(c.$trigger,c,r,u)}else if(i=c.$trigger.offset(),e=m(window),i.top+=e.scrollTop(),i.top<=a.pageY&&(i.left+=e.scrollLeft(),i.left<=a.pageX&&(i.bottom=i.top+c.$trigger.outerHeight(),i.bottom>=a.pageY&&(i.right=i.left+c.$trigger.outerWidth(),i.right>=a.pageX))))return void c.position.call(c.$trigger,c,r,u);s&&t&&c.$trigger.one("contextmenu:hidden",function(){m(s).contextMenu({x:r,y:u,button:l})}),null!=c&&null!==c.$menu&&void 0!==c.$menu&&c.$menu.trigger("contextmenu:hide")}}},50)},keyStop:function(e,t){t.isInput||e.preventDefault(),e.stopPropagation()},key:function(e){var t={};c&&(t=c.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(b.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(b.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(b.keyStop(e,t),t.isInput||!t.$selected||!t.$selected.length)break;if(t.$selected.parent().hasClass("context-menu-root"))break;var a=t.$selected.parent().parent();return t.$selected.trigger("contextmenu:blur"),void(t.$selected=a);case 39:if(b.keyStop(e,t),t.isInput||!t.$selected||!t.$selected.length)break;var s=t.$selected.data("contextMenu")||{};if(s.$menu&&t.$selected.hasClass("context-menu-submenu"))return t.$selected=null,s.$selected=null,void s.$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(b.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 b.keyStop(e,t);case 27:return b.keyStop(e,t),void(null!==t.$menu&&void 0!==t.$menu&&t.$menu.trigger("contextmenu:hide"));default:var i=String.fromCharCode(e.keyCode).toUpperCase();if(t.accesskeys&&t.accesskeys[i])return void t.accesskeys[i].$node.trigger(t.accesskeys[i].$menu?"contextmenu:focus":"mouseup")}e.stopPropagation(),void 0!==t.$selected&&null!==t.$selected&&t.$selected.trigger(e)}},prevItem:function(e){e.stopPropagation();var t=m(this).data("contextMenu")||{},n=m(this).data("contextMenuRoot")||{};if(t.$selected){var o=t.$selected;(t=t.$selected.parent().data("contextMenu")||{}).$selected=o}for(var a=t.$menu.children(),s=t.$selected&&t.$selected.prev().length?t.$selected.prev():a.last(),i=s;s.hasClass(n.classNames.disabled)||s.hasClass(n.classNames.notSelectable)||s.is(":hidden");)if((s=s.prev().length?s.prev():a.last()).is(i))return;t.$selected&&b.itemMouseleave.call(t.$selected.get(0),e),b.itemMouseenter.call(s.get(0),e);var c=s.find("input, textarea, select");c.length&&c.focus()},nextItem:function(e){e.stopPropagation();var t=m(this).data("contextMenu")||{},n=m(this).data("contextMenuRoot")||{};if(t.$selected){var o=t.$selected;(t=t.$selected.parent().data("contextMenu")||{}).$selected=o}for(var a=t.$menu.children(),s=t.$selected&&t.$selected.next().length?t.$selected.next():a.first(),i=s;s.hasClass(n.classNames.disabled)||s.hasClass(n.classNames.notSelectable)||s.is(":hidden");)if((s=s.next().length?s.next():a.first()).is(i))return;t.$selected&&b.itemMouseleave.call(t.$selected.get(0),e),b.itemMouseenter.call(s.get(0),e);var c=s.find("input, textarea, select");c.length&&c.focus()},focusInput:function(){var e=m(this).closest(".context-menu-item"),t=e.data(),n=t.contextMenu,o=t.contextMenuRoot;o.$selected=n.$selected=e,o.isInput=n.isInput=!0},blurInput:function(){var e=m(this).closest(".context-menu-item").data(),t=e.contextMenu;e.contextMenuRoot.isInput=t.isInput=!1},menuMouseenter:function(){m(this).data().contextMenuRoot.hovering=!0},menuMouseleave:function(e){var t=m(this).data().contextMenuRoot;t.$layer&&t.$layer.is(e.relatedTarget)&&(t.hovering=!1)},itemMouseenter:function(e){var t=m(this),n=t.data(),o=n.contextMenu,a=n.contextMenuRoot;a.hovering=!0,e&&a.$layer&&a.$layer.is(e.relatedTarget)&&(e.preventDefault(),e.stopImmediatePropagation()),(o.$menu?o:a).$menu.children("."+a.classNames.hover).trigger("contextmenu:blur").children(".hover").trigger("contextmenu:blur"),t.hasClass(a.classNames.disabled)||t.hasClass(a.classNames.notSelectable)?o.$selected=null:t.trigger("contextmenu:focus")},itemMouseleave:function(e){var t=m(this),n=t.data(),o=n.contextMenu,a=n.contextMenuRoot;if(a!==o&&a.$layer&&a.$layer.is(e.relatedTarget))return void 0!==a.$selected&&null!==a.$selected&&a.$selected.trigger("contextmenu:blur"),e.preventDefault(),e.stopImmediatePropagation(),void(a.$selected=o.$selected=o.$node);o&&o.$menu&&o.$menu.hasClass("context-menu-visible")||t.trigger("contextmenu:blur")},itemClick:function(e){var t,n=m(this),o=n.data(),a=o.contextMenu,s=o.contextMenuRoot,i=o.contextMenuKey;if(!(!a.items[i]||n.is("."+s.classNames.disabled+", .context-menu-separator, ."+s.classNames.notSelectable)||n.is(".context-menu-submenu")&&!1===s.selectableSubMenu)){if(e.preventDefault(),e.stopImmediatePropagation(),m.isFunction(a.callbacks[i])&&Object.prototype.hasOwnProperty.call(a.callbacks,i))t=a.callbacks[i];else{if(!m.isFunction(s.callback))return;t=s.callback}!1!==t.call(s.$trigger,i,s,e)?s.$menu.trigger("contextmenu:hide"):s.$menu.parent().length&&$.update.call(s.$trigger,s)}},inputClick:function(e){e.stopImmediatePropagation()},hideMenu:function(e,t){var n=m(this).data("contextMenuRoot");$.hide.call(n.$trigger,n,t&&t.force)},focusItem:function(e){e.stopPropagation();var t=m(this),n=t.data(),o=n.contextMenu,a=n.contextMenuRoot;t.hasClass(a.classNames.disabled)||t.hasClass(a.classNames.notSelectable)||(t.addClass([a.classNames.hover,a.classNames.visible].join(" ")).parent().find(".context-menu-item").not(t).removeClass(a.classNames.visible).filter("."+a.classNames.hover).trigger("contextmenu:blur"),o.$selected=a.$selected=t,o&&o.$node&&o.$node.hasClass("context-menu-submenu")&&o.$node.addClass(a.classNames.hover),o.$node&&a.positionSubmenu.call(o.$node,o.$menu))},blurItem:function(e){e.stopPropagation();var t=m(this),n=t.data(),o=n.contextMenu,a=n.contextMenuRoot;o.autoHide&&t.removeClass(a.classNames.visible),t.removeClass(a.classNames.hover),o.$selected=null}},$={show:function(n,e,t){var o=m(this),a={};if(m("#context-menu-layer").trigger("mousedown"),n.$trigger=o,!1!==n.events.show.call(o,n))if(!1!==$.update.call(o,n)){if(n.position.call(o,n,e,t),n.zIndex){var s=n.zIndex;"function"==typeof n.zIndex&&(s=n.zIndex.call(o,n)),a.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&&!(-1<"html body".indexOf(n.prop("nodeName").toLowerCase())););return t}(o)+s}$.layer.call(n.$menu,n,a.zIndex),n.$menu.find("ul").css("zIndex",a.zIndex+1),n.$menu.css(a)[n.animation.show](n.animation.duration,function(){o.trigger("contextmenu:visible"),$.activated(n),n.events.activated(n)}),o.data("contextMenu",n).addClass("context-menu-active"),m(document).off("keydown.contextMenu").on("keydown.contextMenu",b.key),n.autoHide&&m(document).on("mousemove.contextMenuAutoHide",function(e){var t=o.offset();t.right=t.left+o.outerWidth(),t.bottom=t.top+o.outerHeight(),!n.$layer||n.hovering||e.pageX>=t.left&&e.pageX<=t.right&&e.pageY>=t.top&&e.pageY<=t.bottom||setTimeout(function(){n.hovering||null===n.$menu||void 0===n.$menu||n.$menu.trigger("contextmenu:hide")},50)})}else c=null;else c=null},hide:function(t,e){var n=m(this);if(t=t||(n.data("contextMenu")||{}),e||!t.events||!1!==t.events.hide.call(n,t)){if(n.removeData("contextMenu").removeClass("context-menu-active"),t.$layer){setTimeout((o=t.$layer,function(){o.remove()}),10);try{delete t.$layer}catch(e){t.$layer=null}}var o;c=null,t.$menu.find("."+t.classNames.hover).trigger("contextmenu:blur"),t.$selected=null,t.$menu.find("."+t.classNames.visible).removeClass(t.classNames.visible),m(document).off(".contextMenuAutoHide").off("keydown.contextMenu"),t.$menu&&t.$menu[t.animation.hide](t.animation.duration,function(){t.build&&(t.$menu.remove(),m.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(){n.trigger("contextmenu:hidden")},10)})}},create:function(r,u){function d(e){var t=m("");if(e._accesskey)e._beforeAccesskey&&t.append(document.createTextNode(e._beforeAccesskey)),m("").addClass("context-menu-accesskey").text(e._accesskey).appendTo(t),e._afterAccesskey&&t.append(document.createTextNode(e._afterAccesskey));else if(e.isHtmlName){if(void 0!==e.accesskey)throw new Error("accesskeys are not compatible with HTML names and cannot be used together in the same item");t.html(e.name)}else t.text(e.name);return t}void 0===u&&(u=r),r.$menu=m('').addClass(r.className||"").data({contextMenu:r,contextMenuRoot:u}),r.dataAttr&&m.each(r.dataAttr,function(e,t){r.$menu.attr("data-"+r.key,t)}),m.each(["callbacks","commands","inputs"],function(e,t){r[t]={},u[t]||(u[t]={})}),u.accesskeys||(u.accesskeys={}),m.each(r.items,function(n,o){var e=m('
  • ').addClass(o.className||""),t=null,a=null;if(e.on("click",m.noop),"string"!=typeof o&&"cm_separator"!==o.type||(o={type:"cm_seperator"}),o.$node=e.data({contextMenu:r,contextMenuRoot:u,contextMenuKey:n}),void 0!==o.accesskey)for(var s,i=function(e){for(var t,n=e.split(/\s+/),o=[],a=0;t=n[a];a++)t=t.charAt(0).toUpperCase(),o.push(t);return o}(o.accesskey),c=0;s=i[c];c++)if(!u.accesskeys[s]){var l=(u.accesskeys[s]=o).name.match(new RegExp("^(.*?)("+s+")(.*)$","i"));l&&(o._beforeAccesskey=l[1],o._accesskey=l[2],o._afterAccesskey=l[3]);break}if(o.type&&v[o.type])v[o.type].call(e,o,r,u),m.each([r,u],function(e,t){t.commands[n]=o,!m.isFunction(o.callback)||void 0!==t.callbacks[n]&&void 0!==r.type||(t.callbacks[n]=o.callback)});else{switch("cm_seperator"===o.type?e.addClass("context-menu-separator "+u.classNames.notSelectable):"html"===o.type?e.addClass("context-menu-html "+u.classNames.notSelectable):"sub"!==o.type&&o.type?(t=m("").appendTo(e),d(o).appendTo(t),e.addClass("context-menu-input"),r.hasTypes=!0,m.each([r,u],function(e,t){t.commands[n]=o,t.inputs[n]=o})):o.items&&(o.type="sub"),o.type){case"cm_seperator":break;case"text":a=m('').attr("name","context-menu-input-"+n).val(o.value||"").appendTo(t);break;case"textarea":a=m('').attr("name","context-menu-input-"+n).val(o.value||"").appendTo(t),o.height&&a.height(o.height);break;case"checkbox":a=m('').attr("name","context-menu-input-"+n).val(o.value||"").prop("checked",!!o.selected).prependTo(t);break;case"radio":a=m('').attr("name","context-menu-input-"+o.radio).val(o.value||"").prop("checked",!!o.selected).prependTo(t);break;case"select":a=m('').attr("name","context-menu-input-"+n).appendTo(t),o.options&&(m.each(o.options,function(e,t){m("").val(e).text(t).appendTo(a)}),a.val(o.selected));break;case"sub":d(o).appendTo(e),o.appendTo=o.$node,e.data("contextMenu",o).addClass("context-menu-submenu"),o.callback=null,"function"==typeof o.items.then?$.processPromises(o,u,o.items):$.create(o,u);break;case"html":m(o.html).appendTo(e);break;default:m.each([r,u],function(e,t){t.commands[n]=o,!m.isFunction(o.callback)||void 0!==t.callbacks[n]&&void 0!==r.type||(t.callbacks[n]=o.callback)}),d(o).appendTo(e)}o.type&&"sub"!==o.type&&"html"!==o.type&&"cm_seperator"!==o.type&&(a.on("focus",b.focusInput).on("blur",b.blurInput),o.events&&a.on(o.events,r)),o.icon&&(m.isFunction(o.icon)?o._icon=o.icon.call(this,this,e,n,o):"string"!=typeof o.icon||"fab "!==o.icon.substring(0,4)&&"fas "!==o.icon.substring(0,4)&&"fad "!==o.icon.substring(0,4)&&"far "!==o.icon.substring(0,4)&&"fal "!==o.icon.substring(0,4)?"string"==typeof o.icon&&"fa-"===o.icon.substring(0,3)?o._icon=u.classNames.icon+" "+u.classNames.icon+"--fa fa "+o.icon:o._icon=u.classNames.icon+" "+u.classNames.icon+"-"+o.icon:(e.addClass(u.classNames.icon+" "+u.classNames.icon+"--fa5"),o._icon=m('')),"string"==typeof o._icon?e.addClass(o._icon):e.prepend(o._icon))}o.$input=a,o.$label=t,e.appendTo(r.$menu),!r.hasTypes&&m.support.eventSelectstart&&e.on("selectstart.disableTextSelect",b.abortevent)}),r.$node||r.$menu.css("display","none").addClass("context-menu-root"),r.$menu.appendTo(r.appendTo||document.body)},resize:function(e,t){var n;e.css({position:"absolute",display:"block"}),e.data("width",(n=e.get(0)).getBoundingClientRect?Math.ceil(n.getBoundingClientRect().width):e.outerWidth()+1),e.css({position:"static",minWidth:"0px",maxWidth:"100000px"}),e.find("> li > ul").each(function(){$.resize(m(this),!0)}),t||e.find("ul").addBack().css({position:"",display:"",minWidth:"",maxWidth:""}).outerWidth(function(){return m(this).data("width")})},update:function(i,c){var l=this;void 0===c&&(c=i,$.resize(i.$menu));var r=!1;return i.$menu.children().each(function(){var e,t=m(this),n=t.data("contextMenuKey"),o=i.items[n],a=m.isFunction(o.disabled)&&o.disabled.call(l,n,c)||!0===o.disabled;if((e=m.isFunction(o.visible)?o.visible.call(l,n,c):void 0===o.visible||!0===o.visible)&&(r=!0),t[e?"show":"hide"](),t[a?"addClass":"removeClass"](c.classNames.disabled),m.isFunction(o.icon)){t.removeClass(o._icon);var s=o.icon.call(this,l,t,n,o);"string"==typeof s?t.addClass(s):t.prepend(s)}if(o.type)switch(t.find("input, select, textarea").prop("disabled",a),o.type){case"text":case"textarea":o.$input.val(o.value||"");break;case"checkbox":case"radio":o.$input.val(o.value||"").prop("checked",!!o.selected);break;case"select":o.$input.val((0===o.selected?"0":o.selected)||"")}o.$menu&&$.update.call(l,o,c)&&(r=!0)}),r},layer:function(e,t){var n=e.$layer=m('
    ').css({height:p.height(),width:p.width(),display:"block",position:"fixed","z-index":t-1,top:0,left:0,opacity:0,filter:"alpha(opacity=0)","background-color":"#000"}).data("contextMenuRoot",e).appendTo(document.body).on("contextmenu",b.abortevent).on("mousedown",b.layerClick);return void 0===document.body.style.maxWidth&&n.css({position:"absolute",height:m(document).height()}),n},processPromises:function(e,t,n){function o(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}}),a(e,t,n)}function a(e,t,n){void 0!==t.$menu&&t.$menu.is(":visible")&&(e.$node.removeClass(t.classNames.iconLoadingClass),e.items=n,$.create(e,t,!0),$.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&&o(void 0),a(e,t,n)}.bind(this,e,t),o.bind(this,e,t))},activated:function(e){var t=e.$menu,n=t.offset(),o=m(window).height(),a=m(window).scrollTop(),s=t.height();oa+o)&&t.css({top:a+"px"})}};function l(e){return e.id&&m('label[for="'+e.id+'"]').val()||e.name}m.fn.contextMenu=function(e){var t=this,n=e;if(0{"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)})(function(d){d.support.htmlMenuitem="HTMLMenuItemElement"in window,d.support.htmlCommand="HTMLCommandElement"in window,d.support.eventSelectstart="onselectstart"in document.documentElement,d.ui&&d.widget||(d.cleanData=(a=d.cleanData,function(e){for(var t,n,o=0;null!=e[o];o++){n=e[o];try{(t=d._data(n,"events"))&&t.remove&&d(n).triggerHandler("remove")}catch(e){}}a(e)}));var a,s=null,m=!1,p=d(window),h=0,f={},g={},x={},v={selector:null,appendTo:null,trigger:"right",shadow:!0,async:!0,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(e){var t;d.ui&&d.ui.position?e.css("display","block").position({my:"center top",at:"center bottom",of:this,offset:"0 5",collision:"fit"}).css("display","none"):((t=this.offset()).top+=this.outerHeight(),t.left+=this.outerWidth()/2-e.outerWidth()/2,e.css(t))},position:function(e,t,n){var o,a,s;t||n?(t="maintain"===t&&"maintain"===n?e.$menu.position():{top:n-(n=e.$menu.offsetParent().offset()).top,left:t-n.left},n=p.scrollTop()+p.height(),o=p.scrollLeft()+p.width(),a=e.$menu.outerHeight(),s=e.$menu.outerWidth(),t.top+a>n&&(t.top-=a),t.top<0&&(t.top=0),t.left+s>o&&(t.left-=s),t.left<0&&(t.left=0),e.$menu.css(t)):e.determinePosition.call(this,e.$menu)},positionSubmenu:function(e){var t;void 0!==e&&(d.ui&&d.ui.position?e.css("display","block").position({my:"left top-5",at:"right top",of:this,collision:"flipfit fit"}).css("display",""):(t={top:-9,left:this.outerWidth()-5},e.css(t)))},zIndex:1,animation:{duration:50,show:"slideDown",hide:"slideUp"},events:{preShow:d.noop,show:d.noop,hide:d.noop,activated:d.noop},callback:null,items:{}},i={timer:null,pageX:null,pageY:null},b={abortevent:function(e){e.preventDefault(),e.stopImmediatePropagation()},contextmenu:function(e){var t=d(this);if(!1!==e.data.events.preShow(t,e)&&("right"===e.data.trigger&&(e.preventDefault(),e.stopImmediatePropagation()),!("right"!==e.data.trigger&&"demand"!==e.data.trigger&&e.originalEvent||!(void 0===e.mouseButton||!e.data||"left"===e.data.trigger&&0===e.mouseButton||"right"===e.data.trigger&&2===e.mouseButton)||t.hasClass("context-menu-active")||t.hasClass("context-menu-disabled")))){if(s=t,e.data.build){var n=e.data.build(s,e);if(!1===n)return;if(e.data=d.extend(!0,{},v,e.data,n||{}),!e.data.items||d.isEmptyObject(e.data.items))throw window.console&&(console.error||console.log).call(console,"No items specified to show in contextMenu"),new Error("No Items specified");e.data.$trigger=s,$.create(e.data)}$.show.call(t,e.data,e.pageX,e.pageY)}},click:function(e){e.preventDefault(),e.stopImmediatePropagation(),d(this).trigger(d.Event("contextmenu",{data:e.data,pageX:e.pageX,pageY:e.pageY}))},mousedown:function(e){var t=d(this);s&&s.length&&!s.is(t)&&b.hideMenu.call(s.data("contextMenu").$menu),2===e.button&&(s=t.data("contextMenuActive",!0))},mouseup:function(e){var t=d(this);t.data("contextMenuActive")&&s&&s.length&&s.is(t)&&!t.hasClass("context-menu-disabled")&&(e.preventDefault(),e.stopImmediatePropagation(),(s=t).trigger(d.Event("contextmenu",{data:e.data,pageX:e.pageX,pageY:e.pageY}))),t.removeData("contextMenuActive")},mouseenter:function(e){var t=d(this),n=d(e.relatedTarget),o=d(document);n.is(".context-menu-list")||n.closest(".context-menu-list").length||s&&s.length||(i.pageX=e.pageX,i.pageY=e.pageY,i.data=e.data,o.on("mousemove.contextMenuShow",b.mousemove),i.timer=setTimeout(function(){i.timer=null,o.off("mousemove.contextMenuShow"),(s=t).trigger(d.Event("contextmenu",{data:i.data,pageX:i.pageX,pageY:i.pageY}))},e.data.delay))},mousemove:function(e){i.pageX=e.pageX,i.pageY=e.pageY},mouseleave:function(e){var t=d(e.relatedTarget);if(!t.is(".context-menu-list")&&!t.closest(".context-menu-list").length){try{clearTimeout(i.timer)}catch(e){}i.timer=null}},layerClick:function(o){var a,s,i=d(this).data("contextMenuRoot"),c=o.button,l=o.pageX,r=o.pageY,u=void 0===l;if(o.preventDefault(),i.async)setTimeout(function(){if(u)null!=i&&null!=i.$menu&&b.hideMenu.call(i.$menu);else{var e,t,n="left"===i.trigger&&0===c||"right"===i.trigger&&2===c;if(document.elementFromPoint&&i.$layer&&(i.$layer.hide(),null!==(a=document.elementFromPoint(l-p.scrollLeft(),r-p.scrollTop()))&&a.isContentEditable&&(e=document.createRange(),t=window.getSelection(),e.selectNode(a),e.collapse(!0),t.removeAllRanges(),t.addRange(e)),d(a).trigger(o),i.$layer.show()),i.hideOnSecondTrigger&&n&&null!=i.$menu)b.hideMenu.call(i.$menu);else{if(i.reposition&&n)if(document.elementFromPoint){if(i.$trigger.is(a))return void i.position.call(i.$trigger,i,l,r)}else if(s=i.$trigger.offset(),t=d(window),s.top+=t.scrollTop(),s.top<=o.pageY&&(s.left+=t.scrollLeft(),s.left<=o.pageX)&&(s.bottom=s.top+i.$trigger.outerHeight(),s.bottom>=o.pageY)&&(s.right=s.left+i.$trigger.outerWidth(),s.right>=o.pageX))return void i.position.call(i.$trigger,i,l,r);a&&n&&i.$trigger.one("contextmenu:hidden",function(){d(a).contextMenu({x:l,y:r,button:c})}),null!=i&&null!=i.$menu&&b.hideMenu.call(i.$menu)}}},50);else if(u)null!=i&&null!=i.$menu&&b.hideMenu.call(i.$menu);else{var e,t,n="left"===i.trigger&&0===c||"right"===i.trigger&&2===c;if(document.elementFromPoint&&i.$layer&&(i.$layer.hide(),null!==(a=document.elementFromPoint(l-p.scrollLeft(),r-p.scrollTop()))&&a.isContentEditable&&(e=document.createRange(),t=window.getSelection(),e.selectNode(a),e.collapse(!0),t.removeAllRanges(),t.addRange(e)),d(a).trigger(o),i.$layer.show()),i.hideOnSecondTrigger&&n&&null!=i.$menu)b.hideMenu.call(i.$menu);else{if(i.reposition&&n)if(document.elementFromPoint){if(i.$trigger.is(a))return void i.position.call(i.$trigger,i,l,r)}else if(s=i.$trigger.offset(),t=d(window),s.top+=t.scrollTop(),s.top<=o.pageY&&(s.left+=t.scrollLeft(),s.left<=o.pageX)&&(s.bottom=s.top+i.$trigger.outerHeight(),s.bottom>=o.pageY)&&(s.right=s.left+i.$trigger.outerWidth(),s.right>=o.pageX))return void i.position.call(i.$trigger,i,l,r);a&&n&&i.$trigger.one("contextmenu:hidden",function(){d(a).contextMenu({x:l,y:r,button:c})}),null!=i&&null!=i.$menu&&b.hideMenu.call(i.$menu)}}},keyStop:function(e,t){t.isInput||e.preventDefault(),e.stopPropagation()},key:function(e){function t(e){""!==e.style.zIndex?o=e.style.zIndex:null!=e.offsetParent?t(e.offsetParent):null!=e.parentElement&&t(e.parentElement)}var n={},o=(void 0===(n=s?s.data("contextMenu")||{}:n).zIndex&&(n.zIndex=0),0);if(t(e.target),!(n.$menu&&parseInt(o,10)>parseInt(n.$menu.css("zIndex"),10))){switch(e.keyCode){case 9:case 38:if(b.keyStop(e,n),n.isInput){if(9===e.keyCode&&e.shiftKey)return e.preventDefault(),n.$selected&&n.$selected.find("input, textarea, select").blur(),void(null!=n.$menu&&b.prevItem.call(n.$menu));if(38===e.keyCode&&"checkbox"===n.$selected.find("input, textarea, select").prop("type"))return void e.preventDefault()}else if(9!==e.keyCode||e.shiftKey)return void(null!=n.$menu&&b.prevItem.call(n.$menu));break;case 40:if(b.keyStop(e,n),!n.isInput)return void(null!=n.$menu&&b.nextItem.call(n.$menu));if(9===e.keyCode)return e.preventDefault(),n.$selected&&n.$selected.find("input, textarea, select").blur(),void(null!=n.$menu&&b.nextItem.call(n.$menu));if(40===e.keyCode&&"checkbox"===n.$selected.find("input, textarea, select").prop("type"))return void e.preventDefault();break;case 37:if(b.keyStop(e,n),n.isInput||!n.$selected||!n.$selected.length)break;if(n.$selected.parent().hasClass("context-menu-root"))break;return a=n.$selected.parent().parent(),n.$selected.trigger("contextmenu:blur"),void(n.$selected=a);case 39:if(b.keyStop(e,n),!n.isInput&&n.$selected&&n.$selected.length){var a=n.$selected.data("contextMenu")||{};if(a.$menu&&n.$selected.hasClass("context-menu-submenu"))return n.$selected=null,a.$selected=null,void b.nextItem.call(a.$menu)}break;case 35:case 36:return n.$selected&&n.$selected.find("input, textarea, select").length?void 0:((n.$selected&&n.$selected.parent()||n.$menu).children(":not(."+n.classNames.disabled+", ."+n.classNames.notSelectable+")")[36===e.keyCode?"first":"last"]().trigger("contextmenu:focus"),void e.preventDefault());case 13:if(b.keyStop(e,n),n.isInput){if(n.$selected&&!n.$selected.is("textarea, select"))return void e.preventDefault();break}return void(null!=n.$selected&&n.$selected.trigger("mouseup"));case 32:case 33:case 34:return void b.keyStop(e,n);case 27:return b.keyStop(e,n),void(null!=n.$menu&&b.hideMenu.call(n.$menu));default:a=String.fromCharCode(e.keyCode).toUpperCase();if(n.accesskeys&&n.accesskeys[a])return void n.accesskeys[a].$node.trigger(n.accesskeys[a].$menu?"contextmenu:focus":"mouseup")}e.stopPropagation(),null!=n.$selected&&n.$selected.trigger(e)}},prevItem:function(e){e.stopPropagation();for(var t=d(this).data("contextMenu")||{},n=d(this).data("contextMenuRoot")||{},o=(t.$selected&&(i=t.$selected,(t=t.$selected.parent().data("contextMenu")||{}).$selected=i),t.$menu.children()),a=t.$selected&&t.$selected.prev().length?t.$selected.prev():o.last(),s=a;a.hasClass(n.classNames.disabled)||a.hasClass(n.classNames.notSelectable)||a.is(":hidden");)if((a=a.prev().length?a.prev():o.last()).is(s))return;t.$selected&&b.itemMouseleave.call(t.$selected.get(0),e),b.itemMouseenter.call(a.get(0),e);var i=a.find("input, textarea, select");i.length&&i.focus()},nextItem:function(e){e.stopPropagation();for(var t=d(this).data("contextMenu")||{},n=d(this).data("contextMenuRoot")||{},o=(t.$selected&&(i=t.$selected,(t=t.$selected.parent().data("contextMenu")||{}).$selected=i),t.$menu.children()),a=t.$selected&&t.$selected.next().length?t.$selected.next():o.first(),s=a;a.hasClass(n.classNames.disabled)||a.hasClass(n.classNames.notSelectable)||a.is(":hidden");)if((a=a.next().length?a.next():o.first()).is(s))return;t.$selected&&b.itemMouseleave.call(t.$selected.get(0),e),b.itemMouseenter.call(a.get(0),e);var i=a.find("input, textarea, select");i.length&&i.focus()},focusInput:function(){var e=d(this).closest(".context-menu-item"),t=e.data(),n=t.contextMenu,t=t.contextMenuRoot;t.$selected=n.$selected=e,t.isInput=n.isInput=!0},blurInput:function(){var e=d(this).closest(".context-menu-item").data(),t=e.contextMenu;e.contextMenuRoot.isInput=t.isInput=!1},menuMouseenter:function(){d(this).data().contextMenuRoot.hovering=!0},menuMouseleave:function(e){var t=d(this).data().contextMenuRoot;t.$layer&&t.$layer.is(e.relatedTarget)&&(t.hovering=!1)},itemMouseenter:function(e){var t=d(this),n=t.data(),o=n.contextMenu,n=n.contextMenuRoot;n.hovering=!0,e&&n.$layer&&n.$layer.is(e.relatedTarget)&&(e.preventDefault(),e.stopImmediatePropagation()),(o.$menu?o:n).$menu.children("."+n.classNames.hover).trigger("contextmenu:blur").children(".hover").trigger("contextmenu:blur"),t.hasClass(n.classNames.disabled)||t.hasClass(n.classNames.notSelectable)?o.$selected=null:t.trigger("contextmenu:focus")},itemMouseleave:function(e){var t=d(this),n=t.data(),o=n.contextMenu,n=n.contextMenuRoot;n!==o&&n.$layer&&n.$layer.is(e.relatedTarget)?(null!=n.$selected&&n.$selected.trigger("contextmenu:blur"),e.preventDefault(),e.stopImmediatePropagation(),n.$selected=o.$selected=o.$node):o&&o.$menu&&o.$menu.hasClass("context-menu-visible")||t.trigger("contextmenu:blur")},itemClick:function(e){var t,n=d(this),o=n.data(),a=o.contextMenu,s=o.contextMenuRoot,o=o.contextMenuKey;if(!(!a.items[o]||n.is("."+s.classNames.disabled+", .context-menu-separator, ."+s.classNames.notSelectable)||n.is(".context-menu-submenu")&&!1===s.selectableSubMenu)){if(e.preventDefault(),e.stopImmediatePropagation(),d.isFunction(a.callbacks[o])&&Object.prototype.hasOwnProperty.call(a.callbacks,o))t=a.callbacks[o];else{if(!d.isFunction(s.callback))return;t=s.callback}!1!==t.call(s.$trigger,o,s,e)?b.hideMenu.call(s.$menu):s.$menu.parent().length&&$.update.call(s.$trigger,s)}},inputClick:function(e){e.stopImmediatePropagation()},hideMenu:function(e,t){var n=d(this).data("contextMenuRoot");$.hide.call(n.$trigger,n,t&&t.force)},focusItem:function(e){e.stopPropagation();var e=d(this),t=e.data(),n=t.contextMenu,t=t.contextMenuRoot;e.hasClass(t.classNames.disabled)||e.hasClass(t.classNames.notSelectable)||(e.addClass([t.classNames.hover,t.classNames.visible].join(" ")).parent().find(".context-menu-item").not(e).removeClass(t.classNames.visible).filter("."+t.classNames.hover).trigger("contextmenu:blur"),n.$selected=t.$selected=e,n&&n.$node&&n.$node.hasClass("context-menu-submenu")&&n.$node.addClass(t.classNames.hover),n.$node&&t.positionSubmenu.call(n.$node,n.$menu))},blurItem:function(e){e.stopPropagation();var e=d(this),t=e.data(),n=t.contextMenu,t=t.contextMenuRoot;n.autoHide&&e.removeClass(t.classNames.visible),e.removeClass(t.classNames.hover),n.$selected=null}},$={show:function(n,e,t){var o=d(this),a={};n.shadow||d("#context-menu-layer").trigger("mousedown"),n.$trigger=o,!1===n.events.show.call(o,n)||!1===$.update.call(o,n)?s=null:(n.position.call(o,n,e,t),n.zIndex&&(e=n.zIndex,"function"==typeof n.zIndex&&(e=n.zIndex.call(o,n)),a.zIndex=(e=>{for(var t=0,n=e;t=Math.max(t,parseInt(n.css("z-index"),10)||0),(n=n.parent())&&n.length&&!(-1<"html body".indexOf(n.prop("nodeName").toLowerCase())););return t})(o)+e),$.layer.call(n.$menu,n,a.zIndex),n.$menu.find("ul").css("zIndex",a.zIndex+1),n.async?n.$menu.css(a)[n.animation.show](n.animation.duration,function(){o.trigger("contextmenu:visible"),$.activated(n),n.events.activated(n)}):(n.$menu.show(),o.trigger("contextmenu:visible"),$.activated(n),n.events.activated(n)),o.data("contextMenu",n).addClass("context-menu-active"),d(document).off("keydown.contextMenu").on("keydown.contextMenu",b.key),n.autoHide&&d(document).on("mousemove.contextMenuAutoHide",function(e){var t=o.offset();t.right=t.left+o.outerWidth(),t.bottom=t.top+o.outerHeight(),!n.$layer||n.hovering||e.pageX>=t.left&&e.pageX<=t.right&&e.pageY>=t.top&&e.pageY<=t.bottom||setTimeout(function(){n.hovering||null==n.$menu||b.hideMenu.call(n.$menu)},50)}))},hide:function(t,e){var n,o=d(this);if(t=t||o.data("contextMenu")||{},e||!t.events||!1!==t.events.hide.call(o,t)){if(o.removeData("contextMenu").removeClass("context-menu-active"),t.$layer){t.async?setTimeout((n=t.$layer,function(){n.remove()}),10):t.$layer.remove();try{delete t.$layer}catch(e){t.$layer=null}}s=null,t.$menu.find("."+t.classNames.hover).trigger("contextmenu:blur"),t.$selected=null,t.$menu.find("."+t.classNames.visible).removeClass(t.classNames.visible),d(document).off(".contextMenuAutoHide").off("keydown.contextMenu"),t.$menu&&(t.async?t.$menu[t.animation.hide](t.animation.duration,function(){t.build&&(t.$menu.remove(),d.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)}):(t.build&&(t.$menu.remove(),d.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}})),o.trigger("contextmenu:hidden")))}},create:function(l,r){function u(e){var t=d("");if(e._accesskey)e._beforeAccesskey&&t.append(document.createTextNode(e._beforeAccesskey)),d("").addClass("context-menu-accesskey").text(e._accesskey).appendTo(t),e._afterAccesskey&&t.append(document.createTextNode(e._afterAccesskey));else if(e.isHtmlName){if(void 0!==e.accesskey)throw new Error("accesskeys are not compatible with HTML names and cannot be used together in the same item");t.html(e.name)}else t.text(e.name);return t}void 0===r&&(r=l),l.$menu=d('
      ').addClass(l.className||"").data({contextMenu:l,contextMenuRoot:r}),l.dataAttr&&d.each(l.dataAttr,function(e,t){l.$menu.attr("data-"+l.key,t)}),d.each(["callbacks","commands","inputs"],function(e,t){l[t]={},r[t]||(r[t]={})}),r.accesskeys||(r.accesskeys={}),d.each(l.items,function(n,o){var e=d('
    • ').addClass(o.className||""),t=null,a=null;if(e.on("click",d.noop),(o="string"!=typeof o&&"cm_separator"!==o.type?o:{type:"cm_seperator"}).$node=e.data({contextMenu:l,contextMenuRoot:r,contextMenuKey:n}),void 0!==o.accesskey)for(var s=(e=>{for(var t,n=e.split(/\s+/),o=[],a=0;t=n[a];a++)t=t.charAt(0).toUpperCase(),o.push(t);return o})(o.accesskey),i=0;c=s[i];i++)if(!r.accesskeys[c]){var c=(r.accesskeys[c]=o).name.match(new RegExp("^(.*?)("+c+")(.*)$","i"));c&&(o._beforeAccesskey=c[1],o._accesskey=c[2],o._afterAccesskey=c[3]);break}if(o.type&&x[o.type])x[o.type].call(e,o,l,r),d.each([l,r],function(e,t){t.commands[n]=o,!d.isFunction(o.callback)||void 0!==t.callbacks[n]&&void 0!==l.type||(t.callbacks[n]=o.callback)});else{switch("cm_seperator"===o.type?e.addClass("context-menu-separator "+r.classNames.notSelectable):"html"===o.type?e.addClass("context-menu-html "+r.classNames.notSelectable):"sub"!==o.type&&o.type?(t=d("").appendTo(e),u(o).appendTo(t),e.addClass("context-menu-input"),l.hasTypes=!0,d.each([l,r],function(e,t){t.commands[n]=o,t.inputs[n]=o})):o.items&&(o.type="sub"),o.type){case"cm_seperator":break;case"text":a=d('').attr("name","context-menu-input-"+n).val(o.value||"").appendTo(t);break;case"textarea":a=d('').attr("name","context-menu-input-"+n).val(o.value||"").appendTo(t),o.height&&a.height(o.height);break;case"checkbox":a=d('').attr("name","context-menu-input-"+n).val(o.value||"").prop("checked",!!o.selected).prependTo(t);break;case"radio":a=d('').attr("name","context-menu-input-"+o.radio).val(o.value||"").prop("checked",!!o.selected).prependTo(t);break;case"select":a=d('').attr("name","context-menu-input-"+n).appendTo(t),o.options&&(d.each(o.options,function(e,t){d("").val(e).text(t).appendTo(a)}),a.val(o.selected));break;case"sub":u(o).appendTo(e),o.appendTo=o.$node,e.data("contextMenu",o).addClass("context-menu-submenu"),o.callback=null,"function"==typeof o.items.then?$.processPromises(o,r,o.items):$.create(o,r);break;case"html":d(o.html).appendTo(e);break;default:d.each([l,r],function(e,t){t.commands[n]=o,!d.isFunction(o.callback)||void 0!==t.callbacks[n]&&void 0!==l.type||(t.callbacks[n]=o.callback)}),u(o).appendTo(e)}o.type&&"sub"!==o.type&&"html"!==o.type&&"cm_seperator"!==o.type&&(a.on("focus",b.focusInput).on("blur",b.blurInput),o.events)&&a.on(o.events,l),o.icon&&(d.isFunction(o.icon)?o._icon=o.icon.call(this,this,e,n,o):"string"!=typeof o.icon||"fab "!==o.icon.substring(0,4)&&"fas "!==o.icon.substring(0,4)&&"fad "!==o.icon.substring(0,4)&&"far "!==o.icon.substring(0,4)&&"fal "!==o.icon.substring(0,4)?"string"==typeof o.icon&&"fa-"===o.icon.substring(0,3)?o._icon=r.classNames.icon+" "+r.classNames.icon+"--fa fa "+o.icon:o._icon=r.classNames.icon+" "+r.classNames.icon+"-"+o.icon:(e.addClass(r.classNames.icon+" "+r.classNames.icon+"--fa5"),o._icon=d('')),"string"==typeof o._icon?e.addClass(o._icon):e.prepend(o._icon))}o.$input=a,o.$label=t,e.appendTo(l.$menu),!l.hasTypes&&d.support.eventSelectstart&&e.on("selectstart.disableTextSelect",b.abortevent)}),l.$node||l.$menu.css("display","none").addClass("context-menu-root"),l.$menu.appendTo(l.appendTo||document.body)},resize:function(e,t){var n;e.css({position:"absolute",display:"block"}),e.data("width",(n=e.get(0)).getBoundingClientRect?Math.ceil(n.getBoundingClientRect().width):e.outerWidth()+1),e.css({position:"static",minWidth:"0px",maxWidth:"100000px"}),e.find("> li > ul").each(function(){$.resize(d(this),!0)}),t||e.find("ul").addBack().css({position:"",display:"",minWidth:"",maxWidth:""}).outerWidth(function(){return d(this).data("width")})},update:function(s,i){var c=this,l=(void 0===i&&(i=s,$.resize(s.$menu)),!1);return s.$menu.children().each(function(){var e=d(this),t=e.data("contextMenuKey"),n=s.items[t],o=d.isFunction(n.disabled)&&n.disabled.call(c,t,i)||!0===n.disabled,a=d.isFunction(n.visible)?n.visible.call(c,t,i):void 0===n.visible||!0===n.visible;if(a&&(l=!0),e[a?"show":"hide"](),e[o?"addClass":"removeClass"](i.classNames.disabled),d.isFunction(n.icon)&&(e.removeClass(n._icon),"string"==typeof(a=n.icon.call(this,c,e,t,n))?e.addClass(a):e.prepend(a)),n.type)switch(e.find("input, select, textarea").prop("disabled",o),n.type){case"text":case"textarea":n.$input.val(n.value||"");break;case"checkbox":case"radio":n.$input.val(n.value||"").prop("checked",!!n.selected);break;case"select":n.$input.val((0===n.selected?"0":n.selected)||"")}n.$menu&&$.update.call(c,n,i)&&(l=!0)}),l},layer:function(e,t){return e.shadow?(t=e.$layer=d('
      ').css({height:"100%",width:"100%",display:"block",position:"fixed","z-index":t-1,top:0,left:0,opacity:0,filter:"alpha(opacity=0)","background-color":"#000"}).data("contextMenuRoot",e).appendTo(document.body).on("contextmenu",b.abortevent).on("mousedown",b.layerClick),void 0===document.body.style.maxWidth&&t.css({position:"absolute",height:d(document).height()}),t):null},processPromises:function(e,t,n){function o(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}}),a(e,t,n)}function a(e,t,n){void 0!==t.$menu&&t.$menu.is(":visible")&&(e.$node.removeClass(t.classNames.iconLoadingClass),e.items=n,$.create(e,t,!0),$.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&&o(void 0),a(e,t,n)}.bind(this,e,t),o.bind(this,e,t))},activated:function(e){var e=e.$menu,t=e.offset(),n=d(window).height(),o=d(window).width(),a=d(window).scrollTop(),s=d(window).scrollLeft(),i=e.height(),c=e.outerHeight(),l=e.outerWidth();na+n&&e.css({top:t.top-(t.top+c-(a+n))+"px"}),t.left+l>s+o&&e.css({left:t.left-(t.left+l-(s+o))+"px"})}};function l(e){return e.id&&d('label[for="'+e.id+'"]').val()||e.name}d.fn.contextMenu=function(e){var t,n=this,o=e;return 0 .mixly-footerbar { width: 100%; height: var(--footer-height); - z-index: 1000; } html[data-bs-theme=dark] div[m-id="{{d.mId}}"] > .mixly-footerbar { diff --git a/common/templates/html/dialog/shadow-all.html b/common/templates/html/dialog/shadow-all.html index 92823826..4c935b67 100644 --- a/common/templates/html/dialog/shadow-all.html +++ b/common/templates/html/dialog/shadow-all.html @@ -6,7 +6,7 @@ right: 0px; bottom: 0px; background: transparent; - z-index: 100; + z-index: 400; }
      \ No newline at end of file diff --git a/common/templates/html/dialog/shadow-nav.html b/common/templates/html/dialog/shadow-nav.html index 5bc3c180..77d5777c 100644 --- a/common/templates/html/dialog/shadow-nav.html +++ b/common/templates/html/dialog/shadow-nav.html @@ -6,7 +6,7 @@ height: var(--nav-height); width: 100%; background: transparent; - z-index: 100; + z-index: 400; }
      \ No newline at end of file diff --git a/common/templates/html/nav/nav-item-container.html b/common/templates/html/nav/nav-item-container.html index 3e6d7154..b51f3403 100644 --- a/common/templates/html/nav/nav-item-container.html +++ b/common/templates/html/nav/nav-item-container.html @@ -2,7 +2,4 @@ {{d.text}} -
      - -
      \ No newline at end of file diff --git a/common/templates/html/nav/nav.html b/common/templates/html/nav/nav.html index da96e3ca..4d973808 100644 --- a/common/templates/html/nav/nav.html +++ b/common/templates/html/nav/nav.html @@ -63,7 +63,7 @@ } ul[m-id="{{d.mId}}"] button > a { - color: rgba(255,255,255,.7); + color: rgba(255, 255, 255, .7); -webkit-transition: all .3s; } @@ -106,14 +106,25 @@ align-items: center; } - ul[m-id="{{d.mId}}"] .left-btn-container { + ul[m-id="{{d.mId}}"] > div > .left-btn-container, + ul[m-id="{{d.mId}}"] > .right-area > .right-menu-container { display: inline-flex; } - ul[m-id="{{d.mId}}"] .left-btn-container button { + ul[m-id="{{d.mId}}"] > div > .left-btn-container > button[m-id="home-btn"] { + font-size: 18px; + } + + ul[m-id="{{d.mId}}"] > .right-area > .right-menu-container { + margin-left: 10px; + z-index: 2000; + } + + ul[m-id="{{d.mId}}"] > div > .left-btn-container > button, + ul[m-id="{{d.mId}}"] > .right-area > .right-menu-container > button { font-family: "Lato", "Noto Sans SC"; height: var(--nav-left-btn-height); - font-size: calc(var(--nav-left-btn-font-size) + 4px); + font-size: 14px; margin: 2px; } diff --git a/common/templates/html/nav/shadow.html b/common/templates/html/nav/shadow.html new file mode 100644 index 00000000..2b5c4197 --- /dev/null +++ b/common/templates/html/nav/shadow.html @@ -0,0 +1,11 @@ + +
      \ No newline at end of file diff --git a/main.js b/main.js index 9cfadb30..472fa017 100644 --- a/main.js +++ b/main.js @@ -102,12 +102,12 @@ function createWindow(filePath = null, indexUrl = null) { else win.loadFile('./src/index.html'); - //打开或关闭开发者工具 + // 打开或关闭开发者工具 electronLocalshortcut.register(win, 'CmdOrCtrl+Shift+I', () => { win.webContents.toggleDevTools(); }); - //重载页面 + // 重载页面 electronLocalshortcut.register(win, 'CmdOrCtrl+R', () => { //win.reload(); sendCommand({ @@ -117,98 +117,22 @@ function createWindow(filePath = null, indexUrl = null) { }, win); }); - //重载页面 + // 重载页面 electronLocalshortcut.register(win, 'CmdOrCtrl+Shift+R', () => { win.reload(); }); - //最小化窗口 - electronLocalshortcut.register(win, 'CmdOrCtrl+M', () => { - win.minimize(); - }); - - //关闭窗口 - electronLocalshortcut.register(win, 'CmdOrCtrl+W', () => { - win.close(); - }); - - //还原窗口 - electronLocalshortcut.register(win, 'CmdOrCtrl+0', () => { - win.webContents.setZoomFactor(1); - }); - - //放大窗口 - electronLocalshortcut.register(win, 'CmdOrCtrl+Shift+=', () => { - let actualZoom = win.webContents.getZoomFactor(); - if (actualZoom == null) { - actualZoom = 1; - } - if (actualZoom < 1.5) { - win.webContents.setZoomFactor(actualZoom + 0.1); - } - }); - - //缩小窗口 - electronLocalshortcut.register(win, 'CmdOrCtrl+Shift+-', () => { - let actualZoom = win.webContents.getZoomFactor(); - if (actualZoom == null) { - actualZoom = 1; - } - if (actualZoom > 0.5) { - win.webContents.setZoomFactor(actualZoom - 0.1); - } - }); - - //重启 + // 重启 electronLocalshortcut.register(win, 'CmdOrCtrl+Q', () => { app.relaunch(); app.exit(0); }); - //打开帮助页面 - electronLocalshortcut.register(win, 'CmdOrCtrl+H', () => { - var sendObj = {}; - sendObj.type = "help"; - var sendStr = JSON.stringify(sendObj); - win.webContents.send('ping', sendStr); - //win.webContents.executeJavaScript('alert("this is a test!");'); - }); - - //创建一个新页面 + // 创建一个新页面 electronLocalshortcut.register(win, 'CmdOrCtrl+Shift+N', () => { createWindow(null); }); - //文件另存为 - electronLocalshortcut.register(win, 'CmdOrCtrl+Shift+S', () => { - const commandObj = { - obj: 'Mixly.Electron.File', - func: 'saveAs' - } - const commandStr = JSON.stringify(commandObj); - win.webContents.send('command', commandStr); - }); - - //保存文件 - electronLocalshortcut.register(win, 'CmdOrCtrl+S', () => { - const commandObj = { - obj: 'Mixly.Electron.File', - func: 'save' - } - const commandStr = JSON.stringify(commandObj); - win.webContents.send('command', commandStr); - }); - - //新建文件 - electronLocalshortcut.register(win, 'CmdOrCtrl+N', () => { - const commandObj = { - obj: 'Mixly.Electron.File', - func: 'newFile' - } - const commandStr = JSON.stringify(commandObj); - win.webContents.send('command', commandStr); - }); - win.once('ready-to-show', () => { win.maximize(); win.show(); @@ -225,32 +149,6 @@ function createWindow(filePath = null, indexUrl = null) { win.on('closed', function () { win = null; }); - - /*if (process.platform === 'win32') { - getLibsJson(function (jsonData) { - if (!jsonData?.version) return; - cloudSoftwareJson = JSON.stringify(jsonData); - //var updateSoftware = changeVersion(app.getVersion(), jsonData.version); - var updateSoftware = (app.getVersion() != jsonData.version); - if (updateSoftware) { - var sendObj = {}; - sendObj.type = "update"; - sendObj.oldVersion = app.getVersion(); - sendObj.newVersion = jsonData.version; - var sendStr = JSON.stringify(sendObj); - setTimeout(function () { - win.webContents.send('ping', sendStr); - }, 1000); - } - }); - - ipcMain.on('ping', (event, arg) => { - if (arg == "update") { - shell.openPath(nodePath.join(__dirname, '../../一键更新.bat')); - } - event.reply('ping', 'get'); - }); - }*/ win.on('unresponsive', async () => { const { response } = await dialog.showMessageBox({