mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(edit) add initAce, worker condition
This commit is contained in:
parent
73dfaef19f
commit
9c8ee6fc52
1 changed files with 43 additions and 35 deletions
|
|
@ -6,6 +6,7 @@ var CloudCmd, Util, DOM, JsDiff, ace;
|
|||
|
||||
function EditProto(CloudCmd, Util, DOM){
|
||||
var Name = 'Edit',
|
||||
DIR = CloudCmd.LIBDIRCLIENT + 'edit/',
|
||||
Value,
|
||||
Edit = this,
|
||||
Ace,
|
||||
|
|
@ -35,7 +36,9 @@ var CloudCmd, Util, DOM, JsDiff, ace;
|
|||
};
|
||||
|
||||
this.show = function(pValue) {
|
||||
var lMode, lSession;
|
||||
var lName = DOM.getCurrentName(),
|
||||
lExt = Util.getExtension(lName),
|
||||
lUseWorker = Util.strCmp(lExt, ['.js', '.json']);
|
||||
|
||||
Images.showLoad();
|
||||
|
||||
|
|
@ -50,36 +53,12 @@ var CloudCmd, Util, DOM, JsDiff, ace;
|
|||
'position: absolute;',
|
||||
not_append : true
|
||||
});
|
||||
|
||||
Ace = ace.edit(Element);
|
||||
lSession = Ace.getSession();
|
||||
|
||||
Ace.setTheme('ace/theme/tomorrow_night_blue');
|
||||
lSession.setMode('ace/mode/javascript');
|
||||
Ace.setShowPrintMargin(false);
|
||||
Ace.setShowInvisibles(true);
|
||||
lSession.setUseSoftTabs(true);
|
||||
|
||||
Ace.commands.addCommand({
|
||||
name : 'hide',
|
||||
bindKey : { win: 'Esc', mac: 'Esc' },
|
||||
exec : function () {
|
||||
Edit.hide();
|
||||
}
|
||||
});
|
||||
|
||||
Ace.commands.addCommand({
|
||||
name : 'save',
|
||||
bindKey : { win: 'Ctrl-S', mac: 'Command-S' },
|
||||
exec : function (pEditor) {
|
||||
var lPath = DOM.getCurrentPath(),
|
||||
lValue = Ace.getValue();
|
||||
|
||||
DOM.RESTfull.save(lPath, lValue);
|
||||
}
|
||||
});
|
||||
|
||||
initAce();
|
||||
}
|
||||
|
||||
Ace.session.setOption('useWorker', lUseWorker);
|
||||
|
||||
if ( Util.isString(pValue) ) {
|
||||
Ace.setValue(pValue);
|
||||
CloudCmd.View.show(Element, focus);
|
||||
|
|
@ -111,15 +90,44 @@ var CloudCmd, Util, DOM, JsDiff, ace;
|
|||
Ace.moveCursorTo(0, 0);
|
||||
}
|
||||
|
||||
function initAce() {
|
||||
var lSession;
|
||||
|
||||
Ace = ace.edit(Element);
|
||||
lSession = Ace.getSession();
|
||||
|
||||
Ace.setTheme('ace/theme/tomorrow_night_blue');
|
||||
lSession.setMode('ace/mode/javascript');
|
||||
Ace.setShowPrintMargin(false);
|
||||
Ace.setShowInvisibles(true);
|
||||
lSession.setUseSoftTabs(true);
|
||||
|
||||
Ace.commands.addCommand({
|
||||
name : 'hide',
|
||||
bindKey : { win: 'Esc', mac: 'Esc' },
|
||||
exec : function () {
|
||||
Edit.hide();
|
||||
}
|
||||
});
|
||||
|
||||
Ace.commands.addCommand({
|
||||
name : 'save',
|
||||
bindKey : { win: 'Ctrl-S', mac: 'Command-S' },
|
||||
exec : function (pEditor) {
|
||||
var lPath = DOM.getCurrentPath(),
|
||||
lValue = Ace.getValue();
|
||||
|
||||
DOM.RESTfull.save(lPath, lValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function load(pCallBack){
|
||||
Util.time(Name + ' load');
|
||||
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'edit/',
|
||||
|
||||
lFiles = [
|
||||
lDir + 'mode-javascript.js',
|
||||
lDir + 'worker-javascript.js',
|
||||
lDir + 'ace.js',
|
||||
var lFiles = [
|
||||
DIR + 'theme-tomorrow_night_blue.js',
|
||||
DIR + 'ace.js',
|
||||
];
|
||||
|
||||
DOM.anyLoadOnLoad(lFiles, function(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue