diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index 6249c080..c60727f2 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -51,9 +51,6 @@ var CloudCommander, Util, DOM, CodeMirror; * @param {value, callback} */ function initCodeMirror(pParams){ - if(!pParams) - pParams = {}; - if(!FM) FM = DOM.getFM(); @@ -68,7 +65,7 @@ var CloudCommander, Util, DOM, CodeMirror; CodeMirrorEditor.CodeMirror = new CodeMirror(CodeMirrorElement,{ mode : 'javascript', - value : pParams.data.data, + value : pParams && pParams.data && pParams.data.data, theme : 'night', lineNumbers : true, //переносим длинные строки @@ -106,7 +103,7 @@ var CloudCommander, Util, DOM, CodeMirror; console.timeEnd('codemirror load'); CodeMirrorLoaded = true; Util.exec(pCallBack); - }); + }); } /** @@ -134,14 +131,13 @@ var CloudCommander, Util, DOM, CodeMirror; setTimeout(lFalseLoading, 400); /* reading data from current file */ DOM.getCurrentData({ - error : lFalseLoading, - success : function(data){ + error : lFalseLoading, + success : function(data){ if( DOM.hidePanel() ){ Util.exec(pCallBack, data); - - /* removing keyBinding if set */ KeyBinding.unSet(); - } + } + DOM.Images.hideLoad(); lFalseLoading(); } diff --git a/lib/client/terminal.js b/lib/client/terminal.js index b8f4be71..ebae0946 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -89,7 +89,6 @@ var CloudCommander, Util, DOM, $; DOM.hide(TerminalId); DOM.showPanel(); - KeyBinding.set(); Term.pause(); @@ -108,18 +107,22 @@ var CloudCommander, Util, DOM, $; ]); /* добавляем обработчик клавишь */ - DOM.addKeyListener(function(pEvent){ + var lKeyHandler = function(pEvent){ + var lKEY = cloudcmd.KEY, + lKeyCode = pEvent.keyCode, + lKeyBinded = KeyBinding.get(); /* если клавиши можно обрабатывать */ - if(Hidden && KeyBinding.get() && - pEvent.keyCode === cloudcmd.KEY.TRA){ - JqueryTerminal.show(); - pEvent.preventDefault(); - } + if(Hidden && lKeyBinded && lKeyCode === lKEY.TRA){ + JqueryTerminal.show(); + pEvent.preventDefault(); + } - else if(!Hidden && pEvent.keyCode === cloudcmd.KEY.ESC) + else if(!Hidden && lKeyCode === lKEY.ESC) JqueryTerminal.hide(); - }); + }; + + DOM.addKeyListener(lKeyHandler); }; - cloudcmd.Terminal.JqueryTerminal = JqueryTerminal; + cloudcmd.Terminal.JqueryTerminal = JqueryTerminal; })(); diff --git a/lib/client/viewer.js b/lib/client/viewer.js index a2db9670..63e1cdb9 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -7,23 +7,9 @@ var CloudCommander, Util, DOM, CloudFunc, $; var cloudcmd = CloudCommander, KeyBinding = CloudCommander.KeyBinding, - FancyBox = {}; - - cloudcmd.Viewer = { - get: (function(){ - return this.FancyBox; - }) - }; - - /* PRIVATE FUNCTIONS */ - - - /** - * function return configureation for FancyBox open and - * onclick (it shoud be different objects) - */ - function getConfig(){ - return{ + FancyBox = {}, + + Config = { beforeShow : function(){ DOM.Images.hideLoad(); KeyBinding.unSet(); @@ -31,7 +17,7 @@ var CloudCommander, Util, DOM, CloudFunc, $; afterShow : function(){ var lEditor = DOM.getById('CloudViewer'); - if(lEditor) + if(lEditor) lEditor.focus(); }, @@ -50,7 +36,12 @@ var CloudCommander, Util, DOM, CloudFunc, $; }, padding : 0 }; - } + + cloudcmd.Viewer = { + get: (function(){ + return this.FancyBox; + }) + }; /** * function loads css and js of FancyBox @@ -88,19 +79,15 @@ var CloudCommander, Util, DOM, CloudFunc, $; /** * function shows FancyBox */ - FancyBox.show = function(){ - var lConfig = getConfig(), - lPath = DOM.getCurrentPath(); + FancyBox.show = function(){ + var lPath = DOM.getCurrentPath(); if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) ) - $.fancybox.open({ href : lPath }, lConfig); + $.fancybox.open({ href : lPath }, Config); else DOM.getCurrentData(function(pParams){ - var lData = pParams.data; $.fancybox('