-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
310 lines (265 loc) · 12.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Squirrel.js Documentation</title>
<!--Page Specific Metas-->
<meta name="description" content="Improve form usability with this tiny jQuery plugin"/>
<meta name="author" content="Squirrel.js"/>
<!--Mobile Specific Metas-->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!--Stylesheets-->
<link rel="stylesheet" href="example.css"/>
</head>
<body>
<div id="container">
<div class="header">
<div class="wrap">
<h1>Squirrel.js</h1>
<h3>Improve form usability with this tiny jQuery plugin that temporarily stores field values in HTML5 sessionStorage as users type.</h3>
</div>
</div>
<div class="block grey-lighter">
<div class="wrap">
<h2>A Quick Example</h2>
<p>
The example form below will store values in the form as you type or change them - so that if you refresh the page or navigate away and return, the things you entered will still be there. It clears when the user clears or submits the form,
otherwise it will last until the browser window is closed.
</p>
<form action="/" method="post" class="squirrel">
<div class="grid-row">
<div class="col4">
<p>
<strong>Example Text Field</strong><br/>
<input type="text" name="test-text" value="">
</p>
</div>
<div class="col4">
<p><strong>Example Number Field</strong><br/>
<input type="number" name="test-number" value=""></p>
</div>
<div class="col4">
<p>
<strong>Example Email Field</strong><br/>
<input type="email" name="test-email" value="">
</p>
</div>
</div>
<div class="grid-row">
<div class="col4">
<p>
<strong>Example Radio Buttons</strong><br/>
<input type="radio" name="test-radio" value="yes"> Yes <input type="radio" name="test-radio" value="no"> No
</p>
</div>
<div class="col4">
<p>
<strong>Example Range Field</strong><br/>
<input type="range" name="test-range" value="">
</p>
</div>
<div class="col4">
<p>
<strong>Example Color Field</strong><br/>
<input type="color" name="test-color" value="#000000">
</p>
</div>
</div>
<div class="grid-row">
<div class="col4">
<p>
<strong>Example Checkboxes</strong><br/>
<input type="checkbox" name="test-checkbox" value="yes"> Option 1 <input type="checkbox" name="test-checkbox" value="no"> Option 2
</p>
</div>
<div class="col4">
<p>
<strong>Example Select List</strong><br/>
<select name="test-select">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
</p>
</div>
<div class="col4">
<p>
<strong>Example Select Multiple List</strong><br/>
<select name="test-select-multiple" multiple>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
</p>
</div>
</div>
<div class="grid-row">
<div class="col6">
<p>
<strong>Example Date Field</strong><br/>
<input type="date" name="test-date" value="">
</p>
</div>
<div class="col6">
<p>
<strong>Example Datetime (Local) Field</strong><br/>
<input type="datetime-local" name="test-datetime-local" value="">
</p>
</div>
</div>
<div class="grid-row">
<div class="col4">
<p>
<strong>Example Month Field</strong><br/>
<input type="month" name="test-month" value="">
</p>
</div>
<div class="col4">
<p>
<strong>Example Week Field</strong><br/>
<input type="week" name="test-week" value="">
</p>
</div>
<div class="col4">
<p>
<strong>Example Time Field</strong><br/>
<input type="time" name="test-time" value="">
</p>
</div>
</div>
<div class="grid-row">
<div class="col6">
<p>
<strong>Example Search Field</strong><br/>
<input type="search" name="test-search" value="">
</p>
</div>
<div class="col6">
<p>
<strong>Example Tel Field</strong><br/>
<input type="tel" name="test-tel" value="">
</p>
</div>
</div>
<div class="grid-row">
<div class="col12">
<p>
<strong>Example URL Field</strong><br/>
<input type="url" name="test-url" value="">
</p>
</div>
</div>
<div class="grid-row">
<div class="col12">
<p>
<strong>Example Textarea</strong><br/>
<textarea name="test-textarea"></textarea>
</p>
</div>
</div>
<div class="grid-row">
<div class="col4">
<button type="reset">Reset Button</button>
</div>
<div class="col4">
<button type="button" id="start-stop">Stop Squirrel.js</button>
</div>
<div class="col4">
<button type="submit">Submit</button>
</div>
</div>
</form>
</div>
</div>
<div class="block grey-light">
<div class="wrap">
<h2>Documentation</h2>
<p>The code snippet below will get you where you need to go. Simply include jQuery, jquery.squirrel.min.js, and add a class of squirrel to your form.</p>
<script src="https://gist.github.com/jpederson/10656984.js"></script>
<p>For more information and advanced configuration options, head over to the <a href="https://github.com/jpederson/Squirrel.js/wiki">wiki</a> and look it up, or take the time while you're on Github to post an issue or request a feature!</p>
</div>
</div>
<a name="download"></a>
<div class="block grey">
<div class="wrap">
<h2>Download Squirrel.js</h2>
<p>Visit the project on Github for updates or just download the source and dig in!</p>
<p class="buttons"><a href="https://github.com/jpederson/Squirrel.js/" target="_blank" class="btn">Squirrel.js on Github</a> <a href="https://github.com/jpederson/Squirrel.js/archive/gh-pages.zip" target="_blank" class="btn gold">Download
Latest</a></p>
<div class="clear"></div>
</div>
</div>
<a name="author"></a>
<div class="block gold footer">
<div class="wrap">
<h2>About the Author</h2>
<div class="fifty">
<p>Built with care for <strong>free</strong> by me, <a href="https://jpederson.com" target="_blank">James Pederson</a>.</p>
<p>I'm a web developer and credit union advocate from Madison, WI. I'm also available for hire, <a href="https://jpederson.com/">get in touch</a> so we can discuss your project.</p>
</div>
<div class="fifty">
<p>Did my script help you? Buy me a beer to show me some love!</p>
<p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="BNAQJ6MC449RQ">
<input type="submit" name="submit" value="Donate" class="btn">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</p>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<!--Scripts-->
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="jquery.squirrel.min.js"></script>
<script>
$(function () {
// when the start/stop button is selected, start/stop squirrel on the form.
// this is using a namespace to distinguish between a standard click event.
// of course 'click' can be used on its own.
$('#start-stop').on('click.squirreljs.example', function () {
// cache the jQuery button object.
var $this = $(this);
// cache the form.
var $form = $('.squirrel');
// if stop is in the button text, then stop monitoring.
if ($this.text().search('Stop') !== -1) {
// pass the 'stop' action to squirrel.
$form.squirrel('stop');
// set the text of the button.
$this.text('Start Squirrel.js');
} else {
// start monitoring again.
$form.squirrel();
// set the text of the button.
$this.text('Stop Squirrel.js');
}
});
// when the form is submitted.
$('form').on('submit.squirrel.example', function (event) {
// prevent default submission of the form.
event.preventDefault();
// cache the form jQuery object.
var $this = $(this);
// display an alert. This would normally be a submission e.g. ajax.
window.alert('Form submitted. The form will now be reset and the session data cleared.');
// reset the form, by triggering a reset event.
$this.trigger('reset');
});
});
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-614793-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-614793-2');
</script>
</body>
</html>