mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
minor changes
This commit is contained in:
parent
23d781157e
commit
3abdd699be
4 changed files with 178 additions and 173 deletions
|
|
@ -4,7 +4,7 @@
|
|||
"minification" : {
|
||||
"js" : false,
|
||||
"css" : false,
|
||||
"html" : true,
|
||||
"html" : false,
|
||||
"img" : true
|
||||
},
|
||||
"cache" : true,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
LIBDIRCLIENT : '/lib/client/',
|
||||
JSONDIR : '/json/',
|
||||
HTMLDIR : '/html/',
|
||||
/* height of Cloud Commander seting up in */
|
||||
HEIGHT : 0,
|
||||
MIN_ONE_PANEL_WIDTH : 1155,
|
||||
OLD_BROWSER : false,
|
||||
|
|
@ -519,7 +518,6 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
var lJSON = Cache.get(lCleanPath);
|
||||
|
||||
if (lJSON){
|
||||
/* переводим из текста в JSON */
|
||||
lJSON = Util.parseJSON(lJSON);
|
||||
createFileTable(lPanel, lJSON);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,180 +3,47 @@ var CloudCmd, Util, DOM, CodeMirror;
|
|||
(function(CloudCmd, Util, DOM){
|
||||
'use strict';
|
||||
|
||||
var Key = CloudCmd.Key,
|
||||
Edit = {},
|
||||
FM,
|
||||
Element,
|
||||
Loaded = false,
|
||||
Loading = false,
|
||||
ReadOnly = false,
|
||||
|
||||
CallBacks = [
|
||||
hide,
|
||||
init,
|
||||
show,
|
||||
load
|
||||
];
|
||||
CloudCmd.Edit = new EditProto(CloudCmd, Util, DOM);
|
||||
|
||||
function setCSS(){
|
||||
var lPosition = DOM.getPanel().id,
|
||||
lRet = DOM.cssSet({
|
||||
id : 'editor-css',
|
||||
inner : '.CodeMirror{' +
|
||||
'font-family' + ': \'Droid Sans Mono\';' +
|
||||
'font-size' + ': 15px;' +
|
||||
'}' +
|
||||
'.CodeMirror-scroll{' +
|
||||
'height' + ':' + CloudCmd.HEIGHT + 'px' +
|
||||
'}' +
|
||||
'#editor{' +
|
||||
'float' + ':' + lPosition +
|
||||
'}'
|
||||
});
|
||||
function EditProto(CloudCmd, Util, DOM){
|
||||
var Key = CloudCmd.Key,
|
||||
Edit = this,
|
||||
FM,
|
||||
Element,
|
||||
Loaded = false,
|
||||
Loading = false,
|
||||
ReadOnly = false,
|
||||
|
||||
CallBacks = [
|
||||
hide,
|
||||
init,
|
||||
_show,
|
||||
load
|
||||
];
|
||||
|
||||
return lRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* function initialize CodeMirror
|
||||
* @param {value, callback}
|
||||
*/
|
||||
function init(pParams){
|
||||
if(!FM)
|
||||
FM = DOM.getFM();
|
||||
|
||||
var lCSS = setCSS(),
|
||||
lCurrent = DOM.getCurrentFile(),
|
||||
lPath = DOM.getCurrentPath( lCurrent );
|
||||
|
||||
Element = DOM.anyload({
|
||||
name : 'div',
|
||||
id : 'editor',
|
||||
className : 'panel',
|
||||
parent : FM
|
||||
});
|
||||
|
||||
var lEditor = Edit.CodeMirror = new CodeMirror(Element, {
|
||||
mode : 'javascript',
|
||||
value : pParams && pParams.data && pParams.data.data,
|
||||
theme : 'night',
|
||||
lineNumbers : true,
|
||||
lineWrapping: false,
|
||||
autofocus : true,
|
||||
extraKeys: {
|
||||
/* Exit */
|
||||
'Esc': function(){
|
||||
Util.exec(pParams);
|
||||
DOM.remove(lCSS, document.head);
|
||||
},
|
||||
|
||||
/* Save */
|
||||
'Ctrl-S': function(){
|
||||
var lValue = lEditor.getValue();
|
||||
|
||||
DOM.setCurrentSize( lValue.length, lCurrent );
|
||||
DOM.RESTfull.save( lPath, lValue );
|
||||
}
|
||||
},
|
||||
readOnly : ReadOnly
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function loads CodeMirror js and css files
|
||||
*/
|
||||
function load(pCallBack){
|
||||
Util.time('codemirror load');
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'edit/codemirror/',
|
||||
lFiles =
|
||||
[
|
||||
[
|
||||
lDir + 'codemirror.css',
|
||||
lDir + 'theme/night.css',
|
||||
lDir + 'mode/javascript.js',
|
||||
],
|
||||
|
||||
lDir + 'codemirror.js'
|
||||
];
|
||||
|
||||
DOM.anyLoadOnLoad(lFiles, function(){
|
||||
Util.timeEnd('codemirror load');
|
||||
Loaded = true;
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function shows CodeMirror editor
|
||||
*/
|
||||
function show(pCallBack){
|
||||
|
||||
/* if CodeMirror function show already
|
||||
* called do not call it again
|
||||
* if f4 key pressed couple times
|
||||
/**
|
||||
* function calls all CodeMirror editor functions
|
||||
*/
|
||||
if(!Loading){
|
||||
/* checking is this link is to directory
|
||||
* when folder view is no need to edit data */
|
||||
ReadOnly = DOM.isCurrentIsDir();
|
||||
|
||||
Loading = true;
|
||||
|
||||
setTimeout(lFalseLoading, 400);
|
||||
|
||||
DOM.getCurrentData({
|
||||
error : lFalseLoading,
|
||||
success : function(data){
|
||||
if( DOM.hidePanel() ){
|
||||
Util.exec(pCallBack, data);
|
||||
Key.unsetBind();
|
||||
}
|
||||
|
||||
DOM.Images.hideLoad();
|
||||
lFalseLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.show = show;
|
||||
/**
|
||||
* function hides CodeMirror editor
|
||||
*/
|
||||
this.hide = hide;
|
||||
|
||||
function lFalseLoading(){ Loading = false; }
|
||||
}
|
||||
|
||||
/**
|
||||
* function hides CodeMirror editor
|
||||
*/
|
||||
function hide() {
|
||||
Key.setBind();
|
||||
/**
|
||||
* function bind keys
|
||||
*/
|
||||
this.init = function(){
|
||||
CloudCmd.Edit = Edit;
|
||||
};
|
||||
|
||||
if(Element && FM)
|
||||
FM.removeChild(Element);
|
||||
|
||||
DOM.showPanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* function calls all CodeMirror editor functions
|
||||
*/
|
||||
Edit.show = function(){
|
||||
DOM.Images.showLoad();
|
||||
Util.loadOnLoad( CallBacks );
|
||||
};
|
||||
|
||||
/**
|
||||
* function hides CodeMirror editor
|
||||
*/
|
||||
Edit.hide = hide;
|
||||
|
||||
/**
|
||||
* function bind keys
|
||||
*/
|
||||
CloudCmd.Edit.init = function(){
|
||||
Edit.show();
|
||||
show();
|
||||
CallBacks.pop();
|
||||
|
||||
/* добавляем обработчик клавишь */
|
||||
DOM.Events.addKey(lListener);
|
||||
DOM.setButtonKey('f4', Edit.show);
|
||||
|
||||
|
||||
function lListener(pEvent){
|
||||
var lIsBind = Key.isBind();
|
||||
|
||||
|
|
@ -189,7 +56,145 @@ var CloudCmd, Util, DOM, CodeMirror;
|
|||
}
|
||||
}
|
||||
|
||||
CloudCmd.Edit = Edit;
|
||||
};
|
||||
function setCSS(){
|
||||
var lPosition = DOM.getPanel().id,
|
||||
lRet = DOM.cssSet({
|
||||
id : 'edit-css',
|
||||
inner : '.CodeMirror{' +
|
||||
'font-family' + ': \'Droid Sans Mono\';' +
|
||||
'font-size' + ': 15px;' +
|
||||
'}' +
|
||||
'.CodeMirror-scroll{' +
|
||||
'height' + ':' + CloudCmd.HEIGHT + 'px' +
|
||||
'}' +
|
||||
'#edit{' +
|
||||
'float' + ':' + lPosition +
|
||||
'}'
|
||||
});
|
||||
|
||||
return lRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* function initialize CodeMirror
|
||||
* @param {value, callback}
|
||||
*/
|
||||
function init(pParams){
|
||||
if(!FM)
|
||||
FM = DOM.getFM();
|
||||
|
||||
var lCSS = setCSS(),
|
||||
lCurrent = DOM.getCurrentFile(),
|
||||
lPath = DOM.getCurrentPath( lCurrent );
|
||||
|
||||
Element = DOM.anyload({
|
||||
name : 'div',
|
||||
id : 'edit',
|
||||
className : 'panel',
|
||||
parent : FM
|
||||
});
|
||||
|
||||
var lEdit = Edit.CodeMirror = new CodeMirror(Element, {
|
||||
mode : 'javascript',
|
||||
value : pParams && pParams.data && pParams.data.data,
|
||||
theme : 'night',
|
||||
lineNumbers : true,
|
||||
lineWrapping: false,
|
||||
autofocus : true,
|
||||
extraKeys: {
|
||||
/* Exit */
|
||||
'Esc': function(){
|
||||
Util.exec(pParams);
|
||||
DOM.remove(lCSS, document.head);
|
||||
},
|
||||
|
||||
/* Save */
|
||||
'Ctrl-S': function(){
|
||||
var lValue = lEdit.getValue();
|
||||
|
||||
DOM.setCurrentSize( lValue.length, lCurrent );
|
||||
DOM.RESTfull.save( lPath, lValue );
|
||||
}
|
||||
},
|
||||
readOnly : ReadOnly
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function loads CodeMirror js and css files
|
||||
*/
|
||||
function load(pCallBack){
|
||||
Util.time('codemirror load');
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'edit/codemirror/',
|
||||
lFiles =
|
||||
[
|
||||
[
|
||||
lDir + 'codemirror.css',
|
||||
lDir + 'theme/night.css',
|
||||
lDir + 'mode/javascript.js',
|
||||
],
|
||||
|
||||
lDir + 'codemirror.js'
|
||||
];
|
||||
|
||||
DOM.anyLoadOnLoad(lFiles, function(){
|
||||
Util.timeEnd('codemirror load');
|
||||
Loaded = true;
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function shows CodeMirror editor
|
||||
*/
|
||||
function _show(pCallBack){
|
||||
|
||||
/* if CodeMirror function show already
|
||||
* called do not call it again
|
||||
* if f4 key pressed couple times
|
||||
*/
|
||||
if(!Loading){
|
||||
/* checking is this link is to directory
|
||||
* when folder view is no need to edit data */
|
||||
ReadOnly = DOM.isCurrentIsDir();
|
||||
|
||||
Loading = true;
|
||||
|
||||
setTimeout(lFalseLoading, 400);
|
||||
|
||||
DOM.getCurrentData({
|
||||
error : lFalseLoading,
|
||||
success : function(data){
|
||||
if( DOM.hidePanel() ){
|
||||
Util.exec(pCallBack, data);
|
||||
Key.unsetBind();
|
||||
}
|
||||
|
||||
DOM.Images.hideLoad();
|
||||
lFalseLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function lFalseLoading(){ Loading = false; }
|
||||
}
|
||||
|
||||
function show() {
|
||||
DOM.Images.showLoad();
|
||||
Util.loadOnLoad( CallBacks );
|
||||
}
|
||||
|
||||
/**
|
||||
* function hides CodeMirror editor
|
||||
*/
|
||||
function hide() {
|
||||
Key.setBind();
|
||||
|
||||
if(Element && FM)
|
||||
FM.removeChild(Element);
|
||||
|
||||
DOM.showPanel();
|
||||
}
|
||||
}
|
||||
|
||||
})(CloudCmd, Util, DOM);
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ var CloudCmd, Util, DOM;
|
|||
};
|
||||
|
||||
KeyProto.prototype = KEY;
|
||||
CloudCmd.Key = new KeyProto();
|
||||
CloudCmd.Key = new KeyProto(CloudCmd, Util, DOM);
|
||||
|
||||
function KeyProto(){
|
||||
function KeyProto(CloudCmd, Util, DOM){
|
||||
var Key = this,
|
||||
Binded,
|
||||
lTabPanel = {
|
||||
|
|
@ -284,11 +284,13 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
break;
|
||||
|
||||
/* обновляем страницу,
|
||||
/*
|
||||
* обновляем страницу,
|
||||
* загружаем содержимое каталога
|
||||
* при этом данные берём всегда с
|
||||
* сервера, а не из кэша
|
||||
* (обновляем кэш)*/
|
||||
* (обновляем кэш)
|
||||
*/
|
||||
case Key.R:
|
||||
if(lCtrl){
|
||||
Util.log('<ctrl>+r pressed\n' +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue