| @@ 1797-1833 (lines=37) @@ | ||
| 1794 | return this; |
|
| 1795 | }, |
|
| 1796 | ||
| 1797 | toggleClass: function( value, stateVal ) { |
|
| 1798 | var type = typeof value, |
|
| 1799 | isBool = typeof stateVal === "boolean"; |
|
| 1800 | ||
| 1801 | if ( jQuery.isFunction( value ) ) { |
|
| 1802 | return this.each(function(i) { |
|
| 1803 | var self = jQuery(this); |
|
| 1804 | self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal ); |
|
| 1805 | }); |
|
| 1806 | } |
|
| 1807 | ||
| 1808 | return this.each(function() { |
|
| 1809 | if ( type === "string" ) { |
|
| 1810 | // toggle individual class names |
|
| 1811 | var className, |
|
| 1812 | i = 0, |
|
| 1813 | self = jQuery( this ), |
|
| 1814 | state = stateVal, |
|
| 1815 | classNames = value.split( rspaces ); |
|
| 1816 | ||
| 1817 | while ( (className = classNames[ i++ ]) ) { |
|
| 1818 | // check each className given, space seperated list |
|
| 1819 | state = isBool ? state : !self.hasClass( className ); |
|
| 1820 | self[ state ? "addClass" : "removeClass" ]( className ); |
|
| 1821 | } |
|
| 1822 | ||
| 1823 | } else if ( type === "undefined" || type === "boolean" ) { |
|
| 1824 | if ( this.className ) { |
|
| 1825 | // store className if set |
|
| 1826 | jQuery._data( this, "__className__", this.className ); |
|
| 1827 | } |
|
| 1828 | ||
| 1829 | // toggle whole className |
|
| 1830 | this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; |
|
| 1831 | } |
|
| 1832 | }); |
|
| 1833 | }, |
|
| 1834 | ||
| 1835 | hasClass: function( selector ) { |
|
| 1836 | var className = " " + selector + " "; |
|
| @@ 2261-2296 (lines=36) @@ | ||
| 2258 | return this; |
|
| 2259 | }, |
|
| 2260 | ||
| 2261 | toggleClass: function( value, stateVal ) { |
|
| 2262 | var type = typeof value, |
|
| 2263 | isBool = typeof stateVal === "boolean"; |
|
| 2264 | ||
| 2265 | if ( jQuery.isFunction( value ) ) { |
|
| 2266 | return this.each(function( i ) { |
|
| 2267 | jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); |
|
| 2268 | }); |
|
| 2269 | } |
|
| 2270 | ||
| 2271 | return this.each(function() { |
|
| 2272 | if ( type === "string" ) { |
|
| 2273 | // toggle individual class names |
|
| 2274 | var className, |
|
| 2275 | i = 0, |
|
| 2276 | self = jQuery( this ), |
|
| 2277 | state = stateVal, |
|
| 2278 | classNames = value.split( rspace ); |
|
| 2279 | ||
| 2280 | while ( (className = classNames[ i++ ]) ) { |
|
| 2281 | // check each className given, space seperated list |
|
| 2282 | state = isBool ? state : !self.hasClass( className ); |
|
| 2283 | self[ state ? "addClass" : "removeClass" ]( className ); |
|
| 2284 | } |
|
| 2285 | ||
| 2286 | } else if ( type === "undefined" || type === "boolean" ) { |
|
| 2287 | if ( this.className ) { |
|
| 2288 | // store className if set |
|
| 2289 | jQuery._data( this, "__className__", this.className ); |
|
| 2290 | } |
|
| 2291 | ||
| 2292 | // toggle whole className |
|
| 2293 | this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; |
|
| 2294 | } |
|
| 2295 | }); |
|
| 2296 | }, |
|
| 2297 | ||
| 2298 | hasClass: function( selector ) { |
|
| 2299 | var className = " " + selector + " ", |
|