aboutsummaryrefslogtreecommitdiffstats
path: root/src/css
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2015-10-09 15:52:29 -0400
committerRichard Gibson <richard.gibson@gmail.com>2015-10-25 14:54:55 -0400
commit3842246024475eafdc8a00a7ac4358d06d76cab2 (patch)
treed0a199786425bf4c4d1d4f8c616a859d8725b397 /src/css
parentbd11778168e5d96b513a03015864aa0fc9536acb (diff)
downloadjquery-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.js26
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();
+ }
+ } );
+ }
+} );
} );