diff --git a/lib/client/menu.js b/lib/client/menu.js index db1434bb..e1ac2fe0 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -56,9 +56,18 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO; }; function show(x, y) { + var position; + if (!x || !y) { - x = position.x; - y = position.y; + if (position) { + x = position.x; + y = position.y; + } else { + position = getCurrentPosition(); + + x = position.x; + y = position.y; + } } if (!Loading) { @@ -279,21 +288,27 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO; }; } + function getCurrentPosition() { + var current = Info.element, + rect = current.getBoundingClientRect(); + position = { + x: rect.left + rect.width / 3, + y: rect.top + }; + + return position; + } + function listener(event) { - var current, x, y, position, + var position, F9 = Key.F9, ESC = Key.ESC, key = event.keyCode, isBind = Key.isBind(); if (isBind && key === F9) { - current = Info.element; - position = current.getBoundingClientRect(); - - x = position.left + position.width / 3; - y = position.top; - - MenuContext.show(x, y); + position = getCurrentPosition(); + MenuContext.show(position.x, position.y); event.preventDefault(); } else if (key === ESC) {