From 84bd6ef3f622c426b37f540d7ffd329551966a07 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 15 Nov 2012 05:43:39 -0500 Subject: [PATCH] fixed bug with positioning of CodeMirror on the right panel --- lib/client/dom.js | 13 ++++++++-- lib/client/editor/_codemirror.js | 42 +++++++++++++++++--------------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 87e253cf..5696dc2f 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -701,11 +701,20 @@ var CloudCommander, $, Util, DOM, CloudFunc; return lRet; }; - DOM.hide = function(pElement){ + DOM.hide = function(pElement){ return DOM.addClass(pElement, 'hidden'); }; - DOM.removeClass = function(pElement, pClass){ + /** + * remove child of element + * @pChild + * @pElement + */ + DOM.remove = function(pChild, pElement){ + return (pElement || document.body).removeChild(pChild); + }; + + DOM.removeClass = function(pElement, pClass){ var lRet_b = true, lClassList = pElement.classList; diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index 7fa051a8..eaf11c55 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -20,6 +20,25 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; /* private functions */ + function setCSS(){ + return DOM.cssSet({ + id : 'editor', + inner : '.CodeMirror{' + + 'font-family' + ': \'Droid Sans Mono\';' + + 'font-size' + ': 15px;' + + /* codemirror v3 */ + //'height : ' + cloudcmd.HEIGHT + 'px' + + '}' + + '.CodeMirror-scroll{' + + 'height' + ':' + cloudcmd.HEIGHT + 'px' + + '}' + + '#CodeMirrorEditor{' + + 'float' + ':' + DOM.getPanel().id + + // 'padding :20px 20px 20px 20px;' + + '}' + }); + } + /** * function initialize CodeMirror * @param {value, callback} @@ -31,6 +50,8 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; if(!FM) FM = DOM.getFM(); + var lCSS = setCSS(); + CodeMirrorElement = DOM.anyload({ name : 'div', id : 'CodeMirrorEditor', @@ -49,6 +70,7 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; extraKeys: { //Сохранение 'Esc': function(){ + DOM.remove(lCSS, document.head); Util.exec(pData.callback); } }, @@ -63,25 +85,7 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; console.time('codemirror load'); var lDir = cloudcmd.LIBDIRCLIENT + 'editor/codemirror/'; - DOM.anyLoadOnLoad( - [{ - name: 'style', - id:'editor', - inner : '.CodeMirror{' + - 'font-family :\'Droid Sans Mono\';' + - 'font-size :15px;' + - /* codemirror v3 */ - //'height : ' + cloudcmd.HEIGHT + 'px' + - '}' + - '.CodeMirror-scroll{' + - 'height : ' + cloudcmd.HEIGHT + 'px' + - '}' + - '#CodeMirrorEditor{' + - 'float: right' + - // 'padding :20px 20px 20px 20px;' + - '}', - parent: document.head - }, + DOM.anyLoadOnLoad([ lDir + 'codemirror.css', lDir + 'theme/night.css', lDir + 'mode/javascript.js',