]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/space-pen/node_modules/jquery/src/serialize.js
0d6dfec6ddbba35af2292825cf8d08e27fe398f3
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
) ) {
19 // Serialize array item.
20 jQuery
.each( obj
, function( i
, v
) {
21 if ( traditional
|| rbracket
.test( prefix
) ) {
22 // Treat each array item as a scalar.
26 // Item is non-scalar (array or object), encode its numeric index.
27 buildParams( prefix
+ "[" + ( typeof v
=== "object" ? i : "" ) + "]", v
, traditional
, add
);
31 } else if ( !traditional
&& jQuery
.type( obj
) === "object" ) {
32 // Serialize object item.
34 buildParams( prefix
+ "[" + name
+ "]", obj
[ name
], traditional
, add
);
38 // Serialize scalar item.
43 // Serialize an array of form elements or a set of
44 // key/values into a query string
45 jQuery
.param = function( a
, traditional
) {
48 add = function( key
, value
) {
49 // If value is a function, invoke it and return its value
50 value
= jQuery
.isFunction( value
) ? value() : ( value
== null ? "" : value
);
51 s
[ s
.length
] = encodeURIComponent( key
) + "=" + encodeURIComponent( value
);
54 // Set traditional to true for jQuery <= 1.3.2 behavior.
55 if ( traditional
=== undefined ) {
56 traditional
= jQuery
.ajaxSettings
&& jQuery
.ajaxSettings
.traditional
;
59 // If an array was passed in, assume that it is an array of form elements.
60 if ( jQuery
.isArray( a
) || ( a
.jquery
&& !jQuery
.isPlainObject( a
) ) ) {
61 // Serialize the form elements
62 jQuery
.each( a
, function() {
63 add( this.name
, this.value
);
67 // If traditional, encode the "old" way (the way 1.3.2 or older
68 // did it), otherwise encode params recursively.
70 buildParams( prefix
, a
[ prefix
], traditional
, add
);
74 // Return the resulting serialization
75 return s
.join( "&" ).replace( r20
, "+" );
79 serialize: function() {
80 return jQuery
.param( this.serializeArray() );
82 serializeArray: function() {
83 return this.map(function() {
84 // Can add propHook for "elements" to filter or add form elements
85 var elements
= jQuery
.prop( this, "elements" );
86 return elements
? jQuery
.makeArray( elements
) : this;
91 // Use .is( ":disabled" ) so that fieldset[disabled] works
92 return this.name
&& !jQuery( this ).is( ":disabled" ) &&
93 rsubmittable
.test( this.nodeName
) && !rsubmitterTypes
.test( type
) &&
94 ( this.checked
|| !rcheckableType
.test( type
) );
96 .map(function( i
, elem
) {
97 var val
= jQuery( this ).val();
101 jQuery
.isArray( val
) ?
102 jQuery
.map( val
, function( val
) {
103 return { name: elem
.name
, value: val
.replace( rCRLF
, "\r\n" ) };
105 { name: elem
.name
, value: val
.replace( rCRLF
, "\r\n" ) };