refactor(listeners) initKeysPanel

This commit is contained in:
coderaiser 2013-12-27 11:41:26 +00:00
parent 77e539b225
commit 16a242f468

View file

@ -39,50 +39,50 @@ var Util, DOM, CloudCmd;
};
this.initKeysPanel = function() {
var button, id, name, func,
var button, id, func,
keysElement = DOM.getByClass('keyspanel')[0],
keysPanel = {},
clickFuncs = {
'f2' : DOM.renameCurrent,
'f5' : DOM.copyCurrent,
'f6' : DOM.moveCurrent,
'f7' : DOM.promptNewDir,
'f8' : DOM.promptDeleteSelected
},
onceClickFuncs = {
'f1' : 'Help',
'f3' : 'View',
'f4' : 'Edit',
'f9' : 'Menu',
'f10' : 'Config',
'~' : 'Console',
'contact' : 'Contact'
'f1' : CloudCmd.Help,
'f3' : CloudCmd.View,
'f4' : CloudCmd.Edit,
'f9' : CloudCmd.Menu,
'f10' : CloudCmd.Config,
'~' : CloudCmd.Console,
'contact' : CloudCmd.Contact
};
for (id in onceClickFuncs) {
button = DOM.getById(id);
if (button) {
func = onceClickFuncs[id];
keysPanel[id] = button;
Events.addOnce('click', func, button);
}
}
if (keysElement)
Events.addClick(function(event) {
var element = event.target,
id = element.id,
clickFuncs = {
'f2' : DOM.renameCurrent,
'f5' : DOM.copyCurrent,
'f6' : DOM.moveCurrent,
'f7' : DOM.promptNewDir,
'f8' : DOM.promptDeleteSelected
},
func = clickFuncs[id];
Util.exec(func);
}, keysElement);
for (id in onceClickFuncs) {
button = DOM.getById(id);
if (button) {
name = onceClickFuncs[id];
func = CloudCmd[name];
keysPanel[id] = button;
Events.addOnce('click', func, button);
}
}
return keysPanel;
};