3 "./manipulation/var/rcheckableType",
5 "./traversing", // filter
7 ], function( jQuery, rcheckableType ) {
12 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
13 rsubmittable = /^(?:input|select|textarea|keygen)/i;
15 function buildParams( prefix, obj, traditional, add ) {
18 if ( jQuery.isArray( obj ) ) {
20 // Serialize array item.
21 jQuery.each( obj, function( i, v ) {
22 if ( traditional || rbracket.test( prefix ) ) {
24 // Treat each array item as a scalar.
29 // Item is non-scalar (array or object), encode its numeric index.
31 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
39 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
41 // Serialize object item.
43 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
48 // Serialize scalar item.
53 // Serialize an array of form elements or a set of
54 // key/values into a query string
55 jQuery.param = function( a, traditional ) {
58 add = function( key, value ) {
60 // If value is a function, invoke it and return its value
61 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
62 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
65 // Set traditional to true for jQuery <= 1.3.2 behavior.
66 if ( traditional === undefined ) {
67 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
70 // If an array was passed in, assume that it is an array of form elements.
71 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
73 // Serialize the form elements
74 jQuery.each( a, function() {
75 add( this.name, this.value );
80 // If traditional, encode the "old" way (the way 1.3.2 or older
81 // did it), otherwise encode params recursively.
83 buildParams( prefix, a[ prefix ], traditional, add );
87 // Return the resulting serialization
88 return s.join( "&" ).replace( r20, "+" );
92 serialize: function() {
93 return jQuery.param( this.serializeArray() );
95 serializeArray: function() {
96 return this.map( function() {
98 // Can add propHook for "elements" to filter or add form elements
99 var elements = jQuery.prop( this, "elements" );
100 return elements ? jQuery.makeArray( elements ) : this;
102 .filter( function() {
103 var type = this.type;
105 // Use .is( ":disabled" ) so that fieldset[disabled] works
106 return this.name && !jQuery( this ).is( ":disabled" ) &&
107 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
108 ( this.checked || !rcheckableType.test( type ) );
110 .map( function( i, elem ) {
111 var val = jQuery( this ).val();
115 jQuery.isArray( val ) ?
116 jQuery.map( val, function( val ) {
117 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
119 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };