diff --git a/lib/client/editor.js b/lib/client/editor.js index f875c324..7fc38ed8 100644 --- a/lib/client/editor.js +++ b/lib/client/editor.js @@ -7,10 +7,13 @@ var CloudCommander, CloudFunc, CodeMirror; var cloudcmd = CloudCommander, Util = CloudCommander.Util, KeyBinding = CloudCommander.KeyBinding, - CodeMirrorEditor = {}, - CodeMirrorLoaded = false, + CodeMirrorEditor = {}, FM, - CodeMirrorElement; + CodeMirrorElement, + CodeMirrorLoaded = false, + /* indicator says CodeMirror still loads */ + Loading = false, + ReadOnly = false; cloudcmd.Editor = { get : (function(){ @@ -19,7 +22,8 @@ var CloudCommander, CloudFunc, CodeMirror; }; - var createEditorDiv = function(pIsReadOnly){ + /* private functions */ + function initCodeMirror(pValue){ if(!FM) FM = Util.getById('fm'); @@ -29,16 +33,28 @@ var CloudCommander, CloudFunc, CodeMirror; className : 'panel', parent : FM }); - }; + + CodeMirrorEditor.CodeMirror = new CodeMirror(CodeMirrorElement,{ + mode : 'javascript', + value : pValue, + theme : 'night', + lineNumbers : true, + //переносим длинные строки + lineWrapping: false, + autofocus : true, + extraKeys: { + //Сохранение + "Esc": CodeMirrorEditor.hide + }, + readOnly : ReadOnly + }); + } cloudcmd.Editor.dir = 'lib/client/editor/'; CodeMirrorEditor.dir = cloudcmd.Editor.dir + 'codemirror/'; - /* indicator says CodeMirror still loads */ - CodeMirrorEditor.loading = false; - /* function loads CodeMirror js and css files */ - CodeMirrorEditor.load = (function(pCurrentFile, pIsReadOnly){ + CodeMirrorEditor.load = (function(){ /* function loads css files of CodeMirror */ var loadAll = function() { Util.cssLoad([ @@ -67,7 +83,7 @@ var CloudCommander, CloudFunc, CodeMirror; Util.jsload(CodeMirrorEditor.dir + 'mode/javascript.js', function(){ CodeMirrorLoaded = true; - CodeMirrorEditor.show(pIsReadOnly); + CodeMirrorEditor.show(); }); }; @@ -76,44 +92,17 @@ var CloudCommander, CloudFunc, CodeMirror; }); /* function shows CodeMirror editor */ - CodeMirrorEditor.show = (function(pIsReadOnly){ + CodeMirrorEditor.show = (function(){ /* if CodeMirrorEditor is not loaded - loading him */ if(!CodeMirrorLoaded) - return this.load(pIsReadOnly); + return this.load(); /* if CodeMirror function show already * called do not call it again * if f4 key pressed couple times */ - if(this.loading) + if(Loading) return; - - /* when folder view - * is no need to edit - * data - */ - var lReadOnly = pIsReadOnly || false; - - var lThis = this; - - var initCodeMirror_f = function(pValue){ - createEditorDiv(); - CodeMirrorEditor.CodeMirror = new CodeMirror(CodeMirrorElement,{ - mode : 'javascript', - value : pValue, - theme : 'night', - lineNumbers : true, - //переносим длинные строки - lineWrapping: false, - autofocus : true, - extraKeys: { - //Сохранение - "Esc": lThis.hide - }, - readOnly : lReadOnly - }); - }; - /* getting link */ var lCurrentFile = Util.getCurrentFile(), @@ -132,34 +121,38 @@ var CloudCommander, CloudFunc, CodeMirror; * not html data */ if (lSize === '