From 16bb1ec6cb243079212f487836d174d05bb0a60d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 19 Jun 2013 11:01:31 +0000 Subject: [PATCH] refactor(console) remove view element --- lib/client/console.js | 194 ++++++++++++++++++++---------------------- 1 file changed, 92 insertions(+), 102 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index bc9525d7..9ba73d4e 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -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); \ No newline at end of file