From 4f1e70a06b444f0b5f8cb9fc6c66b92dc5e5f27b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 19 Oct 2017 13:41:56 +0300 Subject: [PATCH] fix(menu) show menu on F9 when current is ".." --- client/modules/menu.js | 50 +++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/client/modules/menu.js b/client/modules/menu.js index 361d11a8..ddfbd495 100644 --- a/client/modules/menu.js +++ b/client/modules/menu.js @@ -13,7 +13,7 @@ const {FS} = require('../../common/cloudfunc'); const load = require('../dom/load'); const RESTful = require('../dom/rest'); -function MenuProto(position) { +function MenuProto(Position) { const config = CloudCmd.config; const Buffer = DOM.Buffer; const Info = DOM.CurrentInfo; @@ -47,14 +47,9 @@ function MenuProto(position) { MenuContextFile.hide(); }; - this.show = (position = {}) => { - const { - x = 0, - y = 0, - } = position; - + this.show = (position) => { const showFunc = () => { - show(x, y); + show(position); Images.hide(); }; @@ -68,18 +63,29 @@ function MenuProto(position) { }); }; - function show(x, y) { - if (!x || !y) { - if (position) { - x = position.x; - y = position.y; - } else { - const pos = getCurrentPosition(); - - x = pos.x; - y = pos.y; + function getPosition(position) { + if (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 show(position) { + const {x, y} = getPosition(position); if (!Loading) { MenuContext.show(x, y); @@ -104,7 +110,7 @@ function MenuProto(position) { menu.show(x, y); Loading = false; - position = null; + Position = null; }); } @@ -322,8 +328,8 @@ function MenuProto(position) { const rect = current.getBoundingClientRect(); const position = { - x: rect.left + rect.width / 3, - y: rect.top + x: Math.round(rect.left + rect.width / 3), + y: Math.round(rect.top) }; return position;