Mercurial > nebulaweb3
comparison default/node_modules/shoestring/src/dom/serialize.js @ 0:1d038bc9b3d2 default tip
Up:default
author | Liny <dev@neowd.com> |
---|---|
date | Sat, 31 May 2025 09:21:51 +0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1d038bc9b3d2 |
---|---|
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"); |