Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created September 3, 2010 03:03
Show Gist options
  • Save cowboy/36f3be40777bd70706b9 to your computer and use it in GitHub Desktop.
Save cowboy/36f3be40777bd70706b9 to your computer and use it in GitHub Desktop.
/*!
* jQuery queueFn - v0.7pre - 9/02/2010
* http://benalman.com/projects/jquery-misc-plugins/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,undefined){
'$:nomunge'; // Used by YUI compressor.
$.fn.queueFn = function( once, fn ) {
var that = this,
args,
args_to_slice = 2,
i = that.length;
if ( typeof once !== 'boolean' ) {
fn = once;
once = undefined;
args_to_slice = 1;
}
args = Array.prototype.slice.call( arguments, args_to_slice );
fn = $.isFunction( fn ) ? fn : $.fn[ fn ];
return that.queue(function(){
( !once || !--i ) && fn.apply( once ? that : this, args );
$.dequeue( this );
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment