diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2015-10-09 15:52:29 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2015-10-25 14:54:55 -0400 |
commit | 3842246024475eafdc8a00a7ac4358d06d76cab2 (patch) | |
tree | d0a199786425bf4c4d1d4f8c616a859d8725b397 /src/css | |
parent | bd11778168e5d96b513a03015864aa0fc9536acb (diff) | |
download | jquery-3842246024475eafdc8a00a7ac4358d06d76cab2.tar.gz jquery-3842246024475eafdc8a00a7ac4358d06d76cab2.zip |
CSS: Make show/hide/toggle methods a module
Unit test changes some uses of .show() and .hide() to .css( "display", ... ),
there was already an implicit assumption in several of the existing tests.
Fixes gh-2193
Close gh-2648
(cherry picked from commit 67d7a2eefee768b59eb3d51cb1fb2c671873e58a)
Conflicts:
Gruntfile.js
src/css.js
src/css/showHide.js
test/unit/css.js
Diffstat (limited to 'src/css')
-rw-r--r-- | src/css/showHide.js | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/css/showHide.js b/src/css/showHide.js index efc1bdd3f..d143d4885 100644 --- a/src/css/showHide.js +++ b/src/css/showHide.js @@ -1,4 +1,6 @@ -define( [], function() { +define( [ + "../css/var/isHidden" +], function( isHidden ) { function showHide( elements, show ) { var display, elem, @@ -41,6 +43,26 @@ function showHide( elements, show ) { return elements; } -return showHide; +jQuery.fn.extend( { + show: function() { + return showHide( this, true ); + }, + hide: function() { + return showHide( this ); + }, + toggle: function( state ) { + if ( typeof state === "boolean" ) { + return state ? this.show() : this.hide(); + } + + return this.each( function() { + if ( isHidden( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } + } ); + } +} ); } ); |