diff --git a/lib/client/editor.js b/lib/client/editor.js index 69925c2d..c1e47e58 100644 --- a/lib/client/editor.js +++ b/lib/client/editor.js @@ -1,80 +1,100 @@ -var CloudCommander; +var CloudCommander, CodeMirror; CloudCommander.Editor = {}; -CloudCommander.Editor.CloudMirror = { load: (function(){ +CloudCommander.Editor.CloudMirror = { + load: (function(){ - CloudCommander.jsload('http://codemirror.net/lib/codemirror.js', load_all(this)); - - function load_all(pParent) { - return function(){ - CloudCommander.cssLoad({ - src : 'http://codemirror.net/lib/codemirror.css', - element : document.head - }); - - CloudCommander.cssLoad({ - src : 'http://codemirror.net/theme/night.css', - element : document.head - }); - - CloudCommander.cssSet({id:'editor', - inner:'.CodeMirror{'+ - 'font-family:\'Droid Sans Mono\';'+ - 'font-size:15px;'+ - 'resize:vertical;'+ 'margin:16px;'+'padding:20px;' + - '}'+ - '.CodeMirror-scroll{'+ - 'height: 660px;' + - '}' + - '.CodeMirror-scrollbar{'+ - 'overflow-y:auto' + - '}' - }); - - var lShowEditor_f = function (){ - if (!document.getElementById('CloudEditor')) { - var lEditor=document.createElement('div'); - lEditor.id ='CloudEditor'; - lEditor.className = 'hidden'; - fm.appendChild(lEditor); - - CodeMirror(lEditor,{ - mode : "xml", - htmlMode : true, - theme : 'night', - lineNumbers : true, - //переносим длинные строки - lineWrapping: true, - extraKeys: { - //Сохранение - "Esc": pParent.hide - }, - onLoad: pParent.show() - }); - - } + CloudCommander.jsload('http://codemirror.net/lib/codemirror.js', load_all(this)); + + function load_all(pParent) { + return function(){ + CloudCommander.cssLoad({ + src : 'http://codemirror.net/lib/codemirror.css', + element : document.head + }); + + CloudCommander.cssLoad({ + src : 'http://codemirror.net/theme/night.css', + element : document.head + }); + + CloudCommander.cssSet({id:'editor', + inner:'.CodeMirror{'+ + 'font-family:\'Droid Sans Mono\';'+ + 'font-size:15px;'+ + 'resize:vertical;'+ 'margin:16px;'+'padding:20px;' + + '}'+ + '.CodeMirror-scroll{'+ + 'height: 660px;' + + '}' + + '.CodeMirror-scrollbar{'+ + 'overflow-y:auto' + + '}' + }); + + var lShowEditor_f = function (){ + if (!document.getElementById('CloudEditor')) { + var lEditor=document.createElement('div'); + lEditor.id ='CloudEditor'; + lEditor.className = 'hidden'; + 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 + }, + onLoad: pParent.show() + }); + }else console.log('Error. Something went wrong FM not found'); + } + }; + CloudCommander.jsload('http://codemirror.net/mode/xml/xml.js', lShowEditor_f); }; - CloudCommander.jsload('http://codemirror.net/mode/xml/xml.js', lShowEditor_f); - }; - } -}), + } + }), show : (function(){ /* if CloudEditor is not loaded - loading him */ document.getElementById('CloudEditor') || this.load(); /* removing keyBinding if set */ - CloudCommander.keyBinded = false; - left.className = 'panel hidden'; - CloudEditor.className = ''; + CloudCommander.keyBinded = false; + + var lLeft = this.getById('left'); + var lCloudEditor = this.getById('CloudEditor'); + + lLeft && + lLeft.className = 'panel hidden'; + + lCloudEditor && + lCloudEditor + .className = ''; }), - hide :(function() { + hide :(function() { CloudCommander.keyBinded = true; - CloudEditor.className='hidden'; - left.className = 'panel'; - }) + + var lLeft = this.getById('left'); + var lCloudEditor = this.getById('CloudEditor'); + + lCloudEditor && + lCloudEditor.className = 'hidden'; + + lLeft && + lLeft.className = 'panel'; + }), + getById: function(pId){return document.getElementById(pId)} }; CloudCommander.Editor.Keys = (function(){ "use strict"; @@ -89,9 +109,12 @@ CloudCommander.Editor.Keys = (function(){ }; /* добавляем обработчик клавишь */ - if(document.addEventListener) + if (document.addEventListener) document.addEventListener('keydown', key_event,false); - else document.onkeypress=key_event; + + else + document.onkeypress=key_event; + /* клавиши назначены*/ CloudCommander.keyBinded=true; }); \ No newline at end of file diff --git a/node_modules/minify b/node_modules/minify index 8d386766..24173f35 160000 --- a/node_modules/minify +++ b/node_modules/minify @@ -1 +1 @@ -Subproject commit 8d386766868e176add3772365e277e501b0a37dd +Subproject commit 24173f35158113193847d744dacce0faf266b074