-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
385 lines (318 loc) · 9.72 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jQuery Form Fill Plugin</title>
<link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.2.custom.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery.formFill.js"></script>
<style type="text/css">
a {
color: #EA9C00;
font: bold 10px verdana;
letter-spacing: .9px;
text-decoration: none;
}
a:hover {
color: #DC5;
font: bold 10px verdana;
letter-spacing: .9px;
text-decoration: underline;
}
div.description {
font: 10px verdana;
color: #555;
letter-spacing: .1px;
margin-bottom: 10px;
text-indent: 7px;
text-align: left;
width: 99%;
}
div#link {
font: 10px verdana;
color: #AB9927;
text-indent: 7px;
}
div.notice {
font: 9px verdana;
color: #777;
letter-spacing: .1px;
margin-bottom: 10px;
text-indent: 7px;
text-align: left;
width: 99%;
}
div.session {
font: bold 13px verdana;
border-bottom: 1px solid #EFEFEF;
color: #444;
letter-spacing: .7px;
margin-bottom: 10px;
margin-top: 24px;
text-align: left;
width: 99%;
}
div.sub-session {
font: bold 10px verdana;
border-bottom: 1px solid #EFEFEF;
color: #444;
letter-spacing: .7px;
margin-bottom: 10px;
margin-top: 24px;
text-align: left;
width: 99%;
}
div.source {
background: #F8F8FF;
border: 1px solid #EFEFEF;
border-left: 3px solid #CCC;
color: #444;
font: 12px monospace;
letter-spacing: .1px;
margin-bottom: 7px;
margin-top: 5px;
padding: 7px;
width: 99%;
}
div.titulo {
font: bold 17px verdana;
color: #269;
letter-spacing: .7px;
margin-bottom: 20px;
margin-top: 5px;
text-align: left;
width: 99%;
}
</style>
<script type="text/javascript">
$.fill.setDefaults({debug: true});
var user = {"name" : "Makoto Hashimoto",
"email" : "makoto@makoto.blog.br",
"phone" : {
"codeArea" : "+55",
"number" : "2755555555"
},
"date1": "03/30/1981",
"date2": "354769200000", // 1981-03-30 in milliseconds
"gender" : "M",
"admin" : "Y",
"rules" : [
{"id" : "1", "name": "Admin"},
{"id" : "3", "name": "Developer"}
]
};
$(function() {
$("#date1").datepicker({
dateFormat: 'mm/dd/yy',
changeMonth: true,
changeYear: true
});
$("#date2").datepicker({
dateFormat: 'mm/dd/yy',
changeMonth: true,
changeYear: true
});
$("#btnExample1").click(function() {
$("#form1").fill(user, {debug: true});
});
$("#date11").datepicker({
dateFormat: 'mm/dd/yy',
changeMonth: true,
changeYear: true
});
$("#date22").datepicker({
dateFormat: 'mm/dd/yy',
changeMonth: true,
changeYear: true
});
$("#btnExample2").click(function() {
$("#form2").fill(user, {styleElementName: 'none'});
});
});
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16009543-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div class="titulo">jQuery Form Fill Plugin</div>
<div id="link">
| <a href="http://github.com/makotovh/formFill/archives/master" target="_blank">Download</a> |
<a href="http://github.com/makotovh/formFill" target="_blank">Github</a> |
</div>
<div class="session">Overview</div>
<div id="fixed"></div>
<div class="description">
The"jQuery Form Fill" fills forms from JSON objects.
<ul>
<li>
Fills all kinds of html elements:
<ul>
<li>text</li>
<li>password</li>
<li>hidden</li>
<li>textarea</li>
<li>checkbox</li>
<li>radio</li>
<li>select</li>
</ul>
</li>
<li>
Fills fields with jQueryUI Datepicker.
<ul>
<li>Date in string format. Ex: "MM/DD/YYYY"</li>
<li>Date in milliseconds</li>
</ul>
</li>
</ul>
</div>
<div class="session">Quick Start Guide</div>
<div id="fixed"></div>
<div class="session">Using names of form elements with object syntax ("user.name"): </div>
<div id="fixed"></div>
<div id="divForm1" class="description">
<form id="form1">
<label>Nome:</label>
<input type="text" name="user.name" />
<br /><br />
<label>E-mail:</label>
<input type="text" name="user.email" />
<br /><br />
<label>Phone:</label>
<input type="text" name="user.phone.codeArea" size="3" maxlength="3" />
<input type="text" name="user.phone.number" size="11" maxlength="10" />
<br /><br />
<label>Date:</label>
<input type="text" name="user.date1" id="date1" /> from string (mm/dd/yyyy, mm-dd-yyyy, yyyy-mm-dd or yyyy/mm/dd)
<br /><br />
<label>Date 2:</label>
<input type="text" name="user.date2" id="date2"/> from milliseconds
<br /><br />
<label>Gender:</label>
<select name="user.gender">
<option>--select--</option>
<option value="F">Female</option>
<option value="M">Male</option>
</select>
<br /><br />
<label>Is Administrator?</label>
<!--input type="checkbox" name="user.admin" value="Y" -->
<input type="radio" name="user.admin" value="Y"> Yes
<input type="radio" name="user.admin" value="N"> No
<br /><br />
<label>Rules:</label>
<input type="checkbox" name="user.rules[0].id" value="1" /> Admin<br />
<input type="checkbox" name="user.rules[1].id" value="2" /> User<br />
<input type="checkbox" name="user.rules[2].id" value="3" /> Developer
<br /><br />
<input type="text" name="user.rules[0].name" /><br />
<input type="text" name="user.rules[1].name" /><br />
<input type="button" id="btnExample1" value="Fill" />
<input type="reset" value="Reset" />
</form>
</div>
<div class="source">
$("#form1").fill(user);
</div>
<div class="session">Using normal names of form elements: </div>
<div id="fixed"></div>
<div id="divForm2" class="description">
<form id="form2">
<label>Nome:</label>
<input type="text" name="name" />
<br /><br />
<label>E-mail:</label>
<input type="text" name="email" />
<br /><br />
<label>Date:</label>
<input type="text" name="date1" id="date11" /> from string (mm/dd/yyyy, mm-dd-yyyy, yyyy-mm-dd or yyyy/mm/dd)
<br /><br />
<label>Date 2:</label>
<input type="text" name="date2" id="date22"/> from milliseconds
<br /><br />
<label>Gender:</label>
<select name="gender">
<option>--select--</option>
<option value="F">Female</option>
<option value="M">Male</option>
</select>
<br /><br />
<input type="button" id="btnExample2" value="Fill" />
<input type="reset" value="Reset" />
</form>
</div>
<div class="source">
$("#form2").fill(user, {styleElementName:'none'});
</div>
<div class="sub-session">
JSON used:
</div>
<div class="source">
user = {<br />
"name" : "Makoto Hashimoto",<br />
"email" : "makoto@makoto.blog.br",<br />
"phone" : {<br />
"codeArea" : "+55",<br />
"number" : "2755555555"<br />
},<br />
"date1": "03/30/1981", // (mm/dd/yyyy)<br />
"date2": "354769200000", // 1981-03-30 in milliseconds<br />
"gender" : "M"<br />
"admin" : "Y",<br />
"rules" : [<br />
{"id" : "1", "name": "Admin"},<br />
{"id" : "3", "name": "Developer"}<br />
]<br />
};<br />
</div>
<div class="session">
Options:
</div>
<div class="sub-session">
styleElementName
</div>
<div class="description">
<ul>
<li><b>'object'</b> : When the names of form elements looks like objects 'user.name'. (Default)</li>
<li><b>'none'</b> : When the names of form elements are normal</li>
</ul>
</div>
<div class="sub-session">
dateFormat
</div>
<div class="description">
You can inform what date format come from json.
<br />
Examples:
<ul>
<li><b>'mm/dd/yy'</b> : USA date format (Default)</li>
<li><b>'dd/mm/yy'</b> : Brazilian date format</li>
</ul>
</div>
<div class="sub-session">
debug
</div>
<div class="description">
<ul>
<li><b>true</b> : Turn on the debug mode</li>
<li><b>false</b> : Turno off the debug mode (Default)</li>
</ul>
</div>
<div class="sub-session">
elementsExecuteEvents
</div>
<div class="description">
You can inform each element type you want execute the methods of events onclick or onchange.
<br />
Examples:
<ul>
<li><b>['checkbox', 'radio', 'select-one']</b> : Default</li>
</ul>
</div>
</html>