﻿// (c) Copyright PreBook. All rights reserved.
Type.registerNamespace("PreBook.UI");PreBook.UI.RequestPanelBehavior=function(_1){PreBook.UI.RequestPanelBehavior.initializeBase(this,[_1]);this.targetUrl="";this.httpVerb="GET";this.timeout=30000;this.executor=null;};PreBook.UI.RequestPanelBehavior.prototype={initialize:function(){PreBook.UI.RequestPanelBehavior.callBaseMethod(this,"initialize");},dispose:function(){if(this.executor!=null){if(this.executor.get_started()){this.executor.abort();}this.executor=null;}PreBook.UI.RequestPanelBehavior.callBaseMethod(this,"dispose");},invoke:function(){switch(arguments.length){case 1:this.set_TargetUrl(arguments[0]);this.doInvoke();break;case 2:this.set_TargetUrl(arguments[0]);this.set_HttpVerb(arguments[1]);this.doInvoke();break;case 3:this.set_TargetUrl(arguments[0]);this.set_HttpVerb(arguments[1]);this.set_Timeout(arguments[2]);this.doInvoke();break;default:this.doInvoke();}},doInvoke:function(){this.abort();var _2=new Sys.Net.WebRequest();_2.set_url(this.targetUrl);_2.set_httpVerb(this.httpVerb);if(this.httpVerb=="POST"){var _3="msg=panelTest&from=requestpanelbehavior";_2.set_body(_3);_2.get_headers()["Content-Length"]=_3.length;}_2.set_timeout(this.timeout);_2.add_completed(Function.createDelegate(this,this.OnRequestCompleted));this.get_element().innerHTML="Loading...";if(this.executor==null){this.executor=new Sys.Net.XMLHttpExecutor();_2.set_executor(this.executor);}this.executor.executeRequest();},clear:function(){this.get_element().innerHTML="";},abort:function(){if(this.executor!=null){if(this.executor.get_started()){this.executor.abort();}}},OnRequestCompleted:function(_4,_5){var el=this.get_element();if(_4.get_responseAvailable()){if(_4.get_statusCode()==200){try{el.innerHTML=_4.get_responseData();}catch(e){el.innerHTML=e.message;}}else{el.innerHTML="The request could not be completed.<br />(HTTP "+_4.get_statusCode()+")";}}else{if(_4.get_timedOut()){el.innerHTML="Request Timed Out.";}else{if(_4.get_aborted()){el.innerHTML="Request Aborted.";}}}this.executor=null;},get_TargetUrl:function(){return this.targetUrl;},set_TargetUrl:function(_7){this.targetUrl=_7.toString();},get_HttpVerb:function(){return this.httpVerb;},set_HttpVerb:function(_8){if(_8!=""){var _9=_8.toUpperCase();if(_9=="POST"||_9=="GET"){this.httpVerb=_9;}else{var _a=Error.argument("HttpVerb","Not a valid HTTP Verb. Valid verbs include POST and GET.");throw _a;}}},get_Timeout:function(){return this.timeout;},set_Timeout:function(_b){if(_b!=""){if(!isNaN(_b)){if(_b>=0&&_b<=120000){this.timeout=parseInt(_b);}else{var _c=Error.argumentOutOfRange("Timeout",_b,"The timeout is out of range.\nA valid range is 0 - 120000.");throw _c;}}else{var _d=Error.argument("Timeout","Not a valid number.");throw _d;}}}};PreBook.UI.RequestPanelBehavior.registerClass("PreBook.UI.RequestPanelBehavior",AjaxControlToolkit.BehaviorBase);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();