From 812839208ae4fef28a530aae6f8d3fb749a7f740 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 17 Jul 2012 05:30:44 -0700 Subject: [PATCH] added CodeMirror Editor module --- lib/client/editor.js | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 lib/client/editor.js diff --git a/lib/client/editor.js b/lib/client/editor.js new file mode 100644 index 00000000..fe191531 --- /dev/null +++ b/lib/client/editor.js @@ -0,0 +1,75 @@ +var CloudCommander; +CloudCommander.Editor = { CloudMirror: undefined }; +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/mode/xml/xml.js', lShowEditor_f) + } + } +}), + show : (function(){ + /* removing keyBinding if set */ + CloudCommander.keyBinded = false; + left.className = 'panel hidden'; + CloudEditor.className = ''; + }), + + + + + hide :(function() { + CloudCommander.keyBinded = true; + CloudEditor.className='hidden'; + left.className = 'panel'; + }) +}; \ No newline at end of file