aboutsummaryrefslogtreecommitdiffstats
path: root/src/css
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2015-10-09 15:52:29 -0400
committerTimmy Willison <timmywillisn@gmail.com>2015-10-18 12:30:00 -0400
commit67d7a2eefee768b59eb3d51cb1fb2c671873e58a (patch)
tree50f099cedd0c00039f80209e8aaa1e13ccc5ae14 /src/css
parente271f665dd8fb617a5015051e1c9df8cebd6c97b (diff)
downloadjquery-67d7a2eefee768b59eb3d51cb1fb2c671873e58a.tar.gz
jquery-67d7a2eefee768b59eb3d51cb1fb2c671873e58a.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
Diffstat (limited to 'src/css')
-rw-r--r--src/css/showHide.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/css/showHide.js b/src/css/showHide.js
index 35e15bde8..327291eb1 100644
--- a/src/css/showHide.js
+++ b/src/css/showHide.js
@@ -1,6 +1,7 @@
define( [
- "../data/var/dataPriv"
-], function( dataPriv ) {
+ "../data/var/dataPriv",
+ "../css/var/isHidden"
+], function( dataPriv, isHidden ) {
function showHide( elements, show ) {
var display, elem,
@@ -43,6 +44,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();
+ }
+ } );
+ }
+} );
} );