mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(listeners) initKeysPanel
This commit is contained in:
parent
945d6f3f9f
commit
fbd969adf0
1 changed files with 40 additions and 37 deletions
|
|
@ -39,48 +39,51 @@ var Util, DOM, CloudCmd;
|
|||
};
|
||||
|
||||
this.initKeysPanel = function() {
|
||||
var i, lButton, id, n, f,
|
||||
lKeysPanel = {},
|
||||
var button, id, name, func,
|
||||
keysElement = DOM.getByClass('keyspanel')[0],
|
||||
keysPanel = {},
|
||||
|
||||
lFuncs =[
|
||||
null,
|
||||
CloudCmd.Help, /* f1 */
|
||||
DOM.renameCurrent, /* f2 */
|
||||
CloudCmd.View, /* f3 */
|
||||
CloudCmd.Edit, /* f4 */
|
||||
DOM.copyCurrent, /* f5 */
|
||||
DOM.moveCurrent, /* f6 */
|
||||
DOM.promptNewDir, /* f7 */
|
||||
DOM.promptDeleteSelected, /* f8 */
|
||||
CloudCmd.Menu, /* f9 */
|
||||
CloudCmd.Config /* f10 */
|
||||
];
|
||||
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'
|
||||
};
|
||||
|
||||
n = lFuncs.length;
|
||||
for (i = 1; i <= n; i++) {
|
||||
id = 'f' + i,
|
||||
lButton = DOM.getById(id);
|
||||
lKeysPanel[id] = lButton;
|
||||
if (keysElement)
|
||||
Events.addClick(function(event) {
|
||||
var element = event.target,
|
||||
id = element.id,
|
||||
func = clickFuncs[id];
|
||||
|
||||
Util.exec(func);
|
||||
|
||||
}, keysElement);
|
||||
|
||||
for (id in onceClickFuncs) {
|
||||
button = DOM.getById(id);
|
||||
|
||||
if (lButton)
|
||||
if (i === 1 || i === 3 || i === 4 || i === 9 || i === 10)
|
||||
Events.addOnce('click', lFuncs[i], lButton);
|
||||
else
|
||||
Events.addClick(lFuncs[i], lButton);
|
||||
if (button) {
|
||||
name = onceClickFuncs[id];
|
||||
func = CloudCmd[name];
|
||||
keysPanel[id] = button;
|
||||
|
||||
Events.addOnce('click', func, button);
|
||||
}
|
||||
}
|
||||
|
||||
id = '~',
|
||||
lButton = DOM.getById(id);
|
||||
lKeysPanel[id] = lButton;
|
||||
Events.addOnce('click', CloudCmd.Console, lButton);
|
||||
|
||||
id = 'contact',
|
||||
lButton = DOM.getById(id);
|
||||
lKeysPanel[id] = lButton;
|
||||
|
||||
Events.addOnce('click', CloudCmd.Contact, lButton);
|
||||
|
||||
return lKeysPanel;
|
||||
return keysPanel;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue