0
|
1 //>>excludeStart("exclude", pragmas.exclude);
|
|
2 define([ "shoestring" ], function(){
|
|
3 //>>excludeEnd("exclude");
|
|
4
|
|
5 shoestring.inputTypes = [
|
|
6 "text",
|
|
7 "hidden",
|
|
8 "password",
|
|
9 "color",
|
|
10 "date",
|
|
11 "datetime",
|
|
12 // "datetime\-local" matched by datetime
|
|
13 "email",
|
|
14 "month",
|
|
15 "number",
|
|
16 "range",
|
|
17 "search",
|
|
18 "tel",
|
|
19 "time",
|
|
20 "url",
|
|
21 "week"
|
|
22 ];
|
|
23
|
|
24 shoestring.inputTypeTest = new RegExp( shoestring.inputTypes.join( "|" ) );
|
|
25
|
|
26
|
|
27 /**
|
|
28 * Serialize child input element values into an object.
|
|
29 *
|
|
30 * @return shoestring
|
|
31 * @this shoestring
|
|
32 */
|
|
33 shoestring.fn.serialize = function(){
|
|
34 var data = {};
|
|
35
|
|
36 shoestring( "input, select", this ).each(function(){
|
|
37 var type = this.type, name = this.name, value = this.value;
|
|
38
|
|
39 if( shoestring.inputTypeTest.test( type ) ||
|
|
40 ( type === "checkbox" || type === "radio" ) &&
|
|
41 this.checked ){
|
|
42
|
|
43 data[ name ] = value;
|
|
44 } else if( this.nodeName === "SELECT" ){
|
|
45 data[ name ] = this.options[ this.selectedIndex ].nodeValue;
|
|
46 }
|
|
47 });
|
|
48
|
|
49 return data;
|
|
50 };
|
|
51
|
|
52 //>>excludeStart("exclude", pragmas.exclude);
|
|
53 });
|
|
54 //>>excludeEnd("exclude");
|