From c3cbc5bf98ad9bbed0c416b20f08b63d3b343448 Mon Sep 17 00:00:00 2001 From: Ariel Flesler Date: Tue, 29 Apr 2008 21:35:35 +0000 Subject: [PATCH] jquery event: jQuery.toggle can accept more than 2 functions, closes #2378 --- src/event.js | 4 ++-- src/fx.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/event.js b/src/event.js index 0cf6c58..b72ce7c 100644 --- a/src/event.js +++ b/src/event.js @@ -443,13 +443,13 @@ jQuery.fn.extend({ return this.click(function(event) { // Figure out which function to execute - this.lastToggle = 0 == this.lastToggle ? 1 : 0; + this.lastToggle = (this.lastToggle||0) % args.length; // Make sure that clicks stop event.preventDefault(); // and execute the function - return args[this.lastToggle].apply( this, arguments ) || false; + return args[this.lastToggle++].apply( this, arguments ) || false; }); }, diff --git a/src/fx.js b/src/fx.js index 824616a..d5185c5 100644 --- a/src/fx.js +++ b/src/fx.js @@ -35,7 +35,7 @@ jQuery.fn.extend({ toggle: function( fn, fn2 ){ return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? - this._toggle( fn, fn2 ) : + this._toggle.apply( this, arguments ) : fn ? this.animate({ height: "toggle", width: "toggle", opacity: "toggle" -- 1.7.10.4