@@ 7533-7598 (lines=66) @@ | ||
7530 | var rreturn = /\r/g; |
|
7531 | ||
7532 | jQuery.fn.extend( { |
|
7533 | val: function( value ) { |
|
7534 | var hooks, ret, isFunction, |
|
7535 | elem = this[ 0 ]; |
|
7536 | ||
7537 | if ( !arguments.length ) { |
|
7538 | if ( elem ) { |
|
7539 | hooks = jQuery.valHooks[ elem.type ] || |
|
7540 | jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
|
7541 | ||
7542 | if ( hooks && |
|
7543 | "get" in hooks && |
|
7544 | ( ret = hooks.get( elem, "value" ) ) !== undefined |
|
7545 | ) { |
|
7546 | return ret; |
|
7547 | } |
|
7548 | ||
7549 | ret = elem.value; |
|
7550 | ||
7551 | return typeof ret === "string" ? |
|
7552 | ||
7553 | // Handle most common string cases |
|
7554 | ret.replace( rreturn, "" ) : |
|
7555 | ||
7556 | // Handle cases where value is null/undef or number |
|
7557 | ret == null ? "" : ret; |
|
7558 | } |
|
7559 | ||
7560 | return; |
|
7561 | } |
|
7562 | ||
7563 | isFunction = jQuery.isFunction( value ); |
|
7564 | ||
7565 | return this.each( function( i ) { |
|
7566 | var val; |
|
7567 | ||
7568 | if ( this.nodeType !== 1 ) { |
|
7569 | return; |
|
7570 | } |
|
7571 | ||
7572 | if ( isFunction ) { |
|
7573 | val = value.call( this, i, jQuery( this ).val() ); |
|
7574 | } else { |
|
7575 | val = value; |
|
7576 | } |
|
7577 | ||
7578 | // Treat null/undefined as ""; convert numbers to string |
|
7579 | if ( val == null ) { |
|
7580 | val = ""; |
|
7581 | ||
7582 | } else if ( typeof val === "number" ) { |
|
7583 | val += ""; |
|
7584 | ||
7585 | } else if ( jQuery.isArray( val ) ) { |
|
7586 | val = jQuery.map( val, function( value ) { |
|
7587 | return value == null ? "" : value + ""; |
|
7588 | } ); |
|
7589 | } |
|
7590 | ||
7591 | hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; |
|
7592 | ||
7593 | // If set returns undefined, fall back to normal setting |
|
7594 | if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { |
|
7595 | this.value = val; |
|
7596 | } |
|
7597 | } ); |
|
7598 | } |
|
7599 | } ); |
|
7600 | ||
7601 | jQuery.extend( { |
@@ 8204-8268 (lines=65) @@ | ||
8201 | var rreturn = /\r/g; |
|
8202 | ||
8203 | jQuery.fn.extend( { |
|
8204 | val: function( value ) { |
|
8205 | var hooks, ret, isFunction, |
|
8206 | elem = this[ 0 ]; |
|
8207 | ||
8208 | if ( !arguments.length ) { |
|
8209 | if ( elem ) { |
|
8210 | hooks = jQuery.valHooks[ elem.type ] || |
|
8211 | jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
|
8212 | ||
8213 | if ( |
|
8214 | hooks && |
|
8215 | "get" in hooks && |
|
8216 | ( ret = hooks.get( elem, "value" ) ) !== undefined |
|
8217 | ) { |
|
8218 | return ret; |
|
8219 | } |
|
8220 | ||
8221 | ret = elem.value; |
|
8222 | ||
8223 | return typeof ret === "string" ? |
|
8224 | ||
8225 | // handle most common string cases |
|
8226 | ret.replace( rreturn, "" ) : |
|
8227 | ||
8228 | // handle cases where value is null/undef or number |
|
8229 | ret == null ? "" : ret; |
|
8230 | } |
|
8231 | ||
8232 | return; |
|
8233 | } |
|
8234 | ||
8235 | isFunction = jQuery.isFunction( value ); |
|
8236 | ||
8237 | return this.each( function( i ) { |
|
8238 | var val; |
|
8239 | ||
8240 | if ( this.nodeType !== 1 ) { |
|
8241 | return; |
|
8242 | } |
|
8243 | ||
8244 | if ( isFunction ) { |
|
8245 | val = value.call( this, i, jQuery( this ).val() ); |
|
8246 | } else { |
|
8247 | val = value; |
|
8248 | } |
|
8249 | ||
8250 | // Treat null/undefined as ""; convert numbers to string |
|
8251 | if ( val == null ) { |
|
8252 | val = ""; |
|
8253 | } else if ( typeof val === "number" ) { |
|
8254 | val += ""; |
|
8255 | } else if ( jQuery.isArray( val ) ) { |
|
8256 | val = jQuery.map( val, function( value ) { |
|
8257 | return value == null ? "" : value + ""; |
|
8258 | } ); |
|
8259 | } |
|
8260 | ||
8261 | hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; |
|
8262 | ||
8263 | // If set returns undefined, fall back to normal setting |
|
8264 | if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { |
|
8265 | this.value = val; |
|
8266 | } |
|
8267 | } ); |
|
8268 | } |
|
8269 | } ); |
|
8270 | ||
8271 | jQuery.extend( { |
@@ 7294-7353 (lines=60) @@ | ||
7291 | var rreturn = /\r/g; |
|
7292 | ||
7293 | jQuery.fn.extend({ |
|
7294 | val: function( value ) { |
|
7295 | var hooks, ret, isFunction, |
|
7296 | elem = this[0]; |
|
7297 | ||
7298 | if ( !arguments.length ) { |
|
7299 | if ( elem ) { |
|
7300 | hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
|
7301 | ||
7302 | if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { |
|
7303 | return ret; |
|
7304 | } |
|
7305 | ||
7306 | ret = elem.value; |
|
7307 | ||
7308 | return typeof ret === "string" ? |
|
7309 | // handle most common string cases |
|
7310 | ret.replace(rreturn, "") : |
|
7311 | // handle cases where value is null/undef or number |
|
7312 | ret == null ? "" : ret; |
|
7313 | } |
|
7314 | ||
7315 | return; |
|
7316 | } |
|
7317 | ||
7318 | isFunction = jQuery.isFunction( value ); |
|
7319 | ||
7320 | return this.each(function( i ) { |
|
7321 | var val; |
|
7322 | ||
7323 | if ( this.nodeType !== 1 ) { |
|
7324 | return; |
|
7325 | } |
|
7326 | ||
7327 | if ( isFunction ) { |
|
7328 | val = value.call( this, i, jQuery( this ).val() ); |
|
7329 | } else { |
|
7330 | val = value; |
|
7331 | } |
|
7332 | ||
7333 | // Treat null/undefined as ""; convert numbers to string |
|
7334 | if ( val == null ) { |
|
7335 | val = ""; |
|
7336 | ||
7337 | } else if ( typeof val === "number" ) { |
|
7338 | val += ""; |
|
7339 | ||
7340 | } else if ( jQuery.isArray( val ) ) { |
|
7341 | val = jQuery.map( val, function( value ) { |
|
7342 | return value == null ? "" : value + ""; |
|
7343 | }); |
|
7344 | } |
|
7345 | ||
7346 | hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; |
|
7347 | ||
7348 | // If set returns undefined, fall back to normal setting |
|
7349 | if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { |
|
7350 | this.value = val; |
|
7351 | } |
|
7352 | }); |
|
7353 | } |
|
7354 | }); |
|
7355 | ||
7356 | jQuery.extend({ |