/** * jQuery.ajaxq 0.5.2 * jQuery plugin for AJAX queueing. This extension can be used also with Zepto.js. * https://github.com/shults/jquery.ajaxq/ * Yaroslav Kotsur * Distributed under MIT license */ !function(a){"use strict";var b=a.jQuery||a.Zepto||a.$;if("undefined"==typeof b)throw"jquery.ajaxq requires jQuery or jQuery-compatible library (e.g. Zepto.js)";var c=Array.prototype.slice,d=function(a){return!b.isArray(a)&&a-parseFloat(a)+1>=0},e=function(a){return"[object Object]"===Object.prototype.toString.call(a)},f=function(a){function d(a,c){this._aborted=!1,this._jqXHR=null,this._calls={},this._args=[a,c],this._deferred=b.Deferred(),this._deferred.pipe=this._deferred.then,this.readyState=1}var f=d.prototype;b.extend(f,{run:function(){var a,c,d,f=this._deferred;if(null!==this._jqXHR)return this._jqXHR;var g=this._args[0],h=this._args[1];h=e(g)?g:b.extend(!0,h||{},{url:g}),this._jqXHR=b.ajax.call(b,h),this._jqXHR.done(function(){f.resolve.apply(f,arguments)}),this._jqXHR.fail(function(){f.reject.apply(f,arguments)}),this._aborted&&this._jqXHR.abort(this.statusText);for(a in this._calls){c=this._calls[a];for(var d in c)this._jqXHR[a].apply(this._jqXHR,c[d])}return this._jqXHR},_call:function(a,b){return null!==this._jqXHR?"undefined"==typeof this._jqXHR[a]?this._jqXHR:this._jqXHR[a].apply(this._jqXHR,b):(this._calls[a]=this._calls[a]||[],this._calls[a].push(b),this)},abort:function(a){if(null!==this._jqXHR){var c=this,d=["readyState","status","statusText"],e=this._jqXHR.abort.apply(this._jqXHR,arguments)||this._jqXHR;return e&&b.each(d,function(a,b){c[b]=e[b]}),e}return this.statusText=a||"abort",this.status=0,this.readyState=0,this._aborted=!0,this},state:function(){return null!==this._jqXHR?this._jqXHR.state.apply(this._jqXHR,arguments):"pending"}});var g=["setRequestHeader","overrideMimeType","statusCode","done","fail","progress","complete","success","error","always"];b.each(g,function(a,b){f[b]=function(){return this._call(b,c.call(arguments))||this._jqXHR}});var h=["getResponseHeader","getAllResponseHeaders"];b.each(h,function(a,b){f[b]=function(){return null!==this._jqXHR?this._jqXHR[b].apply(this,arguments):null}});var i=["pipe","then","promise"];return b.each(i,function(a,b){f[b]=function(){return this._deferred[b].apply(this._deferred,arguments)}}),d}(),g=function(){function a(c,d){var e=g(c).indexOf(d),f=h(c).shift();-1!==e&&g(c).splice(e,1),"undefined"!=typeof f&&f.always(b.proxy(a,null,c,f)).run()}function c(c,d){g(c).length