html5forms-rails 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -17,6 +17,13 @@ Components from the article [how-to-build-cross-browser-html5-forms](http://net.
17
17
 
18
18
  Even [webforms2](https://github.com/westonruter/webforms2) is now included and should work with html5Widgets to display native javascript widgets ;)
19
19
 
20
+ To enable Formdata for older browsers, the following libs are included:
21
+
22
+ * formdata.js
23
+ * jquery.form.js
24
+
25
+ See [html5-formdata](https://github.com/francois2metz/html5-formdata)
26
+
20
27
  ### Install
21
28
 
22
29
  Simply add to Gemfile and bundle:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "html5forms-rails"
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = "2012-08-27"
12
+ s.date = "2012-08-28"
13
13
  s.description = "Use the power of html5 forms even in old browsers using polyfills :)"
14
14
  s.email = "kmandrup@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -65,6 +65,8 @@ Gem::Specification.new do |s|
65
65
  "vendor/assets/images/html5forms/slider/slider.png",
66
66
  "vendor/assets/javascripts/colorpicker.js",
67
67
  "vendor/assets/javascripts/colorpicker.min.js",
68
+ "vendor/assets/javascripts/formdata.js",
69
+ "vendor/assets/javascripts/formdata.min.js",
68
70
  "vendor/assets/javascripts/h5f.js",
69
71
  "vendor/assets/javascripts/h5f.min.js",
70
72
  "vendor/assets/javascripts/html5forms.fallback.js",
@@ -89,6 +91,8 @@ Gem::Specification.new do |s|
89
91
  "vendor/assets/javascripts/html5forms/slider.min.js",
90
92
  "vendor/assets/javascripts/html5forms/timer.min.js",
91
93
  "vendor/assets/javascripts/html5forms/visibleIf.min.js",
94
+ "vendor/assets/javascripts/jquery.form.js",
95
+ "vendor/assets/javascripts/jquery.form.min.js",
92
96
  "vendor/assets/javascripts/jquery.html5form-shim.js",
93
97
  "vendor/assets/javascripts/jquery.html5form.min.js",
94
98
  "vendor/assets/javascripts/jquery.placehold.min.js",
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Emulate FormData for some browsers
3
+ * MIT License
4
+ * (c) 2010 François de Metz
5
+ */
6
+ (function(w) {
7
+ if (w.FormData)
8
+ return;
9
+ function FormData() {
10
+ this.fake = true;
11
+ this.boundary = "--------FormData" + Math.random();
12
+ this._fields = [];
13
+ }
14
+ FormData.prototype.append = function(key, value) {
15
+ this._fields.push([key, value]);
16
+ }
17
+ FormData.prototype.toString = function() {
18
+ var boundary = this.boundary;
19
+ var body = "";
20
+ this._fields.forEach(function(field) {
21
+ body += "--" + boundary + "\r\n";
22
+ // file upload
23
+ if (field[1].name) {
24
+ var file = field[1];
25
+ body += "Content-Disposition: form-data; name=\""+ field[0] +"\"; filename=\""+ file.name +"\"\r\n";
26
+ body += "Content-Type: "+ file.type +"\r\n\r\n";
27
+ body += file.getAsBinary() + "\r\n";
28
+ } else {
29
+ body += "Content-Disposition: form-data; name=\""+ field[0] +"\";\r\n\r\n";
30
+ body += field[1] + "\r\n";
31
+ }
32
+ });
33
+ body += "--" + boundary +"--";
34
+ return body;
35
+ }
36
+ w.FormData = FormData;
37
+ })(window);
@@ -0,0 +1 @@
1
+ (function(w){if(w.FormData)return;function FormData(){this.fake=true;this.boundary="--------FormData"+Math.random();this._fields=[]}FormData.prototype.append=function(key,value){this._fields.push([key,value])}FormData.prototype.toString=function(){var boundary=this.boundary;var body="";this._fields.forEach(function(field){body+="--"+boundary+"\r\n";if(field[1].name){var file=field[1];body+="Content-Disposition: form-data; name=\""+field[0]+"\"; filename=\""+file.name+"\"\r\n";body+="Content-Type: "+file.type+"\r\n\r\n";body+=file.getAsBinary()+"\r\n"}else{body+="Content-Disposition: form-data; name=\""+field[0]+"\";\r\n\r\n";body+=field[1]+"\r\n"}});body+="--"+boundary+"--";return body}w.FormData=FormData})(window);
@@ -0,0 +1,844 @@
1
+ /*!
2
+ * jQuery Form Plugin
3
+ * version: 2.52 (07-DEC-2010)
4
+ * @requires jQuery v1.3.2 or later
5
+ *
6
+ * Examples and documentation at: http://malsup.com/jquery/form/
7
+ * Dual licensed under the MIT and GPL licenses:
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ * http://www.gnu.org/licenses/gpl.html
10
+ */
11
+ ;(function($) {
12
+
13
+ /*
14
+ Usage Note:
15
+ -----------
16
+ Do not use both ajaxSubmit and ajaxForm on the same form. These
17
+ functions are intended to be exclusive. Use ajaxSubmit if you want
18
+ to bind your own submit handler to the form. For example,
19
+
20
+ $(document).ready(function() {
21
+ $('#myForm').bind('submit', function(e) {
22
+ e.preventDefault(); // <-- important
23
+ $(this).ajaxSubmit({
24
+ target: '#output'
25
+ });
26
+ });
27
+ });
28
+
29
+ Use ajaxForm when you want the plugin to manage all the event binding
30
+ for you. For example,
31
+
32
+ $(document).ready(function() {
33
+ $('#myForm').ajaxForm({
34
+ target: '#output'
35
+ });
36
+ });
37
+
38
+ When using ajaxForm, the ajaxSubmit function will be invoked for you
39
+ at the appropriate time.
40
+ */
41
+
42
+ /**
43
+ * ajaxSubmit() provides a mechanism for immediately submitting
44
+ * an HTML form using AJAX.
45
+ */
46
+ $.fn.ajaxSubmit = function(options) {
47
+ // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
48
+ if (!this.length) {
49
+ log('ajaxSubmit: skipping submit process - no element selected');
50
+ return this;
51
+ }
52
+
53
+ if (typeof options == 'function') {
54
+ options = { success: options };
55
+ }
56
+
57
+ var action = this.attr('action');
58
+ var url = (typeof action === 'string') ? $.trim(action) : '';
59
+ if (url) {
60
+ // clean url (don't include hash vaue)
61
+ url = (url.match(/^([^#]+)/)||[])[1];
62
+ }
63
+ url = url || window.location.href || '';
64
+
65
+ options = $.extend(true, {
66
+ url: url,
67
+ type: this.attr('method') || 'GET',
68
+ iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
69
+ }, options);
70
+
71
+ // hook for manipulating the form data before it is extracted;
72
+ // convenient for use with rich editors like tinyMCE or FCKEditor
73
+ var veto = {};
74
+ this.trigger('form-pre-serialize', [this, options, veto]);
75
+ if (veto.veto) {
76
+ log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
77
+ return this;
78
+ }
79
+
80
+ // provide opportunity to alter form data before it is serialized
81
+ if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
82
+ log('ajaxSubmit: submit aborted via beforeSerialize callback');
83
+ return this;
84
+ }
85
+
86
+ var n,v,a = this.formToArray(options.semantic);
87
+ if (options.data) {
88
+ options.extraData = options.data;
89
+ for (n in options.data) {
90
+ if(options.data[n] instanceof Array) {
91
+ for (var k in options.data[n]) {
92
+ a.push( { name: n, value: options.data[n][k] } );
93
+ }
94
+ }
95
+ else {
96
+ v = options.data[n];
97
+ v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
98
+ a.push( { name: n, value: v } );
99
+ }
100
+ }
101
+ }
102
+
103
+ // give pre-submit callback an opportunity to abort the submit
104
+ if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
105
+ log('ajaxSubmit: submit aborted via beforeSubmit callback');
106
+ return this;
107
+ }
108
+
109
+ // fire vetoable 'validate' event
110
+ this.trigger('form-submit-validate', [a, this, options, veto]);
111
+ if (veto.veto) {
112
+ log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
113
+ return this;
114
+ }
115
+
116
+ var q = $.param(a);
117
+
118
+ if (options.type.toUpperCase() == 'GET') {
119
+ options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
120
+ options.data = null; // data is null for 'get'
121
+ }
122
+ else {
123
+ options.data = q; // data is the query string for 'post'
124
+ }
125
+
126
+ var $form = this, callbacks = [];
127
+ if (options.resetForm) {
128
+ callbacks.push(function() { $form.resetForm(); });
129
+ }
130
+ if (options.clearForm) {
131
+ callbacks.push(function() { $form.clearForm(); });
132
+ }
133
+
134
+ // perform a load on the target only if dataType is not provided
135
+ if (!options.dataType && options.target) {
136
+ var oldSuccess = options.success || function(){};
137
+ callbacks.push(function(data) {
138
+ var fn = options.replaceTarget ? 'replaceWith' : 'html';
139
+ $(options.target)[fn](data).each(oldSuccess, arguments);
140
+ });
141
+ }
142
+ else if (options.success) {
143
+ callbacks.push(options.success);
144
+ }
145
+
146
+ options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
147
+ var context = options.context || options; // jQuery 1.4+ supports scope context
148
+ for (var i=0, max=callbacks.length; i < max; i++) {
149
+ callbacks[i].apply(context, [data, status, xhr || $form, $form]);
150
+ }
151
+ };
152
+
153
+ // are there files to upload?
154
+ var fileInputs = $('input:file', this).length > 0;
155
+ var mp = 'multipart/form-data';
156
+ var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
157
+ var fileAPI = !!(fileInputs && $('input:file', this).get(0).files && window.FormData);
158
+ log("fileAPI :" + fileAPI);
159
+ var shouldUseFrame = (fileInputs || multipart) && !fileAPI;
160
+
161
+ // options.iframe allows user to force iframe mode
162
+ // 06-NOV-09: now defaulting to iframe mode if file input is detected
163
+ if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
164
+ // hack to fix Safari hang (thanks to Tim Molendijk for this)
165
+ // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
166
+ if (options.closeKeepAlive) {
167
+ $.get(options.closeKeepAlive, fileUploadIframe);
168
+ }
169
+ else {
170
+ fileUploadIframe();
171
+ }
172
+ }
173
+ else if ((fileInputs || multipart) && fileAPI) {
174
+ options.progress = options.progress || $.noop();
175
+ fileUploadXhr();
176
+ }
177
+ else {
178
+ $.ajax(options);
179
+ }
180
+
181
+ // fire 'notify' event
182
+ this.trigger('form-submit-notify', [this, options]);
183
+ return this;
184
+
185
+
186
+ // private function for handling file uploads in iframe (hat tip to YAHOO!)
187
+ function fileUploadIframe() {
188
+ var form = $form[0];
189
+
190
+ if ($(':input[name=submit],:input[id=submit]', form).length) {
191
+ // if there is an input with a name or id of 'submit' then we won't be
192
+ // able to invoke the submit fn on the form (at least not x-browser)
193
+ alert('Error: Form elements must not have name or id of "submit".');
194
+ return;
195
+ }
196
+
197
+ var s = $.extend(true, {}, $.ajaxSettings, options);
198
+ s.context = s.context || s;
199
+ var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
200
+ window[fn] = function() {
201
+ var f = $io.data('form-plugin-onload');
202
+ if (f) {
203
+ f();
204
+ window[fn] = undefined;
205
+ try { delete window[fn]; } catch(e){}
206
+ }
207
+ }
208
+ var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ s.iframeSrc +'" onload="window[\'_\'+this.id]()" />');
209
+ var io = $io[0];
210
+
211
+ $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
212
+
213
+ var xhr = { // mock object
214
+ aborted: 0,
215
+ responseText: null,
216
+ responseXML: null,
217
+ status: 0,
218
+ statusText: 'n/a',
219
+ getAllResponseHeaders: function() {},
220
+ getResponseHeader: function() {},
221
+ setRequestHeader: function() {},
222
+ abort: function() {
223
+ this.aborted = 1;
224
+ $io.attr('src', s.iframeSrc); // abort op in progress
225
+ }
226
+ };
227
+
228
+ var g = s.global;
229
+ // trigger ajax global events so that activity/block indicators work like normal
230
+ if (g && ! $.active++) {
231
+ $.event.trigger("ajaxStart");
232
+ }
233
+ if (g) {
234
+ $.event.trigger("ajaxSend", [xhr, s]);
235
+ }
236
+
237
+ if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
238
+ if (s.global) {
239
+ $.active--;
240
+ }
241
+ return;
242
+ }
243
+ if (xhr.aborted) {
244
+ return;
245
+ }
246
+
247
+ var cbInvoked = false;
248
+ var timedOut = 0;
249
+
250
+ // add submitting element to data if we know it
251
+ var sub = form.clk;
252
+ if (sub) {
253
+ var n = sub.name;
254
+ if (n && !sub.disabled) {
255
+ s.extraData = s.extraData || {};
256
+ s.extraData[n] = sub.value;
257
+ if (sub.type == "image") {
258
+ s.extraData[n+'.x'] = form.clk_x;
259
+ s.extraData[n+'.y'] = form.clk_y;
260
+ }
261
+ }
262
+ }
263
+
264
+ // take a breath so that pending repaints get some cpu time before the upload starts
265
+ function doSubmit() {
266
+ // make sure form attrs are set
267
+ var t = $form.attr('target'), a = $form.attr('action');
268
+
269
+ // update form attrs in IE friendly way
270
+ form.setAttribute('target',id);
271
+ if (form.getAttribute('method') != 'POST') {
272
+ form.setAttribute('method', 'POST');
273
+ }
274
+ if (form.getAttribute('action') != s.url) {
275
+ form.setAttribute('action', s.url);
276
+ }
277
+
278
+ // ie borks in some cases when setting encoding
279
+ if (! s.skipEncodingOverride) {
280
+ $form.attr({
281
+ encoding: 'multipart/form-data',
282
+ enctype: 'multipart/form-data'
283
+ });
284
+ }
285
+
286
+ // support timout
287
+ if (s.timeout) {
288
+ setTimeout(function() { timedOut = true; cb(); }, s.timeout);
289
+ }
290
+
291
+ // add "extra" data to form if provided in options
292
+ var extraInputs = [];
293
+ try {
294
+ if (s.extraData) {
295
+ for (var n in s.extraData) {
296
+ extraInputs.push(
297
+ $('<input type="hidden" name="'+n+'" value="'+s.extraData[n]+'" />')
298
+ .appendTo(form)[0]);
299
+ }
300
+ }
301
+
302
+ // add iframe to doc and submit the form
303
+ $io.appendTo('body');
304
+ $io.data('form-plugin-onload', cb);
305
+ form.submit();
306
+ }
307
+ finally {
308
+ // reset attrs and remove "extra" input elements
309
+ form.setAttribute('action',a);
310
+ if(t) {
311
+ form.setAttribute('target', t);
312
+ } else {
313
+ $form.removeAttr('target');
314
+ }
315
+ $(extraInputs).remove();
316
+ }
317
+ }
318
+
319
+ if (s.forceSync) {
320
+ doSubmit();
321
+ }
322
+ else {
323
+ setTimeout(doSubmit, 10); // this lets dom updates render
324
+ }
325
+
326
+ var data, doc, domCheckCount = 50;
327
+
328
+ function cb() {
329
+ if (cbInvoked) {
330
+ return;
331
+ }
332
+
333
+ $io.removeData('form-plugin-onload');
334
+
335
+ var ok = true;
336
+ try {
337
+ if (timedOut) {
338
+ throw 'timeout';
339
+ }
340
+ // extract the server response from the iframe
341
+ doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
342
+
343
+ var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
344
+ log('isXml='+isXml);
345
+ if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
346
+ if (--domCheckCount) {
347
+ // in some browsers (Opera) the iframe DOM is not always traversable when
348
+ // the onload callback fires, so we loop a bit to accommodate
349
+ log('requeing onLoad callback, DOM not available');
350
+ setTimeout(cb, 250);
351
+ return;
352
+ }
353
+ // let this fall through because server response could be an empty document
354
+ //log('Could not access iframe DOM after mutiple tries.');
355
+ //throw 'DOMException: not available';
356
+ }
357
+
358
+ //log('response detected');
359
+ cbInvoked = true;
360
+ xhr.responseText = doc.documentElement ? doc.documentElement.innerHTML : null;
361
+ xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
362
+ xhr.getResponseHeader = function(header){
363
+ var headers = {'content-type': s.dataType};
364
+ return headers[header];
365
+ };
366
+
367
+ var scr = /(json|script)/.test(s.dataType);
368
+ if (scr || s.textarea) {
369
+ // see if user embedded response in textarea
370
+ var ta = doc.getElementsByTagName('textarea')[0];
371
+ if (ta) {
372
+ xhr.responseText = ta.value;
373
+ }
374
+ else if (scr) {
375
+ // account for browsers injecting pre around json response
376
+ var pre = doc.getElementsByTagName('pre')[0];
377
+ var b = doc.getElementsByTagName('body')[0];
378
+ if (pre) {
379
+ xhr.responseText = pre.textContent;
380
+ }
381
+ else if (b) {
382
+ xhr.responseText = b.innerHTML;
383
+ }
384
+ }
385
+ }
386
+ else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
387
+ xhr.responseXML = toXml(xhr.responseText);
388
+ }
389
+ data = $.httpData(xhr, s.dataType);
390
+ }
391
+ catch(e){
392
+ log('error caught:',e);
393
+ ok = false;
394
+ xhr.error = e;
395
+ $.handleError(s, xhr, 'error', e);
396
+ }
397
+
398
+ if (xhr.aborted) {
399
+ log('upload aborted');
400
+ ok = false;
401
+ }
402
+
403
+ // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
404
+ if (ok) {
405
+ s.success.call(s.context, data, 'success', xhr);
406
+ if (g) {
407
+ $.event.trigger("ajaxSuccess", [xhr, s]);
408
+ }
409
+ }
410
+ if (g) {
411
+ $.event.trigger("ajaxComplete", [xhr, s]);
412
+ }
413
+ if (g && ! --$.active) {
414
+ $.event.trigger("ajaxStop");
415
+ }
416
+ if (s.complete) {
417
+ s.complete.call(s.context, xhr, ok ? 'success' : 'error');
418
+ }
419
+
420
+ // clean up
421
+ setTimeout(function() {
422
+ $io.removeData('form-plugin-onload');
423
+ $io.remove();
424
+ xhr.responseXML = null;
425
+ }, 100);
426
+ }
427
+
428
+ function toXml(s, doc) {
429
+ if (window.ActiveXObject) {
430
+ doc = new ActiveXObject('Microsoft.XMLDOM');
431
+ doc.async = 'false';
432
+ doc.loadXML(s);
433
+ }
434
+ else {
435
+ doc = (new DOMParser()).parseFromString(s, 'text/xml');
436
+ }
437
+ return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
438
+ }
439
+ }
440
+
441
+ // private function for handling file uploads with xmlhttprequest (hat type to jquery-sexypost)
442
+ function fileUploadXhr() {
443
+ // this function will POST the contents of the selected form via XmlHttpRequest.
444
+
445
+ var data = new FormData();
446
+ $("input:text, input:hidden, input:password, textarea", $form).each(function(){
447
+ data.append($(this).attr("name"), $(this).val());
448
+ });
449
+
450
+ $("input:file", $form).each(function(){
451
+ var files = this.files;
452
+ for (i=0; i<files.length; i++) data.append($(this).attr("name"), files[i]);
453
+ });
454
+
455
+ $("select option:selected", $form).each(function(){
456
+ data.append($(this).parent().attr("name"), $(this).val());
457
+ });
458
+
459
+ $("input:checked", $form).each(function(){
460
+ data.append($(this).attr("name"), $(this).val());
461
+ });
462
+ options.data = null;
463
+ var originalBeforeSend = options.beforeSend;
464
+ _options = options;
465
+ options.beforeSend = function(xhr, options) { // et toc !
466
+ options.data = data;
467
+ xhr.upload.onprogress = function(event) {
468
+ _options.progress(event.position, event.total);
469
+ }
470
+ /**
471
+ * You can use https://github.com/francois2metz/html5-formdata for a fake FormData object
472
+ * Only work with Firefox 3.6
473
+ */
474
+ if (data.fake) {
475
+ xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary="+ data.boundary);
476
+ // with fake FormData object, we must use sendAsBinary
477
+ xhr.send = function(data) {
478
+ xhr.sendAsBinary(data.toString());
479
+ }
480
+ }
481
+ if (originalBeforeSend) originalBeforeSend(xhr, options);
482
+ }
483
+ $.ajax(options);
484
+ }
485
+
486
+ };
487
+
488
+ /**
489
+ * ajaxForm() provides a mechanism for fully automating form submission.
490
+ *
491
+ * The advantages of using this method instead of ajaxSubmit() are:
492
+ *
493
+ * 1: This method will include coordinates for <input type="image" /> elements (if the element
494
+ * is used to submit the form).
495
+ * 2. This method will include the submit element's name/value data (for the element that was
496
+ * used to submit the form).
497
+ * 3. This method binds the submit() method to the form for you.
498
+ *
499
+ * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
500
+ * passes the options argument along after properly binding events for submit elements and
501
+ * the form itself.
502
+ */
503
+ $.fn.ajaxForm = function(options) {
504
+ // in jQuery 1.3+ we can fix mistakes with the ready state
505
+ if (this.length === 0) {
506
+ var o = { s: this.selector, c: this.context };
507
+ if (!$.isReady && o.s) {
508
+ log('DOM not ready, queuing ajaxForm');
509
+ $(function() {
510
+ $(o.s,o.c).ajaxForm(options);
511
+ });
512
+ return this;
513
+ }
514
+ // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
515
+ log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
516
+ return this;
517
+ }
518
+
519
+ return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
520
+ if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
521
+ e.preventDefault();
522
+ $(this).ajaxSubmit(options);
523
+ }
524
+ }).bind('click.form-plugin', function(e) {
525
+ var target = e.target;
526
+ var $el = $(target);
527
+ if (!($el.is(":submit,input:image"))) {
528
+ // is this a child element of the submit el? (ex: a span within a button)
529
+ var t = $el.closest(':submit');
530
+ if (t.length == 0) {
531
+ return;
532
+ }
533
+ target = t[0];
534
+ }
535
+ var form = this;
536
+ form.clk = target;
537
+ if (target.type == 'image') {
538
+ if (e.offsetX != undefined) {
539
+ form.clk_x = e.offsetX;
540
+ form.clk_y = e.offsetY;
541
+ } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
542
+ var offset = $el.offset();
543
+ form.clk_x = e.pageX - offset.left;
544
+ form.clk_y = e.pageY - offset.top;
545
+ } else {
546
+ form.clk_x = e.pageX - target.offsetLeft;
547
+ form.clk_y = e.pageY - target.offsetTop;
548
+ }
549
+ }
550
+ // clear form vars
551
+ setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
552
+ });
553
+ };
554
+
555
+ // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
556
+ $.fn.ajaxFormUnbind = function() {
557
+ return this.unbind('submit.form-plugin click.form-plugin');
558
+ };
559
+
560
+ /**
561
+ * formToArray() gathers form element data into an array of objects that can
562
+ * be passed to any of the following ajax functions: $.get, $.post, or load.
563
+ * Each object in the array has both a 'name' and 'value' property. An example of
564
+ * an array for a simple login form might be:
565
+ *
566
+ * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
567
+ *
568
+ * It is this array that is passed to pre-submit callback functions provided to the
569
+ * ajaxSubmit() and ajaxForm() methods.
570
+ */
571
+ $.fn.formToArray = function(semantic) {
572
+ var a = [];
573
+ if (this.length === 0) {
574
+ return a;
575
+ }
576
+
577
+ var form = this[0];
578
+ var els = semantic ? form.getElementsByTagName('*') : form.elements;
579
+ if (!els) {
580
+ return a;
581
+ }
582
+
583
+ var i,j,n,v,el,max,jmax;
584
+ for(i=0, max=els.length; i < max; i++) {
585
+ el = els[i];
586
+ n = el.name;
587
+ if (!n) {
588
+ continue;
589
+ }
590
+
591
+ if (semantic && form.clk && el.type == "image") {
592
+ // handle image inputs on the fly when semantic == true
593
+ if(!el.disabled && form.clk == el) {
594
+ a.push({name: n, value: $(el).val()});
595
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
596
+ }
597
+ continue;
598
+ }
599
+
600
+ v = $.fieldValue(el, true);
601
+ if (v && v.constructor == Array) {
602
+ for(j=0, jmax=v.length; j < jmax; j++) {
603
+ a.push({name: n, value: v[j]});
604
+ }
605
+ }
606
+ else if (v !== null && typeof v != 'undefined') {
607
+ a.push({name: n, value: v});
608
+ }
609
+ }
610
+
611
+ if (!semantic && form.clk) {
612
+ // input type=='image' are not found in elements array! handle it here
613
+ var $input = $(form.clk), input = $input[0];
614
+ n = input.name;
615
+ if (n && !input.disabled && input.type == 'image') {
616
+ a.push({name: n, value: $input.val()});
617
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
618
+ }
619
+ }
620
+ return a;
621
+ };
622
+
623
+ /**
624
+ * Serializes form data into a 'submittable' string. This method will return a string
625
+ * in the format: name1=value1&amp;name2=value2
626
+ */
627
+ $.fn.formSerialize = function(semantic) {
628
+ //hand off to jQuery.param for proper encoding
629
+ return $.param(this.formToArray(semantic));
630
+ };
631
+
632
+ /**
633
+ * Serializes all field elements in the jQuery object into a query string.
634
+ * This method will return a string in the format: name1=value1&amp;name2=value2
635
+ */
636
+ $.fn.fieldSerialize = function(successful) {
637
+ var a = [];
638
+ this.each(function() {
639
+ var n = this.name;
640
+ if (!n) {
641
+ return;
642
+ }
643
+ var v = $.fieldValue(this, successful);
644
+ if (v && v.constructor == Array) {
645
+ for (var i=0,max=v.length; i < max; i++) {
646
+ a.push({name: n, value: v[i]});
647
+ }
648
+ }
649
+ else if (v !== null && typeof v != 'undefined') {
650
+ a.push({name: this.name, value: v});
651
+ }
652
+ });
653
+ //hand off to jQuery.param for proper encoding
654
+ return $.param(a);
655
+ };
656
+
657
+ /**
658
+ * Returns the value(s) of the element in the matched set. For example, consider the following form:
659
+ *
660
+ * <form><fieldset>
661
+ * <input name="A" type="text" />
662
+ * <input name="A" type="text" />
663
+ * <input name="B" type="checkbox" value="B1" />
664
+ * <input name="B" type="checkbox" value="B2"/>
665
+ * <input name="C" type="radio" value="C1" />
666
+ * <input name="C" type="radio" value="C2" />
667
+ * </fieldset></form>
668
+ *
669
+ * var v = $(':text').fieldValue();
670
+ * // if no values are entered into the text inputs
671
+ * v == ['','']
672
+ * // if values entered into the text inputs are 'foo' and 'bar'
673
+ * v == ['foo','bar']
674
+ *
675
+ * var v = $(':checkbox').fieldValue();
676
+ * // if neither checkbox is checked
677
+ * v === undefined
678
+ * // if both checkboxes are checked
679
+ * v == ['B1', 'B2']
680
+ *
681
+ * var v = $(':radio').fieldValue();
682
+ * // if neither radio is checked
683
+ * v === undefined
684
+ * // if first radio is checked
685
+ * v == ['C1']
686
+ *
687
+ * The successful argument controls whether or not the field element must be 'successful'
688
+ * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
689
+ * The default value of the successful argument is true. If this value is false the value(s)
690
+ * for each element is returned.
691
+ *
692
+ * Note: This method *always* returns an array. If no valid value can be determined the
693
+ * array will be empty, otherwise it will contain one or more values.
694
+ */
695
+ $.fn.fieldValue = function(successful) {
696
+ for (var val=[], i=0, max=this.length; i < max; i++) {
697
+ var el = this[i];
698
+ var v = $.fieldValue(el, successful);
699
+ if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
700
+ continue;
701
+ }
702
+ v.constructor == Array ? $.merge(val, v) : val.push(v);
703
+ }
704
+ return val;
705
+ };
706
+
707
+ /**
708
+ * Returns the value of the field element.
709
+ */
710
+ $.fieldValue = function(el, successful) {
711
+ var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
712
+ if (successful === undefined) {
713
+ successful = true;
714
+ }
715
+
716
+ if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
717
+ (t == 'checkbox' || t == 'radio') && !el.checked ||
718
+ (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
719
+ tag == 'select' && el.selectedIndex == -1)) {
720
+ return null;
721
+ }
722
+
723
+ if (tag == 'select') {
724
+ var index = el.selectedIndex;
725
+ if (index < 0) {
726
+ return null;
727
+ }
728
+ var a = [], ops = el.options;
729
+ var one = (t == 'select-one');
730
+ var max = (one ? index+1 : ops.length);
731
+ for(var i=(one ? index : 0); i < max; i++) {
732
+ var op = ops[i];
733
+ if (op.selected) {
734
+ var v = op.value;
735
+ if (!v) { // extra pain for IE...
736
+ v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
737
+ }
738
+ if (one) {
739
+ return v;
740
+ }
741
+ a.push(v);
742
+ }
743
+ }
744
+ return a;
745
+ }
746
+ return $(el).val();
747
+ };
748
+
749
+ /**
750
+ * Clears the form data. Takes the following actions on the form's input fields:
751
+ * - input text fields will have their 'value' property set to the empty string
752
+ * - select elements will have their 'selectedIndex' property set to -1
753
+ * - checkbox and radio inputs will have their 'checked' property set to false
754
+ * - inputs of type submit, button, reset, and hidden will *not* be effected
755
+ * - button elements will *not* be effected
756
+ */
757
+ $.fn.clearForm = function() {
758
+ return this.each(function() {
759
+ $('input,select,textarea', this).clearFields();
760
+ });
761
+ };
762
+
763
+ /**
764
+ * Clears the selected form elements.
765
+ */
766
+ $.fn.clearFields = $.fn.clearInputs = function() {
767
+ return this.each(function() {
768
+ var t = this.type, tag = this.tagName.toLowerCase();
769
+ if (t == 'text' || t == 'password' || tag == 'textarea') {
770
+ this.value = '';
771
+ }
772
+ else if (t == 'checkbox' || t == 'radio') {
773
+ this.checked = false;
774
+ }
775
+ else if (tag == 'select') {
776
+ this.selectedIndex = -1;
777
+ }
778
+ });
779
+ };
780
+
781
+ /**
782
+ * Resets the form data. Causes all form elements to be reset to their original value.
783
+ */
784
+ $.fn.resetForm = function() {
785
+ return this.each(function() {
786
+ // guard against an input with the name of 'reset'
787
+ // note that IE reports the reset function as an 'object'
788
+ if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
789
+ this.reset();
790
+ }
791
+ });
792
+ };
793
+
794
+ /**
795
+ * Enables or disables any matching elements.
796
+ */
797
+ $.fn.enable = function(b) {
798
+ if (b === undefined) {
799
+ b = true;
800
+ }
801
+ return this.each(function() {
802
+ this.disabled = !b;
803
+ });
804
+ };
805
+
806
+ /**
807
+ * Checks/unchecks any matching checkboxes or radio buttons and
808
+ * selects/deselects and matching option elements.
809
+ */
810
+ $.fn.selected = function(select) {
811
+ if (select === undefined) {
812
+ select = true;
813
+ }
814
+ return this.each(function() {
815
+ var t = this.type;
816
+ if (t == 'checkbox' || t == 'radio') {
817
+ this.checked = select;
818
+ }
819
+ else if (this.tagName.toLowerCase() == 'option') {
820
+ var $sel = $(this).parent('select');
821
+ if (select && $sel[0] && $sel[0].type == 'select-one') {
822
+ // deselect all other options
823
+ $sel.find('option').selected(false);
824
+ }
825
+ this.selected = select;
826
+ }
827
+ });
828
+ };
829
+
830
+ // helper fn for console logging
831
+ // set $.fn.ajaxSubmit.debug to true to enable debug logging
832
+ function log() {
833
+ if ($.fn.ajaxSubmit.debug) {
834
+ var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
835
+ if (window.console && window.console.log) {
836
+ window.console.log(msg);
837
+ }
838
+ else if (window.opera && window.opera.postError) {
839
+ window.opera.postError(msg);
840
+ }
841
+ }
842
+ };
843
+
844
+ })(jQuery);
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * jQuery Form Plugin
3
+ * version: 2.52 (07-DEC-2010)
4
+ * @requires jQuery v1.3.2 or later
5
+ *
6
+ * Examples and documentation at: http://malsup.com/jquery/form/
7
+ * Dual licensed under the MIT and GPL licenses:
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ * http://www.gnu.org/licenses/gpl.html
10
+ */
11
+ ;(function($){$.fn.ajaxSubmit=function(options){if(!this.length){log('ajaxSubmit: skipping submit process - no element selected');return this}if(typeof options=='function'){options={success:options}}var action=this.attr('action');var url=(typeof action==='string')?$.trim(action):'';if(url){url=(url.match(/^([^#]+)/)||[])[1]}url=url||window.location.href||'';options=$.extend(true,{url:url,type:this.attr('method')||'GET',iframeSrc:/^https/i.test(window.location.href||'')?'javascript:false':'about:blank'},options);var veto={};this.trigger('form-pre-serialize',[this,options,veto]);if(veto.veto){log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');return this}if(options.beforeSerialize&&options.beforeSerialize(this,options)===false){log('ajaxSubmit: submit aborted via beforeSerialize callback');return this}var n,v,a=this.formToArray(options.semantic);if(options.data){options.extraData=options.data;for(n in options.data){if(options.data[n]instanceof Array){for(var k in options.data[n]){a.push({name:n,value:options.data[n][k]})}}else{v=options.data[n];v=$.isFunction(v)?v():v;a.push({name:n,value:v})}}}if(options.beforeSubmit&&options.beforeSubmit(a,this,options)===false){log('ajaxSubmit: submit aborted via beforeSubmit callback');return this}this.trigger('form-submit-validate',[a,this,options,veto]);if(veto.veto){log('ajaxSubmit: submit vetoed via form-submit-validate trigger');return this}var q=$.param(a);if(options.type.toUpperCase()=='GET'){options.url+=(options.url.indexOf('?')>=0?'&':'?')+q;options.data=null}else{options.data=q}var $form=this,callbacks=[];if(options.resetForm){callbacks.push(function(){$form.resetForm()})}if(options.clearForm){callbacks.push(function(){$form.clearForm()})}if(!options.dataType&&options.target){var oldSuccess=options.success||function(){};callbacks.push(function(data){var fn=options.replaceTarget?'replaceWith':'html';$(options.target)[fn](data).each(oldSuccess,arguments)})}else if(options.success){callbacks.push(options.success)}options.success=function(data,status,xhr){var context=options.context||options;for(var i=0,max=callbacks.length;i<max;i++){callbacks[i].apply(context,[data,status,xhr||$form,$form])}};var fileInputs=$('input:file',this).length>0;var mp='multipart/form-data';var multipart=($form.attr('enctype')==mp||$form.attr('encoding')==mp);var fileAPI=!!(fileInputs&&$('input:file',this).get(0).files&&window.FormData);log("fileAPI :"+fileAPI);var shouldUseFrame=(fileInputs||multipart)&&!fileAPI;if(options.iframe!==false&&(options.iframe||shouldUseFrame)){if(options.closeKeepAlive){$.get(options.closeKeepAlive,fileUploadIframe)}else{fileUploadIframe()}}else if((fileInputs||multipart)&&fileAPI){options.progress=options.progress||$.noop();fileUploadXhr()}else{$.ajax(options)}this.trigger('form-submit-notify',[this,options]);return this;function fileUploadIframe(){var form=$form[0];if($(':input[name=submit],:input[id=submit]',form).length){alert('Error: Form elements must not have name or id of "submit".');return}var s=$.extend(true,{},$.ajaxSettings,options);s.context=s.context||s;var id='jqFormIO'+(new Date().getTime()),fn='_'+id;window[fn]=function(){var f=$io.data('form-plugin-onload');if(f){f();window[fn]=undefined;try{delete window[fn]}catch(e){}}}var $io=$('<iframe id="'+id+'" name="'+id+'" src="'+s.iframeSrc+'" onload="window[\'_\'+this.id]()" />');var io=$io[0];$io.css({position:'absolute',top:'-1000px',left:'-1000px'});var xhr={aborted:0,responseText:null,responseXML:null,status:0,statusText:'n/a',getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;$io.attr('src',s.iframeSrc)}};var g=s.global;if(g&&!$.active++){$.event.trigger("ajaxStart")}if(g){$.event.trigger("ajaxSend",[xhr,s])}if(s.beforeSend&&s.beforeSend.call(s.context,xhr,s)===false){if(s.global){$.active--}return}if(xhr.aborted){return}var cbInvoked=false;var timedOut=0;var sub=form.clk;if(sub){var n=sub.name;if(n&&!sub.disabled){s.extraData=s.extraData||{};s.extraData[n]=sub.value;if(sub.type=="image"){s.extraData[n+'.x']=form.clk_x;s.extraData[n+'.y']=form.clk_y}}}function doSubmit(){var t=$form.attr('target'),a=$form.attr('action');form.setAttribute('target',id);if(form.getAttribute('method')!='POST'){form.setAttribute('method','POST')}if(form.getAttribute('action')!=s.url){form.setAttribute('action',s.url)}if(!s.skipEncodingOverride){$form.attr({encoding:'multipart/form-data',enctype:'multipart/form-data'})}if(s.timeout){setTimeout(function(){timedOut=true;cb()},s.timeout)}var extraInputs=[];try{if(s.extraData){for(var n in s.extraData){extraInputs.push($('<input type="hidden" name="'+n+'" value="'+s.extraData[n]+'" />').appendTo(form)[0])}}$io.appendTo('body');$io.data('form-plugin-onload',cb);form.submit()}finally{form.setAttribute('action',a);if(t){form.setAttribute('target',t)}else{$form.removeAttr('target')}$(extraInputs).remove()}}if(s.forceSync){doSubmit()}else{setTimeout(doSubmit,10)}var data,doc,domCheckCount=50;function cb(){if(cbInvoked){return}$io.removeData('form-plugin-onload');var ok=true;try{if(timedOut){throw'timeout'}doc=io.contentWindow?io.contentWindow.document:io.contentDocument?io.contentDocument:io.document;var isXml=s.dataType=='xml'||doc.XMLDocument||$.isXMLDoc(doc);log('isXml='+isXml);if(!isXml&&window.opera&&(doc.body==null||doc.body.innerHTML=='')){if(--domCheckCount){log('requeing onLoad callback, DOM not available');setTimeout(cb,250);return}}cbInvoked=true;xhr.responseText=doc.documentElement?doc.documentElement.innerHTML:null;xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc;xhr.getResponseHeader=function(header){var headers={'content-type':s.dataType};return headers[header]};var scr=/(json|script)/.test(s.dataType);if(scr||s.textarea){var ta=doc.getElementsByTagName('textarea')[0];if(ta){xhr.responseText=ta.value}else if(scr){var pre=doc.getElementsByTagName('pre')[0];var b=doc.getElementsByTagName('body')[0];if(pre){xhr.responseText=pre.textContent}else if(b){xhr.responseText=b.innerHTML}}}else if(s.dataType=='xml'&&!xhr.responseXML&&xhr.responseText!=null){xhr.responseXML=toXml(xhr.responseText)}data=$.httpData(xhr,s.dataType)}catch(e){log('error caught:',e);ok=false;xhr.error=e;$.handleError(s,xhr,'error',e)}if(xhr.aborted){log('upload aborted');ok=false}if(ok){s.success.call(s.context,data,'success',xhr);if(g){$.event.trigger("ajaxSuccess",[xhr,s])}}if(g){$.event.trigger("ajaxComplete",[xhr,s])}if(g&&!--$.active){$.event.trigger("ajaxStop")}if(s.complete){s.complete.call(s.context,xhr,ok?'success':'error')}setTimeout(function(){$io.removeData('form-plugin-onload');$io.remove();xhr.responseXML=null},100)}function toXml(s,doc){if(window.ActiveXObject){doc=new ActiveXObject('Microsoft.XMLDOM');doc.async='false';doc.loadXML(s)}else{doc=(new DOMParser()).parseFromString(s,'text/xml')}return(doc&&doc.documentElement&&doc.documentElement.tagName!='parsererror')?doc:null}}function fileUploadXhr(){var data=new FormData();$("input:text, input:hidden, input:password, textarea",$form).each(function(){data.append($(this).attr("name"),$(this).val())});$("input:file",$form).each(function(){var files=this.files;for(i=0;i<files.length;i++)data.append($(this).attr("name"),files[i])});$("select option:selected",$form).each(function(){data.append($(this).parent().attr("name"),$(this).val())});$("input:checked",$form).each(function(){data.append($(this).attr("name"),$(this).val())});options.data=null;var originalBeforeSend=options.beforeSend;_options=options;options.beforeSend=function(xhr,options){options.data=data;xhr.upload.onprogress=function(event){_options.progress(event.position,event.total)}if(data.fake){xhr.setRequestHeader("Content-Type","multipart/form-data; boundary="+data.boundary);xhr.send=function(data){xhr.sendAsBinary(data.toString())}}if(originalBeforeSend)originalBeforeSend(xhr,options)}$.ajax(options)}};$.fn.ajaxForm=function(options){if(this.length===0){var o={s:this.selector,c:this.context};if(!$.isReady&&o.s){log('DOM not ready, queuing ajaxForm');$(function(){$(o.s,o.c).ajaxForm(options)});return this}log('terminating; zero elements found by selector'+($.isReady?'':' (DOM not ready)'));return this}return this.ajaxFormUnbind().bind('submit.form-plugin',function(e){if(!e.isDefaultPrevented()){e.preventDefault();$(this).ajaxSubmit(options)}}).bind('click.form-plugin',function(e){var target=e.target;var $el=$(target);if(!($el.is(":submit,input:image"))){var t=$el.closest(':submit');if(t.length==0){return}target=t[0]}var form=this;form.clk=target;if(target.type=='image'){if(e.offsetX!=undefined){form.clk_x=e.offsetX;form.clk_y=e.offsetY}else if(typeof $.fn.offset=='function'){var offset=$el.offset();form.clk_x=e.pageX-offset.left;form.clk_y=e.pageY-offset.top}else{form.clk_x=e.pageX-target.offsetLeft;form.clk_y=e.pageY-target.offsetTop}}setTimeout(function(){form.clk=form.clk_x=form.clk_y=null},100)})};$.fn.ajaxFormUnbind=function(){return this.unbind('submit.form-plugin click.form-plugin')};$.fn.formToArray=function(semantic){var a=[];if(this.length===0){return a}var form=this[0];var els=semantic?form.getElementsByTagName('*'):form.elements;if(!els){return a}var i,j,n,v,el,max,jmax;for(i=0,max=els.length;i<max;i++){el=els[i];n=el.name;if(!n){continue}if(semantic&&form.clk&&el.type=="image"){if(!el.disabled&&form.clk==el){a.push({name:n,value:$(el).val()});a.push({name:n+'.x',value:form.clk_x},{name:n+'.y',value:form.clk_y})}continue}v=$.fieldValue(el,true);if(v&&v.constructor==Array){for(j=0,jmax=v.length;j<jmax;j++){a.push({name:n,value:v[j]})}}else if(v!==null&&typeof v!='undefined'){a.push({name:n,value:v})}}if(!semantic&&form.clk){var $input=$(form.clk),input=$input[0];n=input.name;if(n&&!input.disabled&&input.type=='image'){a.push({name:n,value:$input.val()});a.push({name:n+'.x',value:form.clk_x},{name:n+'.y',value:form.clk_y})}}return a};$.fn.formSerialize=function(semantic){return $.param(this.formToArray(semantic))};$.fn.fieldSerialize=function(successful){var a=[];this.each(function(){var n=this.name;if(!n){return}var v=$.fieldValue(this,successful);if(v&&v.constructor==Array){for(var i=0,max=v.length;i<max;i++){a.push({name:n,value:v[i]})}}else if(v!==null&&typeof v!='undefined'){a.push({name:this.name,value:v})}});return $.param(a)};$.fn.fieldValue=function(successful){for(var val=[],i=0,max=this.length;i<max;i++){var el=this[i];var v=$.fieldValue(el,successful);if(v===null||typeof v=='undefined'||(v.constructor==Array&&!v.length)){continue}v.constructor==Array?$.merge(val,v):val.push(v)}return val};$.fieldValue=function(el,successful){var n=el.name,t=el.type,tag=el.tagName.toLowerCase();if(successful===undefined){successful=true}if(successful&&(!n||el.disabled||t=='reset'||t=='button'||(t=='checkbox'||t=='radio')&&!el.checked||(t=='submit'||t=='image')&&el.form&&el.form.clk!=el||tag=='select'&&el.selectedIndex==-1)){return null}if(tag=='select'){var index=el.selectedIndex;if(index<0){return null}var a=[],ops=el.options;var one=(t=='select-one');var max=(one?index+1:ops.length);for(var i=(one?index:0);i<max;i++){var op=ops[i];if(op.selected){var v=op.value;if(!v){v=(op.attributes&&op.attributes['value']&&!(op.attributes['value'].specified))?op.text:op.value}if(one){return v}a.push(v)}}return a}return $(el).val()};$.fn.clearForm=function(){return this.each(function(){$('input,select,textarea',this).clearFields()})};$.fn.clearFields=$.fn.clearInputs=function(){return this.each(function(){var t=this.type,tag=this.tagName.toLowerCase();if(t=='text'||t=='password'||tag=='textarea'){this.value=''}else if(t=='checkbox'||t=='radio'){this.checked=false}else if(tag=='select'){this.selectedIndex=-1}})};$.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=='function'||(typeof this.reset=='object'&&!this.reset.nodeType)){this.reset()}})};$.fn.enable=function(b){if(b===undefined){b=true}return this.each(function(){this.disabled=!b})};$.fn.selected=function(select){if(select===undefined){select=true}return this.each(function(){var t=this.type;if(t=='checkbox'||t=='radio'){this.checked=select}else if(this.tagName.toLowerCase()=='option'){var $sel=$(this).parent('select');if(select&&$sel[0]&&$sel[0].type=='select-one'){$sel.find('option').selected(false)}this.selected=select}})};function log(){if($.fn.ajaxSubmit.debug){var msg='[jquery.form] '+Array.prototype.join.call(arguments,'');if(window.console&&window.console.log){window.console.log(msg)}else if(window.opera&&window.opera.postError){window.opera.postError(msg)}}}})(jQuery);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html5forms-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-27 00:00:00.000000000 Z
12
+ date: 2012-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -147,6 +147,8 @@ files:
147
147
  - vendor/assets/images/html5forms/slider/slider.png
148
148
  - vendor/assets/javascripts/colorpicker.js
149
149
  - vendor/assets/javascripts/colorpicker.min.js
150
+ - vendor/assets/javascripts/formdata.js
151
+ - vendor/assets/javascripts/formdata.min.js
150
152
  - vendor/assets/javascripts/h5f.js
151
153
  - vendor/assets/javascripts/h5f.min.js
152
154
  - vendor/assets/javascripts/html5forms.fallback.js
@@ -171,6 +173,8 @@ files:
171
173
  - vendor/assets/javascripts/html5forms/slider.min.js
172
174
  - vendor/assets/javascripts/html5forms/timer.min.js
173
175
  - vendor/assets/javascripts/html5forms/visibleIf.min.js
176
+ - vendor/assets/javascripts/jquery.form.js
177
+ - vendor/assets/javascripts/jquery.form.min.js
174
178
  - vendor/assets/javascripts/jquery.html5form-shim.js
175
179
  - vendor/assets/javascripts/jquery.html5form.min.js
176
180
  - vendor/assets/javascripts/jquery.placehold.min.js
@@ -205,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
209
  version: '0'
206
210
  segments:
207
211
  - 0
208
- hash: 156499816781596132
212
+ hash: 97740047234551011
209
213
  required_rubygems_version: !ruby/object:Gem::Requirement
210
214
  none: false
211
215
  requirements: