Files
galaxy/static/scripts/utils/ajax-queue.js
T
carlfeberhard 3686ed55c3 UI, history: use arrays when filtering contents
- Moves all history filtering to returning arrays and not new
HistoryContents (subset collections)
- Reworks contents.ajaxQueue
- Moves filterAndUpdate to contents from HistoryView
2016-05-02 10:33:54 -04:00

2 lines
1.7 KiB
JavaScript

define([],function(){function a(a){var b=this;return b.deferred=jQuery.Deferred(),b.queue=[],b.responses=[],b.numToProcess=0,b.running=!1,b.init(a||[]),b.start(),b}function b(b){var c=this;return c.names={},a.call(this,b),c}return a.prototype.init=function(a){var b=this;a.forEach(function(a){b.add(a)})},a.prototype.add=function(a){var b=this,c=this.queue.length;return this.numToProcess+=1,this.queue.push(function(){var d=c,e=a();e.done(function(a){b.deferred.notify({curr:d,total:b.numToProcess,response:a})}),e.always(function(a){b.responses.push(a),b.queue.length?b.queue.shift()():b.stop()})}),this},a.prototype.start=function(){return this.queue.length&&(this.running=!0,this.queue.shift()()),this},a.prototype.stop=function(a,b){return this.running=!1,this.queue=[],a?this.deferred.reject(b):this.deferred.resolve(this.responses),this.numToProcess=0,this.deferred=jQuery.Deferred(),this},a.prototype.done=function(a){return this.deferred.done(a)},a.prototype.fail=function(a){return this.deferred.fail(a)},a.prototype.always=function(a){return this.deferred.always(a)},a.prototype.progress=function(a){return this.deferred.progress(a)},a.create=function(b){return new a(b).deferred},b.prototype=new a,b.prototype.constructor=b,b.prototype.add=function(b){if(!b.hasOwnProperty("name")||!b.hasOwnProperty("fn"))throw new Error('NamedAjaxQueue.add requires an object with both "name" and "fn": '+JSON.stringify(b));if(!this.names.hasOwnProperty(b.name))return this.names[b.name]=!0,a.prototype.add.call(this,b.fn)},b.prototype.clear=function(){return this.names={},this},b.create=function(a){return new b(a).deferred},{AjaxQueue:a,NamedAjaxQueue:b}});
//# sourceMappingURL=../../maps/utils/ajax-queue.js.map