mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
refactored
This commit is contained in:
parent
1fa39b2389
commit
ef1ab0ef86
5 changed files with 34 additions and 41 deletions
|
|
@ -3,17 +3,17 @@ var CloudCmd, Util, DOM, CodeMirror;
|
|||
(function(CloudCmd, Util, DOM){
|
||||
'use strict';
|
||||
|
||||
var Key = CloudCmd.Key,
|
||||
Editor = {},
|
||||
var Key = CloudCmd.Key,
|
||||
Edit = {},
|
||||
FM,
|
||||
Element,
|
||||
CodeMirrorLoaded = false,
|
||||
Loading = false,
|
||||
ReadOnly = false,
|
||||
Loaded = false,
|
||||
Loading = false,
|
||||
ReadOnly = false,
|
||||
|
||||
CallBacks = [
|
||||
hide,
|
||||
initCodeMirror,
|
||||
init,
|
||||
show,
|
||||
load
|
||||
];
|
||||
|
|
@ -41,7 +41,7 @@ var CloudCmd, Util, DOM, CodeMirror;
|
|||
* function initialize CodeMirror
|
||||
* @param {value, callback}
|
||||
*/
|
||||
function initCodeMirror(pParams){
|
||||
function init(pParams){
|
||||
if(!FM)
|
||||
FM = DOM.getFM();
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ var CloudCmd, Util, DOM, CodeMirror;
|
|||
parent : FM
|
||||
});
|
||||
|
||||
var lEditor = Editor.CodeMirror = new CodeMirror(Element, {
|
||||
var lEditor = Edit.CodeMirror = new CodeMirror(Element, {
|
||||
mode : 'javascript',
|
||||
value : pParams && pParams.data && pParams.data.data,
|
||||
theme : 'night',
|
||||
|
|
@ -87,7 +87,7 @@ var CloudCmd, Util, DOM, CodeMirror;
|
|||
*/
|
||||
function load(pCallBack){
|
||||
Util.time('codemirror load');
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'editor/codemirror/',
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'edit/codemirror/',
|
||||
lFiles =
|
||||
[
|
||||
[
|
||||
|
|
@ -101,7 +101,7 @@ var CloudCmd, Util, DOM, CodeMirror;
|
|||
|
||||
DOM.anyLoadOnLoad(lFiles, function(){
|
||||
Util.timeEnd('codemirror load');
|
||||
CodeMirrorLoaded = true;
|
||||
Loaded = true;
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ var CloudCmd, Util, DOM, CodeMirror;
|
|||
/**
|
||||
* function calls all CodeMirror editor functions
|
||||
*/
|
||||
Editor.show = function(){
|
||||
Edit.show = function(){
|
||||
DOM.Images.showLoad();
|
||||
Util.loadOnLoad( CallBacks );
|
||||
};
|
||||
|
|
@ -164,18 +164,18 @@ var CloudCmd, Util, DOM, CodeMirror;
|
|||
/**
|
||||
* function hides CodeMirror editor
|
||||
*/
|
||||
Editor.hide = hide;
|
||||
Edit.hide = hide;
|
||||
|
||||
/**
|
||||
* function bind keys
|
||||
*/
|
||||
CloudCmd.Editor.init = function(){
|
||||
Editor.show();
|
||||
CloudCmd.Edit.init = function(){
|
||||
Edit.show();
|
||||
CallBacks.pop();
|
||||
|
||||
/* добавляем обработчик клавишь */
|
||||
DOM.Events.addKey(lListener);
|
||||
DOM.setButtonKey('f4', Editor.show);
|
||||
DOM.setButtonKey('f4', Edit.show);
|
||||
|
||||
function lListener(pEvent){
|
||||
var lIsBind = Key.isBind();
|
||||
|
|
@ -185,11 +185,11 @@ var CloudCmd, Util, DOM, CodeMirror;
|
|||
lKey = pEvent.keyCode;
|
||||
|
||||
if(lKey === lF4)
|
||||
Editor.show();
|
||||
Edit.show();
|
||||
}
|
||||
}
|
||||
|
||||
CloudCmd.Edit = Edit;
|
||||
};
|
||||
|
||||
CloudCmd.Editor.CodeMirror = Editor;
|
||||
|
||||
})(CloudCmd, Util, DOM);
|
||||
|
|
|
|||
|
|
@ -128,13 +128,13 @@ var CloudCmd, Util, DOM;
|
|||
break;
|
||||
|
||||
case Key.F3:
|
||||
Util.exec(CloudCmd.Viewer);
|
||||
Util.exec(CloudCmd.View);
|
||||
DOM.preventDefault(pEvent);
|
||||
break;
|
||||
|
||||
case Key.F4:
|
||||
DOM.Images.showLoad();
|
||||
Util.exec(CloudCmd.Editor);
|
||||
Util.exec(CloudCmd.Edit);
|
||||
DOM.preventDefault(pEvent);
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,13 +23,12 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
*/
|
||||
function showEditor(pReadOnly){
|
||||
DOM.Images.showLoad();
|
||||
var lEditor = CloudCmd[pReadOnly ? 'Viewer' : 'Editor'],
|
||||
lResult = Util.exec(lEditor, pReadOnly);
|
||||
|
||||
var lEditor = CloudCmd[pReadOnly ? 'View' : 'Edit'],
|
||||
lResult = Util.exec(lEditor);
|
||||
|
||||
if(!lResult){
|
||||
lEditor = lEditor.get();
|
||||
if(lEditor)
|
||||
Util.exec(lEditor.show);
|
||||
Util.exec(lEditor.show);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue