refactored

This commit is contained in:
coderaiser 2013-06-04 07:34:28 -04:00
parent 1fa39b2389
commit ef1ab0ef86
5 changed files with 34 additions and 41 deletions

View file

@ -1,7 +1,7 @@
[
"editor/_codemirror",
"edit/_codemirror",
"menu",
"viewer",
"view",
"terminal", {
"name": "storage",
"data": [{

View file

@ -11,16 +11,12 @@ var Util, DOM, CloudFunc, CloudCmd;
Events = DOM.Events,
Cache = DOM.Cache;
/* Клиентский обьект, содержащий функциональную часть*/
CloudCmd = {
/* КОНСТАНТЫ*/
LIBDIR : '/lib/',
LIBDIRCLIENT : '/lib/client/',
JSONDIR : '/json/',
HTMLDIR : '/html/',
/* height of Cloud Commander
* seting up in init()
*/
/* height of Cloud Commander seting up in */
HEIGHT : 0,
MIN_ONE_PANEL_WIDTH : 1155,
OLD_BROWSER : false,
@ -175,12 +171,12 @@ var Util, DOM, CloudFunc, CloudCmd;
CloudCmd.Menu.ENABLED || DOM.preventDefault(pEvent);
}, document);
var lStorage = 'storage',
var i, n, lStorage = 'storage',
lShowLoadFunc = Util.retFunc( DOM.Images.showLoad ),
lDoBefore = {
'edit/_codemirror' : lShowLoadFunc,
'view' : lShowLoadFunc
'edit/_codemirror' : lShowLoadFunc,
'view' : lShowLoadFunc
},
lLoad = function(pName, pPath, pDoBefore){
@ -191,7 +187,7 @@ var Util, DOM, CloudFunc, CloudCmd;
});
};
for(var i = 0, n = pModules.length; i < n ; i++){
for(i = 0, n = pModules.length; i < n ; i++){
var lModule = pModules[i];
if( Util.isString(lModule) )
@ -624,7 +620,7 @@ var Util, DOM, CloudFunc, CloudCmd;
size : 'dir'
}],
lLI = lLeft.getElementsByTagName('li'),
lLI = DOM.getByTag('li', lLeft),
i, n, j = 1; /* счётчик реальных файлов */
/* счётчик элементов файлов в DOM
@ -638,9 +634,7 @@ var Util, DOM, CloudFunc, CloudCmd;
var lCurrent = lLI[i],
lName = DOM.getCurrentName(lCurrent),
lSize = DOM.getCurrentSize(lCurrent),
/* переводим права доступа в цыфровой вид
* для хранения в localStorage
*/
lMode = DOM.getCurrentMode(lCurrent);
lMode = CloudFunc.getNumericPermissions(lMode);
@ -652,7 +646,7 @@ var Util, DOM, CloudFunc, CloudCmd;
};
}
return Util.stringifyJSON(lFileTable);
};
}
Events.addOneTime('load', function(){
/* базовая инициализация*/

View file

@ -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);

View file

@ -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;

View file

@ -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);
}
}