Skip to content

Commit 73cc72c

Browse files
committed
Merge branch 'master' of git://github.com/malsup/form
2 parents 9a831c6 + a8043e2 commit 73cc72c

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

vendor/assets/javascripts/jquery.form.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* jQuery Form Plugin
3-
* version: 3.18 (28-SEP-2012)
3+
* version: 3.22 (1-DEC-2012)
44
* @requires jQuery v1.5 or later
55
*
66
* Examples and documentation at: http://malsup.com/jquery/form/
@@ -172,7 +172,11 @@ $.fn.ajaxSubmit = function(options) {
172172
};
173173

174174
// are there files to upload?
175-
var fileInputs = $('input:file:enabled[value]', this); // [value] (issue #113)
175+
176+
// [value] (issue #113), also see comment:
177+
// https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219
178+
var fileInputs = $('input[type=file]:enabled[value!=""]', this);
179+
176180
var hasFileInputs = fileInputs.length > 0;
177181
var mp = 'multipart/form-data';
178182
var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
@@ -221,6 +225,8 @@ $.fn.ajaxSubmit = function(options) {
221225
var result = {};
222226
var i, part;
223227
for (i=0; i < len; i++) {
228+
// #252; undo param space replacement
229+
serialized[i] = serialized[i].replace(/\+/g,' ');
224230
part = serialized[i].split('=');
225231
result[decodeURIComponent(part[0])] = decodeURIComponent(part[1]);
226232
}
@@ -286,7 +292,7 @@ $.fn.ajaxSubmit = function(options) {
286292
var useProp = !!$.fn.prop;
287293
var deferred = $.Deferred();
288294

289-
if ($(':input[name=submit],:input[id=submit]', form).length) {
295+
if ($('[name=submit],[id=submit]', form).length) {
290296
// if there is an input with a name or id of 'submit' then we won't be
291297
// able to invoke the submit fn on the form (at least not x-browser)
292298
alert('Error: Form elements must not have name or id of "submit".');
@@ -764,9 +770,9 @@ function captureSubmittingElement(e) {
764770
/*jshint validthis:true */
765771
var target = e.target;
766772
var $el = $(target);
767-
if (!($el.is(":submit,input:image"))) {
773+
if (!($el.is("[type=submit],[type=image]"))) {
768774
// is this a child element of the submit el? (ex: a span within a button)
769-
var t = $el.closest(':submit');
775+
var t = $el.closest('[type=submit]');
770776
if (t.length === 0) {
771777
return;
772778
}
@@ -924,19 +930,19 @@ $.fn.fieldSerialize = function(successful) {
924930
* <input name="C" type="radio" value="C2" />
925931
* </fieldset></form>
926932
*
927-
* var v = $(':text').fieldValue();
933+
* var v = $('input[type=text]').fieldValue();
928934
* // if no values are entered into the text inputs
929935
* v == ['','']
930936
* // if values entered into the text inputs are 'foo' and 'bar'
931937
* v == ['foo','bar']
932938
*
933-
* var v = $(':checkbox').fieldValue();
939+
* var v = $('input[type=checkbox]').fieldValue();
934940
* // if neither checkbox is checked
935941
* v === undefined
936942
* // if both checkboxes are checked
937943
* v == ['B1', 'B2']
938944
*
939-
* var v = $(':radio').fieldValue();
945+
* var v = $('input[type=radio]').fieldValue();
940946
* // if neither radio is checked
941947
* v === undefined
942948
* // if first radio is checked
@@ -1037,6 +1043,13 @@ $.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
10371043
else if (tag == 'select') {
10381044
this.selectedIndex = -1;
10391045
}
1046+
else if (t == "file") {
1047+
if ($.browser.msie) {
1048+
$(this).replaceWith($(this).clone());
1049+
} else {
1050+
$(this).val('');
1051+
}
1052+
}
10401053
else if (includeHidden) {
10411054
// includeHidden can be the value true, or it can be a selector string
10421055
// indicating a special test; for example:

0 commit comments

Comments
 (0)