| @@ 4314-4370 (lines=57) @@ | ||
| 4311 | ||
| 4312 | ||
| 4313 | ||
| 4314 | function adjustCSS( elem, prop, valueParts, tween ) { |
|
| 4315 | var adjusted, |
|
| 4316 | scale = 1, |
|
| 4317 | maxIterations = 20, |
|
| 4318 | currentValue = tween ? |
|
| 4319 | function() { return tween.cur(); } : |
|
| 4320 | function() { return jQuery.css( elem, prop, "" ); }, |
|
| 4321 | initial = currentValue(), |
|
| 4322 | unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), |
|
| 4323 | ||
| 4324 | // Starting value computation is required for potential unit mismatches |
|
| 4325 | initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && |
|
| 4326 | rcssNum.exec( jQuery.css( elem, prop ) ); |
|
| 4327 | ||
| 4328 | if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { |
|
| 4329 | ||
| 4330 | // Trust units reported by jQuery.css |
|
| 4331 | unit = unit || initialInUnit[ 3 ]; |
|
| 4332 | ||
| 4333 | // Make sure we update the tween properties later on |
|
| 4334 | valueParts = valueParts || []; |
|
| 4335 | ||
| 4336 | // Iteratively approximate from a nonzero starting point |
|
| 4337 | initialInUnit = +initial || 1; |
|
| 4338 | ||
| 4339 | do { |
|
| 4340 | ||
| 4341 | // If previous iteration zeroed out, double until we get *something*. |
|
| 4342 | // Use string for doubling so we don't accidentally see scale as unchanged below |
|
| 4343 | scale = scale || ".5"; |
|
| 4344 | ||
| 4345 | // Adjust and apply |
|
| 4346 | initialInUnit = initialInUnit / scale; |
|
| 4347 | jQuery.style( elem, prop, initialInUnit + unit ); |
|
| 4348 | ||
| 4349 | // Update scale, tolerating zero or NaN from tween.cur() |
|
| 4350 | // Break the loop if scale is unchanged or perfect, or if we've just had enough. |
|
| 4351 | } while ( |
|
| 4352 | scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations |
|
| 4353 | ); |
|
| 4354 | } |
|
| 4355 | ||
| 4356 | if ( valueParts ) { |
|
| 4357 | initialInUnit = +initialInUnit || +initial || 0; |
|
| 4358 | ||
| 4359 | // Apply relative offset (+=/-=) if specified |
|
| 4360 | adjusted = valueParts[ 1 ] ? |
|
| 4361 | initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : |
|
| 4362 | +valueParts[ 2 ]; |
|
| 4363 | if ( tween ) { |
|
| 4364 | tween.unit = unit; |
|
| 4365 | tween.start = initialInUnit; |
|
| 4366 | tween.end = adjusted; |
|
| 4367 | } |
|
| 4368 | } |
|
| 4369 | return adjusted; |
|
| 4370 | } |
|
| 4371 | ||
| 4372 | ||
| 4373 | // Multifunctional method to get and set values of a collection |
|
| @@ 4182-4238 (lines=57) @@ | ||
| 4179 | ||
| 4180 | ||
| 4181 | ||
| 4182 | function adjustCSS( elem, prop, valueParts, tween ) { |
|
| 4183 | var adjusted, |
|
| 4184 | scale = 1, |
|
| 4185 | maxIterations = 20, |
|
| 4186 | currentValue = tween ? |
|
| 4187 | function() { return tween.cur(); } : |
|
| 4188 | function() { return jQuery.css( elem, prop, "" ); }, |
|
| 4189 | initial = currentValue(), |
|
| 4190 | unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), |
|
| 4191 | ||
| 4192 | // Starting value computation is required for potential unit mismatches |
|
| 4193 | initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && |
|
| 4194 | rcssNum.exec( jQuery.css( elem, prop ) ); |
|
| 4195 | ||
| 4196 | if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { |
|
| 4197 | ||
| 4198 | // Trust units reported by jQuery.css |
|
| 4199 | unit = unit || initialInUnit[ 3 ]; |
|
| 4200 | ||
| 4201 | // Make sure we update the tween properties later on |
|
| 4202 | valueParts = valueParts || []; |
|
| 4203 | ||
| 4204 | // Iteratively approximate from a nonzero starting point |
|
| 4205 | initialInUnit = +initial || 1; |
|
| 4206 | ||
| 4207 | do { |
|
| 4208 | ||
| 4209 | // If previous iteration zeroed out, double until we get *something*. |
|
| 4210 | // Use string for doubling so we don't accidentally see scale as unchanged below |
|
| 4211 | scale = scale || ".5"; |
|
| 4212 | ||
| 4213 | // Adjust and apply |
|
| 4214 | initialInUnit = initialInUnit / scale; |
|
| 4215 | jQuery.style( elem, prop, initialInUnit + unit ); |
|
| 4216 | ||
| 4217 | // Update scale, tolerating zero or NaN from tween.cur() |
|
| 4218 | // Break the loop if scale is unchanged or perfect, or if we've just had enough. |
|
| 4219 | } while ( |
|
| 4220 | scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations |
|
| 4221 | ); |
|
| 4222 | } |
|
| 4223 | ||
| 4224 | if ( valueParts ) { |
|
| 4225 | initialInUnit = +initialInUnit || +initial || 0; |
|
| 4226 | ||
| 4227 | // Apply relative offset (+=/-=) if specified |
|
| 4228 | adjusted = valueParts[ 1 ] ? |
|
| 4229 | initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : |
|
| 4230 | +valueParts[ 2 ]; |
|
| 4231 | if ( tween ) { |
|
| 4232 | tween.unit = unit; |
|
| 4233 | tween.start = initialInUnit; |
|
| 4234 | tween.end = adjusted; |
|
| 4235 | } |
|
| 4236 | } |
|
| 4237 | return adjusted; |
|
| 4238 | } |
|
| 4239 | var rcheckableType = ( /^(?:checkbox|radio)$/i ); |
|
| 4240 | ||
| 4241 | var rtagName = ( /<([\w:-]+)/ ); |
|