Make the maintenance page a hardcoded response
[Melange.git] / app / jquery / jquery-ajaxQueue.js
blob7b621b4f2465283b3f66aaab3141641c840afc5a
1 /**
2 * Ajax Queue Plugin
4 * Homepage: http://jquery.com/plugins/project/ajaxqueue
5 * Documentation: http://docs.jquery.com/AjaxQueue
6 */
8 /**
10 <script>
11 $(function(){
12 jQuery.ajaxQueue({
13 url: "test.php",
14 success: function(html){ jQuery("ul").append(html); }
15 });
16 jQuery.ajaxQueue({
17 url: "test.php",
18 success: function(html){ jQuery("ul").append(html); }
19 });
20 jQuery.ajaxSync({
21 url: "test.php",
22 success: function(html){ jQuery("ul").append("<b>"+html+"</b>"); }
23 });
24 jQuery.ajaxSync({
25 url: "test.php",
26 success: function(html){ jQuery("ul").append("<b>"+html+"</b>"); }
27 });
28 });
29 </script>
30 <ul style="position: absolute; top: 5px; right: 5px;"></ul>
34 * Queued Ajax requests.
35 * A new Ajax request won't be started until the previous queued
36 * request has finished.
40 * Synced Ajax requests.
41 * The Ajax request will happen as soon as you call this method, but
42 * the callbacks (success/error/complete) won't fire until all previous
43 * synced requests have been completed.
47 (function($) {
49 var ajax = $.ajax;
51 var pendingRequests = {};
53 var synced = [];
54 var syncedData = [];
56 $.ajax = function(settings) {
57 // create settings for compatibility with ajaxSetup
58 settings = jQuery.extend(settings, jQuery.extend({}, jQuery.ajaxSettings, settings));
60 var port = settings.port;
62 switch(settings.mode) {
63 case "abort":
64 if ( pendingRequests[port] ) {
65 pendingRequests[port].abort();
67 return pendingRequests[port] = ajax.apply(this, arguments);
68 case "queue":
69 var _old = settings.complete;
70 settings.complete = function(){
71 if ( _old )
72 _old.apply( this, arguments );
73 jQuery([ajax]).dequeue("ajax" + port );;
76 jQuery([ ajax ]).queue("ajax" + port, function(){
77 ajax( settings );
78 });
79 return;
80 case "sync":
81 var pos = synced.length;
83 synced[ pos ] = {
84 error: settings.error,
85 success: settings.success,
86 complete: settings.complete,
87 done: false
90 syncedData[ pos ] = {
91 error: [],
92 success: [],
93 complete: []
96 settings.error = function(){ syncedData[ pos ].error = arguments; };
97 settings.success = function(){ syncedData[ pos ].success = arguments; };
98 settings.complete = function(){
99 syncedData[ pos ].complete = arguments;
100 synced[ pos ].done = true;
102 if ( pos == 0 || !synced[ pos-1 ] )
103 for ( var i = pos; i < synced.length && synced[i].done; i++ ) {
104 if ( synced[i].error ) synced[i].error.apply( jQuery, syncedData[i].error );
105 if ( synced[i].success ) synced[i].success.apply( jQuery, syncedData[i].success );
106 if ( synced[i].complete ) synced[i].complete.apply( jQuery, syncedData[i].complete );
108 synced[i] = null;
109 syncedData[i] = null;
113 return ajax.apply(this, arguments);
116 })(jQuery);