Skip to content

Instantly share code, notes, and snippets.

@wuxianliang
Forked from zohararad/queue.js
Created August 5, 2013 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wuxianliang/6156149 to your computer and use it in GitHub Desktop.
Save wuxianliang/6156149 to your computer and use it in GitHub Desktop.
$.fn.queue = function(){
var Q = function(){
this.q = [];
}
Q.prototype = {
enqueue: function(el){
if($.isArray(el)){
this.q = el;
} else {
this.q.push(el);
}
return this.q;
},
queue: function(){
var args = Array.prototype.slice.call(arguments, 0);
if(args.length === 0){
return this.q;
} else {
return this.enqueue.apply(this,args);
}
}
}
this.q = this.q || new Q();
var args = Array.prototype.slice.call(arguments, 0);
return this.q.queue.apply(this.q, args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment