diff --git a/lib/client/editor.js b/lib/client/editor.js index f483c487..f2c245cb 100644 --- a/lib/client/editor.js +++ b/lib/client/editor.js @@ -7,7 +7,7 @@ CloudCommander.Editor.CodeMirror = { load: (function(){ /* function loads CodeMirror js and css files */ /* function shows editor */ - var showEditor = function (pParent){ + var createEditorDiv = function (pParent){ return function(){ if (!document.getElementById('CloudEditor')) { var lEditor=document.createElement('div'); @@ -15,20 +15,7 @@ CloudCommander.Editor.CodeMirror = { var lFM = document.getElementById('fm'); if(lFM){ - lFM.appendChild(lEditor); - - CodeMirror(lEditor,{ - mode : "xml", - htmlMode : true, - theme : 'night', - lineNumbers : true, - //переносим длинные строки - lineWrapping: true, - extraKeys: { - //Сохранение - "Esc": pParent.hide(pParent) - } - }); + lFM.appendChild(lEditor); }else console.log('Error. Something went wrong FM not found'); } }; @@ -62,7 +49,7 @@ CloudCommander.Editor.CodeMirror = { }); CloudCommander.jsload('lib/client/editor/codemirror/pack/xml.pack.js', - showEditor(pParent)); + createEditorDiv); }; }; @@ -70,7 +57,7 @@ CloudCommander.Editor.CodeMirror = { CloudCommander.jsload('lib/client/editor/codemirror/pack/codemirror.pack.js', loadAll(this)); }), - show : (function(){ /* function shows CodeMirror editor */ + show : (function(pParent){ /* function shows CodeMirror editor */ /* if CloudEditor is not loaded - loading him */ document.getElementById('CloudEditor') || this.load(); @@ -83,6 +70,21 @@ CloudCommander.Editor.CodeMirror = { lLeft && (lLeft.className = 'panel hidden'); + + CodeMirror(lCloudEditor,{ + mode : "xml", + htmlMode : true, + theme : 'night', + lineNumbers : true, + //переносим длинные строки + lineWrapping: true, + extraKeys: { + //Сохранение + "Esc": pParent.hide(pParent) + } + }); + + lCloudEditor && (lCloudEditor.className = ''); }), @@ -114,7 +116,7 @@ CloudCommander.Editor.Keys = (function(){ "use strict"; /* loading js and css of CodeMirror */ - CloudCommander.Editor.CodeMirror.show(); + CloudCommander.Editor.CodeMirror.show(CloudCommander.Editor.CodeMirror); var key_event=function(event){