Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added .queueFn( [ once, ] fn [, arg... ] ) signature, if once (Boolea…

…n) is true, callback executes just once (not once for each selected element)
  • Loading branch information...
commit 3da4e209f3e8276dae843f5fe8607ba83e739a81 1 parent f3e6b8e
@temp01 temp01 authored committed
Showing with 13 additions and 3 deletions.
  1. +13 −3 jquery.ba-queuefn.js
View
16 jquery.ba-queuefn.js
@@ -1,5 +1,5 @@
/*!
- * jQuery queueFn - v0.6 - 06/21/2010
+ * jQuery queueFn - v0.7 - 9/05/2010
* http://benalman.com/projects/jquery-misc-plugins/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
@@ -11,12 +11,22 @@
'$:nomunge'; // Used by YUI compressor.
$.fn.queueFn = function( fn ) {
- var args = Array.prototype.slice.call( arguments, 1 );
+ var i,
+ that,
+ args = Array.prototype.slice.call( arguments, 1 );
+
+ if ( typeof fn === 'boolean' ) {
+ if ( fn ) {
+ that = this;
+ i = this.length;
+ }
+ fn = args.shift();
+ }
fn = $.isFunction( fn ) ? fn : $.fn[ fn ];
return this.queue(function(){
- fn.apply( $(this), args );
+ !--i && fn.apply( that || this, args );
$.dequeue( this );
});
};
Please sign in to comment.
Something went wrong with that request. Please try again.