From eae20a674ecc69ec43aa3d4a826914f55e73d90e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 28 Sep 2012 11:04:43 -0400 Subject: [PATCH] minor changes --- lib/client/editor.js | 18 ++++-- lib/client/editor/ace_editor.js | 106 +++++++++++++++----------------- 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/lib/client/editor.js b/lib/client/editor.js index 7fc38ed8..1a9999e3 100644 --- a/lib/client/editor.js +++ b/lib/client/editor.js @@ -194,18 +194,24 @@ var CloudCommander, CloudFunc, CodeMirror; var lShow = Util.bind(lThis.show, lThis); if(!pEvent.shiftKey){ - if(pEvent.keyCode === lF4) - lShow(); - else if(pEvent.keyCode === lF3){ - lShow(true); - } + switch(pEvent.keyCode) + { + case lF4: + ReadOnly = false; + lShow(); + break; + case lF3: + ReadOnly = true; + lShow(); + break; + } } } }; /* добавляем обработчик клавишь */ if (document.addEventListener) - document.addEventListener('keydown', key_event,false); + document.addEventListener('keydown', key_event, false); else{ var lFunc; diff --git a/lib/client/editor/ace_editor.js b/lib/client/editor/ace_editor.js index 084dffe1..6ff8cd18 100644 --- a/lib/client/editor/ace_editor.js +++ b/lib/client/editor/ace_editor.js @@ -9,7 +9,8 @@ var CloudCommander, CloudFunc, ace; KeyBinding = CloudCommander.KeyBinding, AceEditor = {}, AceLoaded = false, - AceEditorElement, + ReadOnly = false, + AceElement, FM; CloudCommander.Editor = { @@ -22,64 +23,19 @@ var CloudCommander, CloudFunc, ace; AceEditor.dir = cloudcmd.Editor.dir + 'ace/'; - var createEditorDiv = function(){ + /* private functions */ + function initCodeMirror(pValue){ if(!FM) FM = Util.getById('fm'); - - AceEditorElement = Util.anyload({ + + AceElement = Util.anyload({ name : 'div', - id : 'AceEditor', + id : 'CodeMirrorEditor', className : 'panel', parent : FM - }); - }; - - /* indicator says Ace still loads */ - AceEditor.loading = false; - - /* function loads Ace js and css files */ - AceEditor.load = (function(pIsReadOnly){ - Util.cssSet({id:'editor', - inner : '#AceEditor{' + - 'font-size : 15px;' + - 'padding : 0 0 0 0;' + - '}' }); - /* load Ace main module */ - Util.jsload(AceEditor.dir + 'ace.js', function() { - Util.jsload(AceEditor.dir + 'mode-javascript.js', - function(){ - AceLoaded = true; - AceEditor.show(pIsReadOnly); - }); - }); - }); - - /* function shows Ace editor */ - AceEditor.show = (function(pIsReadOnly){ - /* if Ace function show already - * called do not call it again - * if f4 key pressed couple times - */ - if(this.loading) - return; - - if(!AceLoaded){ - return AceEditor.load(pIsReadOnly); - } - - /* when folder view - * is no need to edit - * data - */ - var lReadOnly = pIsReadOnly || false; - - var lThis = this; - - var initAce_f = function(pValue){ - createEditorDiv(); - var editor = ace.edit("AceEditor"); + var editor = ace.edit("AceEditor"); editor.setTheme("ace/theme/tomorrow_night_blue"); editor.getSession().setMode("ace/mode/javascript"); @@ -95,11 +51,45 @@ var CloudCommander, CloudFunc, ace; }); */ - editor.setReadOnly(lReadOnly); + editor.setReadOnly(ReadOnly); editor.setValue(pValue); - }; + } + + /* indicator says Ace still loads */ + AceEditor.loading = false; + + /* function loads Ace js and css files */ + AceEditor.load = (function(){ + Util.cssSet({id:'editor', + inner : '#AceEditor{' + + 'font-size : 15px;' + + 'padding : 0 0 0 0;' + + '}' + }); + /* load Ace main module */ + Util.jsload(AceEditor.dir + 'ace.js', function() { + Util.jsload(AceEditor.dir + 'mode-javascript.js', + function(){ + AceLoaded = true; + AceEditor.show(); + }); + }); + }); + + /* function shows Ace editor */ + AceEditor.show = (function(){ + /* if Ace function show already + * called do not call it again + * if f4 key pressed couple times + */ + if(this.loading) + return; + + if(!AceLoaded){ + return AceEditor.load(); + } /* getting link */ var lCurrentFile = Util.getCurrentFile(), @@ -121,7 +111,11 @@ var CloudCommander, CloudFunc, ace; if (lA.indexOf(CloudFunc.NOJS) === CloudFunc.FS.length) { lA = lA.replace(CloudFunc.NOJS, ''); - lReadOnly = true; + /* when folder view + * is no need to edit + * data + */ + ReadOnly = true; } } } @@ -160,7 +154,7 @@ var CloudCommander, CloudFunc, ace; /* function hides Ace editor */ AceEditor.hide = (function() { - var lElem = AceEditorElement; + var lElem = AceElement; KeyBinding.set(); if(lElem && FM)