From 1038e1a028ada18f231e0a3bd32facbaea6f6304 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 30 Jul 2012 10:43:48 -0400 Subject: [PATCH] minor changes --- lib/client/editor.js | 47 +++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/lib/client/editor.js b/lib/client/editor.js index 7d3f52f4..c2c29882 100644 --- a/lib/client/editor.js +++ b/lib/client/editor.js @@ -65,10 +65,27 @@ CloudCommander.Editor.CodeMirror = { /* removing keyBinding if set */ CloudCommander.keyBinded = false; + var initCodeMirror_f = function(pValue){ + CodeMirror(lCloudEditor,{ + mode : 'xml', + value : pValue, + theme : 'night', + lineNumbers : true, + //переносим длинные строки + lineWrapping: true, + autofocus : true, + extraKeys: { + //Сохранение + "Esc": this.hide(this) + } + }); + }; + var lLeft = this.getById('left'); var lCloudEditor = this.getById('CloudEditor'); var lCURRENTFILE = CloudCommander.CURRENT_FILE; + var lCurrent = this.getByClass(lCURRENTFILE); var lA; if(lCurrent.length) @@ -76,27 +93,25 @@ CloudCommander.Editor.CodeMirror = { if(lA.length) lA = lA[0].href; + + /* reading data from current file */ + var lValue = $.ajax({ + url:lA, - var lValue = $.ajax(lA); + error: function(jqXHR, textStatus, errorThrown){ + console.log(textStatus+' : '+errorThrown); + initCodeMirror_f(''); + }, + + success:function(data, textStatus, jqXHR){ + initCodeMirror_f(data); + } + }); if(lValue.responseText) lValue = lValue.responseText; lLeft && - (lLeft.className = 'panel hidden'); - - CodeMirror(lCloudEditor,{ - mode : 'xml', - value : lValue, - theme : 'night', - lineNumbers : true, - //переносим длинные строки - lineWrapping: true, - autofocus : true, - extraKeys: { - //Сохранение - "Esc": this.hide(this) - } - }); + (lLeft.className = 'panel hidden'); }), hide : (function(pParent) { return function(){