diff --git a/client/modules/edit-file.js b/client/modules/edit-file.js index 3fa55c14..f9b29041 100644 --- a/client/modules/edit-file.js +++ b/client/modules/edit-file.js @@ -140,6 +140,8 @@ function setMenu(event) { const element = CloudCmd.Edit.getElement(); Menu = supermenu(element, options, getMenuData()); + + Menu.addContextMenuListener(); Menu.show(position.x, position.y); } diff --git a/client/modules/edit-names.js b/client/modules/edit-names.js index 06c0e29e..e26e9ad8 100644 --- a/client/modules/edit-names.js +++ b/client/modules/edit-names.js @@ -203,6 +203,8 @@ function setMenu(event) { const element = CloudCmd.Edit.getElement(); Menu = supermenu(element, options, menuData); + + Menu.addContextMenuListener(); Menu.show(position.x, position.y); } diff --git a/client/modules/menu.js b/client/modules/menu.js index 439e48cb..66a4dbcc 100644 --- a/client/modules/menu.js +++ b/client/modules/menu.js @@ -41,15 +41,17 @@ module.exports.init = () => { menuDataFile, } = getFileMenuData(); - const NOT_FILE = true; const fm = DOM.getFM(); const menuData = getMenuData(isAuth); - const options = getOptions(NOT_FILE); - const optionsFile = getOptions(); + const options = getOptions({type: 'context'}); + const optionsFile = getOptions({type: 'file'}); MenuContext = supermenu(fm, options, menuData); MenuContextFile = supermenu(fm, optionsFile, menuDataFile); + MenuContext.addContextMenuListener(); + MenuContextFile.addContextMenuListener(); + Events.addKey(listener); }; @@ -91,14 +93,14 @@ function getMenuNameByEl(el) { return 'contextFile'; } -function getOptions(notFile) { +function getOptions({type}) { let name; let func; - if (notFile) { + if (type === 'context') { name = 'context'; func = Key.unsetBind; - } else { + } else if (type === 'file') { name = 'contextFile'; } @@ -205,21 +207,21 @@ function beforeShow(callback, params) { }); const menuName = getMenuNameByEl(el); - let notShow = menuName === 'contextFile'; - if (params.name === 'contextFile') { - notShow = !notShow; - } + let isShow = menuName !== 'contextFile'; - if (!notShow) + if (params.name === 'contextFile') + isShow = !isShow; + + if (isShow) MenuShowedName = name; exec(callback); - if (!notShow) - notShow = isPath(params.x, params.y); + if (isShow) + isShow = isPath(params.x, params.y); - return notShow; + return isShow; } function beforeClick(name) { diff --git a/package.json b/package.json index 725f7546..f1121aff 100644 --- a/package.json +++ b/package.json @@ -212,7 +212,7 @@ "style-loader": "^1.0.0", "stylelint": "^13.0.0", "stylelint-config-standard": "^20.0.0", - "supermenu": "^3.0.0", + "supermenu": "^4.0.1", "supertape": "^1.0.3", "tar-stream": "^2.0.0", "unionfs": "^4.0.0",