mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(menu) listener
This commit is contained in:
parent
790eef0df0
commit
860a109b2e
1 changed files with 18 additions and 9 deletions
|
|
@ -23,7 +23,6 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO;
|
|||
|
||||
Util.loadOnLoad([
|
||||
load,
|
||||
//setUploadToItemNames,
|
||||
Menu.show
|
||||
]);
|
||||
|
||||
|
|
@ -34,13 +33,15 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO;
|
|||
MenuContext.hide();
|
||||
};
|
||||
|
||||
this.show = function() {
|
||||
var fm, options, menuData,
|
||||
x = (position || Position).x,
|
||||
this.show = function(x, y ) {
|
||||
var fm, options, menuData;
|
||||
|
||||
if (!x || !y) {
|
||||
x = (position || Position).x;
|
||||
y = (position || Position).y;
|
||||
}
|
||||
|
||||
if (!Loading) {
|
||||
Key.unsetBind();
|
||||
MenuContext.show(x, y);
|
||||
} else {
|
||||
fm = DOM.getFM();
|
||||
|
|
@ -50,7 +51,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO;
|
|||
beforShow : Key.unsetBind
|
||||
};
|
||||
menuData = getMenuData();
|
||||
MenuContext = MenuIO(fm, options, menuData);
|
||||
MenuContext = new MenuIO(fm, options, menuData);
|
||||
|
||||
MenuContext.show(x, y);
|
||||
Loading = false;
|
||||
|
|
@ -173,17 +174,25 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO;
|
|||
}
|
||||
|
||||
function listener(event) {
|
||||
var F9 = Key.F9,
|
||||
var current, x, y, position,
|
||||
F9 = Key.F9,
|
||||
ESC = Key.ESC,
|
||||
key = event.keyCode,
|
||||
isBind = Key.isBind();
|
||||
|
||||
if (isBind && key === F9) {
|
||||
MenuContext.show(Position);
|
||||
current = Info.element;
|
||||
position = current.getBoundingClientRect();
|
||||
|
||||
x = position.left + position.width / 3;
|
||||
y = position.top;
|
||||
|
||||
MenuContext.show(x, y);
|
||||
|
||||
DOM.preventDefault(event);
|
||||
} else if (key === ESC)
|
||||
} else if (key === ESC) {
|
||||
MenuContext.hide();
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue