From 1c8accbcac77242a6737fdf4cdc49b321fe2142c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 14 Nov 2012 09:48:01 -0500 Subject: [PATCH] added function setButtonKey --- client.js | 20 +++++++++++++++----- lib/client/dom.js | 13 +++++++++---- lib/client/editor/_codemirror.js | 2 +- lib/client/viewer.js | 4 ++-- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/client.js b/client.js index 5e7342ae..e4894d26 100644 --- a/client.js +++ b/client.js @@ -14,6 +14,7 @@ var CloudClient = { init : null, /* start initialization */ KeyBinding : null, /* обьект обработки нажатий клавишь */ + KeysPanel : null, /* panel with key buttons f1-f8 */ Config : null, /* function loads and shows config */ Editor : null, /* function loads and shows editor */ Storage : null, /* function loads storage */ @@ -382,7 +383,7 @@ CloudClient._currentToParent = function(pDirName){ CloudClient.init = function(){ var lFunc = function(){ Util.loadOnLoad([ - initCmdButtons, + initKeysPanel, initModules, baseInit ]); @@ -439,8 +440,10 @@ function initModules(pCallBack){ }); } -function initCmdButtons(pCallBack){ - var lFuncs =[ +function initKeysPanel(pCallBack){ + var lKeysPanel = {}, + + lFuncs =[ null, null, /* f1 */ null, /* f2 */ @@ -451,9 +454,16 @@ function initCmdButtons(pCallBack){ null, /* f7 */ null, /* f8 */ ]; - for(var i = 1; i <= 8; i++) - getById('f' + i).onclick = lFuncs[i]; + for(var i = 1; i <= 8; i++){ + var lButton = 'f' + i, + lEl = getById('f' + i); + + lEl.onclick = lFuncs[i]; + lKeysPanel[lButton] = lEl; + } + + cloudcmd.KeysPanel = lKeysPanel; Util.exec(pCallBack); } diff --git a/lib/client/dom.js b/lib/client/dom.js index ab9c1229..7ff0f7c2 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -3,12 +3,13 @@ var CloudCommander, $, Util, DOM, CloudFunc; (function(){ "use strict"; + var cloudcmd = CloudCommander; DOM = {}; /* PRIVATE */ function getCurrentFile(){ - return CloudCommander.CURRENT_FILE; + return cloudcmd.CURRENT_FILE; } /* private members */ @@ -541,7 +542,7 @@ var CloudCommander, $, Util, DOM, CloudFunc; return lRefresh; }; - DOM.setCurrentFile = function(pCurrentFile){ + DOM.setCurrentFile = function(pCurrentFile){ var lRet_b = true; if(!pCurrentFile){ @@ -573,6 +574,10 @@ var CloudCommander, $, Util, DOM, CloudFunc; return lRet_b; }; + DOM.setButtonKey = function(pKey, pFunc){ + cloudcmd.KeysPanel[pKey].onclick = pFunc; + }; + var lUnSetCurrentFile = function(pCurrentFile){ if(!pCurrentFile) DOM.addCloudStatus({ @@ -590,7 +595,7 @@ var CloudCommander, $, Util, DOM, CloudFunc; return lRet_b; }; - DOM.isCurrentFile = function(pCurrentFile){ + DOM.isCurrentFile = function(pCurrentFile){ if(!pCurrentFile) DOM.addCloudStatus({ code : -1, @@ -658,7 +663,7 @@ var CloudCommander, $, Util, DOM, CloudFunc; * then always work with passive * panel */ - if(window.innerWidth < CloudCommander.MIN_ONE_PANEL_WIDTH) + if(window.innerWidth < cloudcmd.MIN_ONE_PANEL_WIDTH) lPanel = DOM.getById('left'); diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index 28431691..7146b6c5 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -231,7 +231,7 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; /* добавляем обработчик клавишь */ DOM.addKeyListener( lKeyListener ); - DOM.getById('f4').onclick = lEditor; + DOM.setButtonKey('f4', lEditor); }; cloudcmd.Editor.CodeMirror = CodeMirrorEditor; diff --git a/lib/client/viewer.js b/lib/client/viewer.js index 8dbb4801..3faaab76 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -209,7 +209,7 @@ var CloudCommander, Util, DOM, CloudFunc, $; var lF3 = cloudcmd.KEY.F3, lKeyBinded = KeyBinding.get(), lKey = event.keyCode, - lShift = event.shiftKey; + lShift = event.shiftKey; /* если клавиши можно обрабатывать */ if( lKeyBinded && lKey === lF3 && lShift ){ @@ -221,7 +221,7 @@ var CloudCommander, Util, DOM, CloudFunc, $; /* добавляем обработчик клавишь */ DOM.addKeyListener(lKeyListener); - DOM.getById('f3').onclick = lView; + DOM.setButtonKey('f3', lView); }; cloudcmd.Viewer.FancyBox = FancyBox;