mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(console) remove view element
This commit is contained in:
parent
1cfaa5a0ee
commit
16bb1ec6cb
1 changed files with 92 additions and 102 deletions
|
|
@ -1,103 +1,93 @@
|
|||
var CloudCmd, Util, DOM, $;
|
||||
(function(CloudCmd, Util, DOM){
|
||||
'use strict';
|
||||
|
||||
CloudCmd.Console = new ConsoleProto(CloudCmd, Util, DOM);
|
||||
|
||||
function ConsoleProto(CloudCmd, Util, DOM){
|
||||
var Name = 'Console',
|
||||
Key = CloudCmd.Key,
|
||||
Images = DOM.Images,
|
||||
Console = this;
|
||||
|
||||
this.init = function(pCallBack){
|
||||
Util.loadOnLoad([
|
||||
Console.show,
|
||||
load,
|
||||
CloudCmd.View,
|
||||
DOM.jqueryLoad,
|
||||
]);
|
||||
|
||||
DOM.Events.addKey(listener);
|
||||
|
||||
delete Console.init;
|
||||
};
|
||||
|
||||
this.show = function(){
|
||||
var lElement, lViewElement;
|
||||
|
||||
Images.showLoad({top:true});
|
||||
|
||||
lViewElement = DOM.anyload({
|
||||
name : 'div',
|
||||
id : 'view',
|
||||
attribute : {
|
||||
tabindex : 0
|
||||
},
|
||||
not_append : true
|
||||
}),
|
||||
|
||||
lElement = DOM.anyload({
|
||||
name : 'div',
|
||||
className : 'console',
|
||||
parent : lViewElement
|
||||
}),
|
||||
|
||||
$(lElement).console({
|
||||
promptLabel: '# ',
|
||||
commandValidate : function(line){
|
||||
var lRet = line !== "";
|
||||
|
||||
return lRet;
|
||||
},
|
||||
commandHandle : function(line){
|
||||
return line;
|
||||
},
|
||||
autofocus : true,
|
||||
animateScroll : true,
|
||||
promptHistory : true,
|
||||
});
|
||||
|
||||
CloudCmd.View.show(lViewElement);
|
||||
};
|
||||
|
||||
|
||||
this.hide = function(){
|
||||
CloudCmd.View.hide();
|
||||
};
|
||||
|
||||
function load(pCallBack){
|
||||
Util.time(Name + ' load');
|
||||
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'terminal/jquery-console/',
|
||||
lFiles = [
|
||||
lDir + 'jquery.console.js',
|
||||
lDir + 'jquery.console.css'
|
||||
];
|
||||
|
||||
DOM.anyLoadInParallel(lFiles, function(){
|
||||
console.timeEnd(Name + ' load');
|
||||
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
}
|
||||
|
||||
function listener(pEvent){
|
||||
var lF10 = Key.F10,
|
||||
lESC = Key.ESC,
|
||||
lIsBind = Key.isBind(),
|
||||
lKey = pEvent.keyCode;
|
||||
|
||||
switch(lKey){
|
||||
case lF10:
|
||||
Console.show();
|
||||
break;
|
||||
case lESC:
|
||||
Console.hide();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var CloudCmd, Util, DOM, $;
|
||||
(function(CloudCmd, Util, DOM){
|
||||
'use strict';
|
||||
|
||||
CloudCmd.Console = new ConsoleProto(CloudCmd, Util, DOM);
|
||||
|
||||
function ConsoleProto(CloudCmd, Util, DOM){
|
||||
var Name = 'Console',
|
||||
Key = CloudCmd.Key,
|
||||
Images = DOM.Images,
|
||||
Console = this;
|
||||
|
||||
this.init = function(pCallBack){
|
||||
Util.loadOnLoad([
|
||||
Console.show,
|
||||
load,
|
||||
CloudCmd.View,
|
||||
DOM.jqueryLoad,
|
||||
]);
|
||||
|
||||
DOM.Events.addKey(listener);
|
||||
|
||||
delete Console.init;
|
||||
};
|
||||
|
||||
this.show = function(){
|
||||
var lElement;
|
||||
|
||||
Images.showLoad({top:true});
|
||||
|
||||
lElement = DOM.anyload({
|
||||
name : 'div',
|
||||
className : 'console'
|
||||
});
|
||||
|
||||
$(lElement).console({
|
||||
promptLabel: '# ',
|
||||
commandValidate : function(line){
|
||||
var lRet = line !== "";
|
||||
|
||||
return lRet;
|
||||
},
|
||||
commandHandle : function(line){
|
||||
return line;
|
||||
},
|
||||
autofocus : true,
|
||||
animateScroll : false,
|
||||
promptHistory : true,
|
||||
});
|
||||
|
||||
CloudCmd.View.show(lElement);
|
||||
};
|
||||
|
||||
|
||||
this.hide = function(){
|
||||
CloudCmd.View.hide();
|
||||
};
|
||||
|
||||
function load(pCallBack){
|
||||
Util.time(Name + ' load');
|
||||
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'terminal/jquery-console/',
|
||||
lFiles = [
|
||||
lDir + 'jquery.console.js',
|
||||
lDir + 'jquery.console.css'
|
||||
];
|
||||
|
||||
DOM.anyLoadInParallel(lFiles, function(){
|
||||
console.timeEnd(Name + ' load');
|
||||
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
}
|
||||
|
||||
function listener(pEvent){
|
||||
var lF10 = Key.F10,
|
||||
lESC = Key.ESC,
|
||||
lIsBind = Key.isBind(),
|
||||
lKey = pEvent.keyCode;
|
||||
|
||||
switch(lKey){
|
||||
case lF10:
|
||||
Console.show();
|
||||
break;
|
||||
case lESC:
|
||||
Console.hide();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
})(CloudCmd, Util, DOM);
|
||||
Loading…
Add table
Add a link
Reference in a new issue