3 "./manipulation/var/rcheckableType",
5 "./traversing", // filter
7 ], function( jQuery, rcheckableType ) {
14 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
15 rsubmittable = /^(?:input|select|textarea|keygen)/i;
17 function buildParams( prefix, obj, traditional, add ) {
20 if ( Array.isArray( obj ) ) {
22 // Serialize array item.
23 jQuery.each( obj, function( i, v ) {
24 if ( traditional || rbracket.test( prefix ) ) {
26 // Treat each array item as a scalar.
31 // Item is non-scalar (array or object), encode its numeric index.
33 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
41 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
43 // Serialize object item.
45 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
50 // Serialize scalar item.
55 // Serialize an array of form elements or a set of
56 // key/values into a query string
57 jQuery.param = function( a, traditional ) {
60 add = function( key, valueOrFunction ) {
62 // If value is a function, invoke it and use its return value
63 var value = jQuery.isFunction( valueOrFunction ) ?
67 s[ s.length ] = encodeURIComponent( key ) + "=" +
68 encodeURIComponent( value == null ? "" : value );
71 // If an array was passed in, assume that it is an array of form elements.
72 if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
74 // Serialize the form elements
75 jQuery.each( a, function() {
76 add( this.name, this.value );
81 // If traditional, encode the "old" way (the way 1.3.2 or older
82 // did it), otherwise encode params recursively.
84 buildParams( prefix, a[ prefix ], traditional, add );
88 // Return the resulting serialization
93 serialize: function() {
94 return jQuery.param( this.serializeArray() );
96 serializeArray: function() {
97 return this.map( function() {
99 // Can add propHook for "elements" to filter or add form elements
100 var elements = jQuery.prop( this, "elements" );
101 return elements ? jQuery.makeArray( elements ) : this;
103 .filter( function() {
104 var type = this.type;
106 // Use .is( ":disabled" ) so that fieldset[disabled] works
107 return this.name && !jQuery( this ).is( ":disabled" ) &&
108 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
109 ( this.checked || !rcheckableType.test( type ) );
111 .map( function( i, elem ) {
112 var val = jQuery( this ).val();
118 if ( Array.isArray( val ) ) {
119 return jQuery.map( val, function( val ) {
120 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
124 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };