summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Bas <ctrlaltca@gmail.com>2014-01-06 23:10:22 +0100
committerFabio Bas <ctrlaltca@gmail.com>2014-01-06 23:10:22 +0100
commitac4eaa30cc19cddec0aae5621d136a5a5fe7777c (patch)
tree1771c92532b0accf82642b5a9c384a2dd33c880a
parent498a2ca334c38f3f1e51081acb9e8492810fb42c (diff)
Implemented ajax queue (based on https://github.com/gnarf37/jquery-ajaxQueue)
-rw-r--r--framework/Web/Javascripts/source/prado/activecontrols/ajax3.js53
-rw-r--r--jQuery-WIP.txt2
2 files changed, 52 insertions, 3 deletions
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js
index 597187bb..e6616176 100644
--- a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js
+++ b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js
@@ -66,6 +66,55 @@ Prado.CallbackRequestManager =
}
msg += e.version+" "+e.time+"\n";
return msg;
+ },
+
+ /*! jQuery Ajax Queue - v0.1.2pre - 2013-03-19
+ * https://github.com/gnarf37/jquery-ajaxQueue
+ * Copyright (c) 2013 Corey Frang; Licensed MIT
+ * Slightly adapted for use within prado by Fabio Bas <ctrlaltca@gmail.com>
+ */
+
+ // jQuery on an empty object, we are going to use this as our Queue
+ ajaxQueue : jQuery({}),
+
+ ajax : function( ajaxOpts ) {
+ var jqXHR,
+ dfd = jQuery.Deferred(),
+ promise = dfd.promise();
+
+ // run the actual query
+ function doRequest( next ) {
+ jqXHR = jQuery.ajax( ajaxOpts );
+ jqXHR.done( dfd.resolve )
+ .fail( dfd.reject )
+ .then( next, next );
+ }
+
+ // queue our ajax request
+ Prado.CallbackRequestManager.ajaxQueue.queue( doRequest );
+
+ // add the abort method
+ promise.abort = function( statusText ) {
+
+ // proxy abort to the jqXHR if it is active
+ if ( jqXHR ) {
+ return jqXHR.abort( statusText );
+ }
+
+ // if there wasn't already a jqXHR we need to remove from queue
+ var queue = Prado.CallbackRequestManager.ajaxQueue.queue(),
+ index = jQuery.inArray( doRequest, queue );
+
+ if ( index > -1 ) {
+ queue.splice( index, 1 );
+ }
+
+ // and then reject the deferred
+ dfd.rejectWith( ajaxOpts.context || ajaxOpts, [ promise, statusText, "" ] );
+ return promise;
+ };
+
+ return promise;
}
};
@@ -215,7 +264,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack,
this.options.data = this.getParameters();
this.options.url = this.getCallbackUrl();
- this.request = jQuery.ajax(this.options);
+ this.request = Prado.CallbackRequestManager.ajax(this.options);
},
abort : function()
@@ -239,7 +288,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack,
if(this.options.EventTarget)
data[Prado.CallbackRequestManager.FIELD_CALLBACK_TARGET] = this.options.EventTarget;
- if(this.options.PostInputs != false)
+ if(this.options.PostInputs != false)
return jQuery(form).serialize() + '&' + jQuery.param(data);
else
return jQuery.param(data);
diff --git a/jQuery-WIP.txt b/jQuery-WIP.txt
index c1726b45..61fc6787 100644
--- a/jQuery-WIP.txt
+++ b/jQuery-WIP.txt
@@ -23,6 +23,7 @@ Basic postback controls (TButton, TCheckBox, TLinkButton, TRadioButton, TTextBox
Js-based controls (TTabPanel, TDatePicker, TColorPicker, TSlider, THtmlArea, TAccordion)
List, Data controls
*Validators
+Ajax queue
Basic callback controls (TActive*, TInPlaceTextBox)
Badic jquery-ui controls
@@ -31,7 +32,6 @@ TJuiAutoComplete
TJuiDraggable,TJuiDroppable
TBD
-Implement Ajax queue
Port *ratings
Add JQuery-ui-Effects: clip, explode, transfer, switchclass
Add JQuery-ui-Methods: show, hide, toggle?