| @@ 4082-4119 (lines=38) @@ | ||
| 4079 | }); |
|
| 4080 | }, |
|
| 4081 | ||
| 4082 | addClass: function( value ) { |
|
| 4083 | var classes, elem, cur, clazz, j, |
|
| 4084 | i = 0, |
|
| 4085 | len = this.length, |
|
| 4086 | proceed = typeof value === "string" && value; |
|
| 4087 | ||
| 4088 | if ( jQuery.isFunction( value ) ) { |
|
| 4089 | return this.each(function( j ) { |
|
| 4090 | jQuery( this ).addClass( value.call( this, j, this.className ) ); |
|
| 4091 | }); |
|
| 4092 | } |
|
| 4093 | ||
| 4094 | if ( proceed ) { |
|
| 4095 | // The disjunction here is for better compressibility (see removeClass) |
|
| 4096 | classes = ( value || "" ).match( core_rnotwhite ) || []; |
|
| 4097 | ||
| 4098 | for ( ; i < len; i++ ) { |
|
| 4099 | elem = this[ i ]; |
|
| 4100 | cur = elem.nodeType === 1 && ( elem.className ? |
|
| 4101 | ( " " + elem.className + " " ).replace( rclass, " " ) : |
|
| 4102 | " " |
|
| 4103 | ); |
|
| 4104 | ||
| 4105 | if ( cur ) { |
|
| 4106 | j = 0; |
|
| 4107 | while ( (clazz = classes[j++]) ) { |
|
| 4108 | if ( cur.indexOf( " " + clazz + " " ) < 0 ) { |
|
| 4109 | cur += clazz + " "; |
|
| 4110 | } |
|
| 4111 | } |
|
| 4112 | elem.className = jQuery.trim( cur ); |
|
| 4113 | ||
| 4114 | } |
|
| 4115 | } |
|
| 4116 | } |
|
| 4117 | ||
| 4118 | return this; |
|
| 4119 | }, |
|
| 4120 | ||
| 4121 | removeClass: function( value ) { |
|
| 4122 | var classes, elem, cur, clazz, j, |
|
| @@ 4121-4157 (lines=37) @@ | ||
| 4118 | return this; |
|
| 4119 | }, |
|
| 4120 | ||
| 4121 | removeClass: function( value ) { |
|
| 4122 | var classes, elem, cur, clazz, j, |
|
| 4123 | i = 0, |
|
| 4124 | len = this.length, |
|
| 4125 | proceed = arguments.length === 0 || typeof value === "string" && value; |
|
| 4126 | ||
| 4127 | if ( jQuery.isFunction( value ) ) { |
|
| 4128 | return this.each(function( j ) { |
|
| 4129 | jQuery( this ).removeClass( value.call( this, j, this.className ) ); |
|
| 4130 | }); |
|
| 4131 | } |
|
| 4132 | if ( proceed ) { |
|
| 4133 | classes = ( value || "" ).match( core_rnotwhite ) || []; |
|
| 4134 | ||
| 4135 | for ( ; i < len; i++ ) { |
|
| 4136 | elem = this[ i ]; |
|
| 4137 | // This expression is here for better compressibility (see addClass) |
|
| 4138 | cur = elem.nodeType === 1 && ( elem.className ? |
|
| 4139 | ( " " + elem.className + " " ).replace( rclass, " " ) : |
|
| 4140 | "" |
|
| 4141 | ); |
|
| 4142 | ||
| 4143 | if ( cur ) { |
|
| 4144 | j = 0; |
|
| 4145 | while ( (clazz = classes[j++]) ) { |
|
| 4146 | // Remove *all* instances |
|
| 4147 | while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { |
|
| 4148 | cur = cur.replace( " " + clazz + " ", " " ); |
|
| 4149 | } |
|
| 4150 | } |
|
| 4151 | elem.className = value ? jQuery.trim( cur ) : ""; |
|
| 4152 | } |
|
| 4153 | } |
|
| 4154 | } |
|
| 4155 | ||
| 4156 | return this; |
|
| 4157 | }, |
|
| 4158 | ||
| 4159 | toggleClass: function( value, stateVal ) { |
|
| 4160 | var type = typeof value; |
|