Commit c3cbc5bf authored by Ariel Flesler's avatar Ariel Flesler

jquery event: jQuery.toggle can accept more than 2 functions, closes #2378

parent e9c62079
...@@ -443,13 +443,13 @@ jQuery.fn.extend({ ...@@ -443,13 +443,13 @@ jQuery.fn.extend({
return this.click(function(event) { return this.click(function(event) {
// Figure out which function to execute // 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 // Make sure that clicks stop
event.preventDefault(); event.preventDefault();
// and execute the function // and execute the function
return args[this.lastToggle].apply( this, arguments ) || false; return args[this.lastToggle++].apply( this, arguments ) || false;
}); });
}, },
......
...@@ -35,7 +35,7 @@ jQuery.fn.extend({ ...@@ -35,7 +35,7 @@ jQuery.fn.extend({
toggle: function( fn, fn2 ){ toggle: function( fn, fn2 ){
return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
this._toggle( fn, fn2 ) : this._toggle.apply( this, arguments ) :
fn ? fn ?
this.animate({ this.animate({
height: "toggle", width: "toggle", opacity: "toggle" height: "toggle", width: "toggle", opacity: "toggle"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment