refactor(menu) listener

This commit is contained in:
coderaiser 2014-05-13 07:11:51 -04:00
parent 790eef0df0
commit 860a109b2e

View file

@ -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();