From 4d93472df069666e130a171308a23bea130bba1a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 19 Oct 2017 13:56:47 +0300 Subject: [PATCH] fix(menu) when click on ".." show full menu --- client/modules/menu.js | 54 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/client/modules/menu.js b/client/modules/menu.js index ddfbd495..a51af6f4 100644 --- a/client/modules/menu.js +++ b/client/modules/menu.js @@ -68,22 +68,60 @@ function MenuProto(Position) { return { x: position.x, y: position.y, - } + }; if (Position) return { x: Position.x, y: Position.y, - } + }; if (position) return { x: position.x, y: position.y, - } + }; return getCurrentPosition(); + } + + function getMenuNameByEl(el) { + if (!el) + return 'context'; + + const name = DOM.getCurrentName(el); + + if (name === '..') + return 'context'; + + return 'contextFile'; + } + + function getMenuByName(name) { + if (name === 'context') + return MenuContext; + + return MenuContextFile; + } + + function getMenuNameByEl(el) { + if (!el) + return 'context'; + + const name = DOM.getCurrentName(el); + + if (name === '..') + return 'context' + + return 'contextFile' }; + function getMenuByName(name) { + if (name === 'context') + return MenuContext; + + return MenuContextFile; + } + function show(position) { const {x, y} = getPosition(position); @@ -104,8 +142,9 @@ function MenuProto(Position) { MenuContext = new MenuIO(fm, options, menuData); MenuContextFile = new MenuIO(fm, optionsFile, menuDataFile); - const is = DOM.getCurrentByPosition({x, y}); - const menu = is ? MenuContextFile : MenuContext; + const el = DOM.getCurrentByPosition({x, y}); + const menuName = getMenuNameByEl(el); + const menu = getMenuByName(menuName); menu.show(x, y); @@ -216,11 +255,14 @@ function MenuProto(Position) { function beforeShow(callback, params) { const name = params.name; - let notShow = DOM.getCurrentByPosition({ + let el = DOM.getCurrentByPosition({ x: params.x, y: params.y }); + const menuName = getMenuNameByEl(el); + let notShow = menuName === 'contextFile'; + if (params.name === 'contextFile') { notShow = !notShow; }