From 4db2f9f93e45a5fbd1a4b257bd2ec1b636ee2852 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 30 Nov 2012 05:25:01 -0500 Subject: [PATCH] fixed bug with editor close, when started from menu --- ChangeLog | 2 ++ lib/client/editor/_codemirror.js | 52 +++++++++++++++++++------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3eaada1..51a8d62a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -131,6 +131,8 @@ config.json only if it setted up. * Fixed bug with slashes on win32. +* Fixed bug with editor close, when started from menu. + 2012.10.01, Version 0.1.7 diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index 3c16541e..63ed80c8 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -10,7 +10,14 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; CodeMirrorLoaded = false, /* indicator says CodeMirror still loads */ Loading = false, - ReadOnly = false; + ReadOnly = false, + + CallBacks = [ + hide, + initCodeMirror, + show, + load + ]; cloudcmd.Editor = { get : (function(){ @@ -70,8 +77,8 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; extraKeys: { //Сохранение 'Esc': function(){ - DOM.remove(lCSS, document.head); Util.exec(pData.callback); + DOM.remove(lCSS, document.head); } }, readOnly : ReadOnly @@ -105,7 +112,7 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; /** * function shows CodeMirror editor */ - CodeMirrorEditor.show = function(pCallBack){ + function show(pCallBack){ /* if CodeMirror function show already * called do not call it again @@ -180,7 +187,7 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; /** * function hides CodeMirror editor */ - CodeMirrorEditor.hide = function() { + function hide() { var lElem = CodeMirrorElement; KeyBinding.set(); @@ -188,27 +195,30 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; FM.removeChild(lElem); DOM.showPanel(); + } + + + /** + * function calls all CodeMirror editor functions + */ + CodeMirrorEditor.show = function(){ + DOM.Images.showLoad(); + Util.loadOnLoad( CallBacks ); }; + /** + * function hides CodeMirror editor + */ + CodeMirrorEditor.hide = hide; + /** * function bind keys */ cloudcmd.Editor.Keys = function(pReadOnly){ ReadOnly = pReadOnly; - var lShowCodemirror = [ - CodeMirrorEditor.hide, - initCodeMirror, - CodeMirrorEditor.show, - load - ], - lEditor = function(){ - DOM.Images.showLoad(); - Util.loadOnLoad( lShowCodemirror ); - }; - - lEditor(); - lShowCodemirror.pop(); + CodeMirrorEditor.show(); + CallBacks.pop(); var lKeyListener = function(pEvent){ /* если клавиши можно обрабатывать */ @@ -222,19 +232,19 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; { case lF4: ReadOnly = false; - lEditor(); + CodeMirrorEditor.show(); break; case lF3: ReadOnly = true; - lEditor(); + CodeMirrorEditor.show(); break; } } }; /* добавляем обработчик клавишь */ - DOM.addKeyListener( lKeyListener ) - .setButtonKey('f4', lEditor); + DOM.addKeyListener( lKeyListener ); + DOM.setButtonKey('f4', CodeMirrorEditor.show); }; cloudcmd.Editor.CodeMirror = CodeMirrorEditor;