summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/js/compressed/ajax.js
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/Javascripts/js/compressed/ajax.js')
-rw-r--r--framework/Web/Javascripts/js/compressed/ajax.js63
1 files changed, 27 insertions, 36 deletions
diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js
index 4b260ab3..593b4c15 100644
--- a/framework/Web/Javascripts/js/compressed/ajax.js
+++ b/framework/Web/Javascripts/js/compressed/ajax.js
@@ -22,7 +22,8 @@ if(this.responseIsSuccess()){if(this.onComplete)
setTimeout(this.onComplete.bind(this),10);}}});Ajax.PeriodicalUpdater=Class.create();Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(container,url,options){this.setOptions(options);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=container;this.url=url;this.start();},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent();},stop:function(){this.updater.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments);},updateComplete:function(request){if(this.options.decay){this.decay=(request.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=request.responseText;}
this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options);}});Object.extend(Ajax.Request.prototype,{respondToReadyState:function(readyState)
{var event=Ajax.Request.Events[readyState];var transport=this.transport,json=this.getHeaderData(Prado.CallbackRequest.DATA_HEADER);if(event=='Complete')
-{if((this.header('Content-type')||'').match(/^text\/javascript/i))
+{if(this.header('X-PRADO-REDIRECT'))
+document.location.href=this.header('X-PRADO-REDIRECT');if((this.header('Content-type')||'').match(/^text\/javascript/i))
{try
{json=eval('('+transport.responseText+')');}catch(e)
{if(typeof(json)=="string")
@@ -36,7 +37,7 @@ this.transport.onreadystatechange=Prototype.emptyFunction;},getHeaderData:functi
{var json=this.header(name);return eval('('+json+')');}
catch(e)
{if(typeof(json)=="string")
-return Prado.CallbackRequest.decode(json);}}});Prado.CallbackRequest=Class.create();Object.extend(Prado.CallbackRequest,{FIELD_CALLBACK_TARGET:'PRADO_CALLBACK_TARGET',FIELD_CALLBACK_PARAMETER:'PRADO_CALLBACK_PARAMETER',FIELD_CALLBACK_PAGESTATE:'PRADO_PAGESTATE',FIELD_POSTBACK_TARGET:'PRADO_POSTBACK_TARGET',FIELD_POSTBACK_PARAMETER:'PRADO_POSTBACK_PARAMETER',PostDataLoaders:[],DATA_HEADER:'X-PRADO-DATA',ACTION_HEADER:'X-PRADO-ACTIONS',ERROR_HEADER:'X-PRADO-ERROR',PAGESTATE_HEADER:'X-PRADO-PAGESTATE',currentRequest:null,requestQueue:[],addPostLoaders:function(ids)
+return Prado.CallbackRequest.decode(json);}}});Prado.CallbackRequest=Class.create();Object.extend(Prado.CallbackRequest,{FIELD_CALLBACK_TARGET:'PRADO_CALLBACK_TARGET',FIELD_CALLBACK_PARAMETER:'PRADO_CALLBACK_PARAMETER',FIELD_CALLBACK_PAGESTATE:'PRADO_PAGESTATE',FIELD_POSTBACK_TARGET:'PRADO_POSTBACK_TARGET',FIELD_POSTBACK_PARAMETER:'PRADO_POSTBACK_PARAMETER',PostDataLoaders:[],DATA_HEADER:'X-PRADO-DATA',ACTION_HEADER:'X-PRADO-ACTIONS',ERROR_HEADER:'X-PRADO-ERROR',PAGESTATE_HEADER:'X-PRADO-PAGESTATE',requestQueue:[],addPostLoaders:function(ids)
{var self=Prado.CallbackRequest;self.PostDataLoaders=self.PostDataLoaders.concat(ids);var list=[];self.PostDataLoaders.each(function(id)
{if(list.indexOf(id)<0)
list.push(id);});self.PostDataLoaders=list;},dispatchActions:function(transport,actions)
@@ -65,35 +66,28 @@ msg+=e.version+" "+e.time+"\n";return msg;}},encode:function(data)
{return Prado.JSON.stringify(data);},decode:function(data)
{if(typeof(data)=="string"&&data.trim().length>0)
return Prado.JSON.parse(data);else
-return null;},dispatchPriorityRequest:function(callback)
-{var self=Prado.CallbackRequest;callback.request=new Ajax.Request(callback.url,callback.options);callback.timeout=setTimeout(function()
-{self.abortCurrentRequest();},callback.options.RequestTimeOut);self.currentRequest=callback;return true;},dispatchNormalRequest:function(callback)
-{new Ajax.Request(callback.url,callback.options);return true;},abortCurrentRequest:function()
-{var self=Prado.CallbackRequest;var inProgress=self.currentRequest;if(inProgress)
-{clearTimeout(inProgress.timeout);self.currentRequest=null;if(inProgress.request.transport.readyState<4)
-inProgress.request.transport.abort();return self.dispatchQueue();}
-else
-return self.dispatchQueue();},updatePageState:function(request,transport)
+return null;},dispatchNormalRequest:function(callback)
+{new Ajax.Request(callback.url,callback.options);return true;},tryNextRequest:function()
+{var self=Prado.CallbackRequest;if(typeof(self.currentRequest)=='undefined'||self.currentRequest==null)
+{if(self.requestQueue.length>0)
+return self.dispatchQueue();}},updatePageState:function(request,transport)
{var self=Prado.CallbackRequest;var pagestate=$(self.FIELD_CALLBACK_PAGESTATE);var enabled=request.options.EnablePageStateUpdate&&request.options.HasPriority;var aborted=self.currentRequest==null;if(enabled&&!aborted&&pagestate)
{var data=request.header(self.PAGESTATE_HEADER);if(typeof(data)=="string"&&data.length>0)
pagestate.value=data;else
{if(typeof(Logger)!="undefined")
-Logger.warn("Missing page state:"+data);return false;}}
-return true;},enqueue:function(callback)
-{var self=Prado.CallbackRequest;if(self.currentRequest==null)
-self.dispatchPriorityRequest(callback);else
-self.requestQueue.push(callback);},dispatchQueue:function()
-{var self=Prado.CallbackRequest;if(self.requestQueue.length>0)
-{var callback=self.requestQueue.shift();return self.dispatchPriorityRequest(callback);}
-return false;},abortRequest:function(id)
-{var self=Prado.CallbackRequest;if(self.currentRequest!=null&&self.currentRequest.id==id)
-self.abortCurrentRequest();else
-{var queque=[];self.requestQueue.each(function(callback)
-{if(callback.id!=id)
-queque.push(callback);});self.requestQueue=queque;}}})
+Logger.warn("Missing page state:"+data);self.endCurrentRequest();return false;}}
+self.endCurrentRequest();return true;},enqueue:function(callback)
+{var self=Prado.CallbackRequest;self.requestQueue.push(callback);self.tryNextRequest();},dispatchQueue:function()
+{var self=Prado.CallbackRequest;var callback=self.requestQueue.shift();self.currentRequest=callback;callback.options.postBody=callback._getPostData(),callback.request=new Ajax.Request(callback.url,callback.options);callback.timeout=setTimeout(function()
+{self.abortRequest(callback.id);},callback.options.RequestTimeOut);},endCurrentRequest:function()
+{var self=Prado.CallbackRequest;clearTimeout(self.currentRequest.timeout);self.currentRequest=null;},abortRequest:function(id)
+{var self=Prado.CallbackRequest;if(typeof(self.currentRequest)!='undefined'&&self.currentRequest!=null&&self.currentRequest.id==id)
+{var request=self.currentRequest.request;if(request.transport.readyState<4)
+request.transport.abort();self.endCurrentRequest();}
+self.tryNextRequest();}})
Ajax.Responders.register({onComplete:function(request)
{if(request.options.HasPriority)
-Prado.CallbackRequest.abortCurrentRequest();}});Event.OnLoad(function()
+Prado.CallbackRequest.tryNextRequest();}});Event.OnLoad(function()
{if(typeof Logger!="undefined")
Ajax.Responders.register(Prado.CallbackRequest.Exception);});Prado.CallbackRequest.prototype={url:window.location.href,options:{},id:null,request:null,Enabled:true,initialize:function(id,options)
{this.id=id;this.options=Object.extend({RequestTimeOut:30000,EnablePageStateUpdate:true,HasPriority:true,CausesValidation:true,ValidationGroup:null,PostInputs:true},options||{});},setCallbackParameter:function(value)
@@ -106,7 +100,7 @@ Ajax.Responders.register(Prado.CallbackRequest.Exception);});Prado.CallbackReque
{this.options['ValidationGroup']=group;},getValidationGroup:function()
{return this.options['ValidationGroup'];},dispatch:function()
{if(typeof tinyMCE!="undefined")
-tinyMCE.triggerSave();Object.extend(this.options,{postBody:this._getPostData(),parameters:''});if(this.options.CausesValidation&&typeof(Prado.Validation)!="undefined")
+tinyMCE.triggerSave();Object.extend(this.options,{parameters:''});if(this.options.CausesValidation&&typeof(Prado.Validation)!="undefined")
{var form=this.options.Form||Prado.Validation.getForm();if(Prado.Validation.validate(form,this.options.ValidationGroup,this)==false)
return false;}
if(this.options.onPreDispatch)
@@ -241,16 +235,13 @@ this.onInit(options);},doCallback:function(event,options)
{var element=Event.findElement(event,'LI');this.index=element.autocompleteIndex;this.selectEntry();this.hide();Event.fireEvent(this.element,"change");},getUpdatedChoices:function()
{var options=new Array(this.getToken(),"__TAutoComplete_onSuggest__");Prado.Callback(this.options.EventTarget,options,null,this.options);},onComplete:function(request,boundary)
{var result=Prado.Element.extractContent(request.transport.responseText,boundary);if(typeof(result)=="string"&&result.length>0)
-this.updateChoices(result);}});Prado.WebUI.TTimeTriggeredCallback=Base.extend({count:0,timeout:0,constructor:function(options)
-{this.options=Object.extend({Interval:1,DecayRate:0},options||{})
-this.onComplete=this.options.onComplete;Prado.WebUI.TTimeTriggeredCallback.register(this);},startTimer:function()
-{this.options.onComplete=this.onRequestComplete.bind(this);this.timer=setTimeout(this.onTimerEvent.bind(this),200);},stopTimer:function()
-{(this.onComplete||Prototype.emptyFunction).apply(this,arguments);this.options.onComplete=undefined;clearTimeout(this.timer);this.timer=undefined;this.count=0;},onTimerEvent:function()
-{this.options.params=this.timeout/1000;var request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.dispatch();},onRequestComplete:function()
-{(this.onComplete||Prototype.emptyFunction).apply(this,arguments);this.timer=setTimeout(this.onTimerEvent.bind(this),this.getNewTimeout())},getNewTimeout:function()
-{switch(this.options.DecayType)
-{case'Exponential':t=(Math.exp(this.options.DecayRate*this.count*this.options.Interval))-1;break;case'Linear':t=this.options.DecayRate*this.count*this.options.Interval;break;case'Quadratic':t=this.options.DecayRate*this.count*this.count*this.options.Interval;break;case'Cubic':t=this.options.DecayRate*this.count*this.count*this.count*this.options.Interval;break;default:t=0;}
-this.timeout=(t+this.options.Interval)*1000;this.count++;return parseInt(this.timeout);}},{timers:{},register:function(timer)
+this.updateChoices(result);}});Prado.WebUI.TTimeTriggeredCallback=Base.extend({constructor:function(options)
+{this.options=Object.extend({Interval:1},options||{});Prado.WebUI.TTimeTriggeredCallback.register(this);},startTimer:function()
+{setTimeout(this.onTimerEvent.bind(this),100);if(typeof(this.timer)=='undefined'||this.timer==null)
+this.timer=setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000);},stopTimer:function()
+{if(typeof(this.timer)!='undefined')
+{clearInterval(this.timer);this.timer=null;}},onTimerEvent:function()
+{var request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.dispatch();}},{timers:{},register:function(timer)
{Prado.WebUI.TTimeTriggeredCallback.timers[timer.options.ID]=timer;},start:function(id)
{Prado.WebUI.TTimeTriggeredCallback.timers[id].startTimer();},stop:function(id)
{Prado.WebUI.TTimeTriggeredCallback.timers[id].stopTimer();}});Prado.WebUI.ActiveListControl=Base.extend({constructor:function(options)