|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
/*!
|
|
|
|
|
* jQuery Form Plugin
|
|
|
|
|
* version: 3.32.0-2013.04.09
|
|
|
|
|
* @requires jQuery v1.5 or later
|
|
|
|
|
* version: 3.49.0-2014.02.05
|
|
|
|
|
* Requires jQuery v1.5 or later
|
|
|
|
|
* Copyright (c) 2013 M. Alsup
|
|
|
|
|
* Examples and documentation at: http://malsup.com/jquery/form/
|
|
|
|
|
* Project repository: https://github.com/malsup/form
|
|
|
|
@ -9,7 +9,20 @@
|
|
|
|
|
* https://github.com/malsup/form#copyright-and-license
|
|
|
|
|
*/
|
|
|
|
|
/*global ActiveXObject */
|
|
|
|
|
;(function($) {
|
|
|
|
|
|
|
|
|
|
// AMD support
|
|
|
|
|
(function (factory) {
|
|
|
|
|
"use strict";
|
|
|
|
|
if (typeof define === 'function' && define.amd) {
|
|
|
|
|
// using AMD; register as anon module
|
|
|
|
|
define(['jquery'], factory);
|
|
|
|
|
} else {
|
|
|
|
|
// no AMD; invoke directly
|
|
|
|
|
factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(function($) {
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -59,15 +72,17 @@ feature.formdata = window.FormData !== undefined;
|
|
|
|
|
var hasProp = !!$.fn.prop;
|
|
|
|
|
|
|
|
|
|
// attr2 uses prop when it can but checks the return type for
|
|
|
|
|
// an expected string. this accounts for the case where a form
|
|
|
|
|
// an expected string. this accounts for the case where a form
|
|
|
|
|
// contains inputs with names like "action" or "method"; in those
|
|
|
|
|
// cases "prop" returns the element
|
|
|
|
|
$.fn.attr2 = function() {
|
|
|
|
|
if ( ! hasProp )
|
|
|
|
|
if ( ! hasProp ) {
|
|
|
|
|
return this.attr.apply(this, arguments);
|
|
|
|
|
}
|
|
|
|
|
var val = this.prop.apply(this, arguments);
|
|
|
|
|
if ( ( val && val.jquery ) || typeof val === 'string' )
|
|
|
|
|
if ( ( val && val.jquery ) || typeof val === 'string' ) {
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
return this.attr.apply(this, arguments);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -89,9 +104,12 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
if (typeof options == 'function') {
|
|
|
|
|
options = { success: options };
|
|
|
|
|
}
|
|
|
|
|
else if ( options === undefined ) {
|
|
|
|
|
options = {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
method = this.attr2('method');
|
|
|
|
|
action = this.attr2('action');
|
|
|
|
|
method = options.type || this.attr2('method');
|
|
|
|
|
action = options.url || this.attr2('action');
|
|
|
|
|
|
|
|
|
|
url = (typeof action === 'string') ? $.trim(action) : '';
|
|
|
|
|
url = url || window.location.href || '';
|
|
|
|
@ -103,7 +121,7 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
options = $.extend(true, {
|
|
|
|
|
url: url,
|
|
|
|
|
success: $.ajaxSettings.success,
|
|
|
|
|
type: method || 'GET',
|
|
|
|
|
type: method || $.ajaxSettings.type,
|
|
|
|
|
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
|
|
|
|
|
}, options);
|
|
|
|
|
|
|
|
|
@ -186,11 +204,27 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (options.error) {
|
|
|
|
|
var oldError = options.error;
|
|
|
|
|
options.error = function(xhr, status, error) {
|
|
|
|
|
var context = options.context || this;
|
|
|
|
|
oldError.apply(context, [xhr, status, error, $form]);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.complete) {
|
|
|
|
|
var oldComplete = options.complete;
|
|
|
|
|
options.complete = function(xhr, status) {
|
|
|
|
|
var context = options.context || this;
|
|
|
|
|
oldComplete.apply(context, [xhr, status, $form]);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// are there files to upload?
|
|
|
|
|
|
|
|
|
|
// [value] (issue #113), also see comment:
|
|
|
|
|
// https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219
|
|
|
|
|
var fileInputs = $('input[type=file]:enabled[value!=""]', this);
|
|
|
|
|
var fileInputs = $('input[type=file]:enabled', this).filter(function() { return $(this).val() !== ''; });
|
|
|
|
|
|
|
|
|
|
var hasFileInputs = fileInputs.length > 0;
|
|
|
|
|
var mp = 'multipart/form-data';
|
|
|
|
@ -226,8 +260,9 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
$form.removeData('jqxhr').data('jqxhr', jqxhr);
|
|
|
|
|
|
|
|
|
|
// clear element array
|
|
|
|
|
for (var k=0; k < elements.length; k++)
|
|
|
|
|
for (var k=0; k < elements.length; k++) {
|
|
|
|
|
elements[k] = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fire 'notify' event
|
|
|
|
|
this.trigger('form-submit-notify', [this, options]);
|
|
|
|
@ -235,7 +270,7 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
|
|
|
|
|
// utility fn for deep serialization
|
|
|
|
|
function deepSerialize(extraData){
|
|
|
|
|
var serialized = $.param(extraData).split('&');
|
|
|
|
|
var serialized = $.param(extraData, options.traditional).split('&');
|
|
|
|
|
var len = serialized.length;
|
|
|
|
|
var result = [];
|
|
|
|
|
var i, part;
|
|
|
|
@ -259,9 +294,11 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
|
|
|
|
|
if (options.extraData) {
|
|
|
|
|
var serializedData = deepSerialize(options.extraData);
|
|
|
|
|
for (i=0; i < serializedData.length; i++)
|
|
|
|
|
if (serializedData[i])
|
|
|
|
|
for (i=0; i < serializedData.length; i++) {
|
|
|
|
|
if (serializedData[i]) {
|
|
|
|
|
formdata.append(serializedData[i][0], serializedData[i][1]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
options.data = null;
|
|
|
|
@ -276,7 +313,7 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
if (options.uploadProgress) {
|
|
|
|
|
// workaround because jqXHR does not expose upload property
|
|
|
|
|
s.xhr = function() {
|
|
|
|
|
var xhr = jQuery.ajaxSettings.xhr();
|
|
|
|
|
var xhr = $.ajaxSettings.xhr();
|
|
|
|
|
if (xhr.upload) {
|
|
|
|
|
xhr.upload.addEventListener('progress', function(event) {
|
|
|
|
|
var percent = 0;
|
|
|
|
@ -293,11 +330,18 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s.data = null;
|
|
|
|
|
var beforeSend = s.beforeSend;
|
|
|
|
|
s.beforeSend = function(xhr, o) {
|
|
|
|
|
var beforeSend = s.beforeSend;
|
|
|
|
|
s.beforeSend = function(xhr, o) {
|
|
|
|
|
//Send FormData() provided by user
|
|
|
|
|
if (options.formData) {
|
|
|
|
|
o.data = options.formData;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
o.data = formdata;
|
|
|
|
|
if(beforeSend)
|
|
|
|
|
beforeSend.call(this, xhr, o);
|
|
|
|
|
}
|
|
|
|
|
if(beforeSend) {
|
|
|
|
|
beforeSend.call(this, xhr, o);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return $.ajax(s);
|
|
|
|
|
}
|
|
|
|
@ -307,14 +351,21 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
|
|
|
|
|
var deferred = $.Deferred();
|
|
|
|
|
|
|
|
|
|
// #341
|
|
|
|
|
deferred.abort = function(status) {
|
|
|
|
|
xhr.abort(status);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (a) {
|
|
|
|
|
// ensure that every serialized input is still enabled
|
|
|
|
|
for (i=0; i < elements.length; i++) {
|
|
|
|
|
el = $(elements[i]);
|
|
|
|
|
if ( hasProp )
|
|
|
|
|
if ( hasProp ) {
|
|
|
|
|
el.prop('disabled', false);
|
|
|
|
|
else
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
el.removeAttr('disabled');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -324,10 +375,12 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
if (s.iframeTarget) {
|
|
|
|
|
$io = $(s.iframeTarget);
|
|
|
|
|
n = $io.attr2('name');
|
|
|
|
|
if (!n)
|
|
|
|
|
$io.attr2('name', id);
|
|
|
|
|
else
|
|
|
|
|
if (!n) {
|
|
|
|
|
$io.attr2('name', id);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
id = n;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />');
|
|
|
|
@ -359,12 +412,15 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
|
|
|
|
|
$io.attr('src', s.iframeSrc); // abort op in progress
|
|
|
|
|
xhr.error = e;
|
|
|
|
|
if (s.error)
|
|
|
|
|
if (s.error) {
|
|
|
|
|
s.error.call(s.context, xhr, e, status);
|
|
|
|
|
if (g)
|
|
|
|
|
}
|
|
|
|
|
if (g) {
|
|
|
|
|
$.event.trigger("ajaxError", [xhr, s, e]);
|
|
|
|
|
if (s.complete)
|
|
|
|
|
}
|
|
|
|
|
if (s.complete) {
|
|
|
|
|
s.complete.call(s.context, xhr, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -405,7 +461,7 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
|
|
|
|
|
var CLIENT_TIMEOUT_ABORT = 1;
|
|
|
|
|
var SERVER_ABORT = 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getDoc(frame) {
|
|
|
|
|
/* it looks like contentWindow or contentDocument do not
|
|
|
|
|
* carry the protocol property in ie8, when running under ssl
|
|
|
|
@ -413,9 +469,9 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
* the protocol is know but not on the other two objects. strange?
|
|
|
|
|
* "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var doc = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// IE8 cascading access check
|
|
|
|
|
try {
|
|
|
|
|
if (frame.contentWindow) {
|
|
|
|
@ -451,11 +507,14 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
// take a breath so that pending repaints get some cpu time before the upload starts
|
|
|
|
|
function doSubmit() {
|
|
|
|
|
// make sure form attrs are set
|
|
|
|
|
var t = $form.attr2('target'), a = $form.attr2('action');
|
|
|
|
|
var t = $form.attr2('target'),
|
|
|
|
|
a = $form.attr2('action'),
|
|
|
|
|
mp = 'multipart/form-data',
|
|
|
|
|
et = $form.attr('enctype') || $form.attr('encoding') || mp;
|
|
|
|
|
|
|
|
|
|
// update form attrs in IE friendly way
|
|
|
|
|
form.setAttribute('target',id);
|
|
|
|
|
if (!method) {
|
|
|
|
|
if (!method || /post/i.test(method) ) {
|
|
|
|
|
form.setAttribute('method', 'POST');
|
|
|
|
|
}
|
|
|
|
|
if (a != s.url) {
|
|
|
|
@ -480,14 +539,16 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
try {
|
|
|
|
|
var state = getDoc(io).readyState;
|
|
|
|
|
log('state = ' + state);
|
|
|
|
|
if (state && state.toLowerCase() == 'uninitialized')
|
|
|
|
|
if (state && state.toLowerCase() == 'uninitialized') {
|
|
|
|
|
setTimeout(checkState,50);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
log('Server abort: ' , e, ' (', e.name, ')');
|
|
|
|
|
cb(SERVER_ABORT);
|
|
|
|
|
if (timeoutHandle)
|
|
|
|
|
if (timeoutHandle) {
|
|
|
|
|
clearTimeout(timeoutHandle);
|
|
|
|
|
}
|
|
|
|
|
timeoutHandle = undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -515,10 +576,12 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
if (!s.iframeTarget) {
|
|
|
|
|
// add iframe to doc and submit the form
|
|
|
|
|
$io.appendTo('body');
|
|
|
|
|
if (io.attachEvent)
|
|
|
|
|
io.attachEvent('onload', cb);
|
|
|
|
|
else
|
|
|
|
|
io.addEventListener('load', cb, false);
|
|
|
|
|
}
|
|
|
|
|
if (io.attachEvent) {
|
|
|
|
|
io.attachEvent('onload', cb);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
io.addEventListener('load', cb, false);
|
|
|
|
|
}
|
|
|
|
|
setTimeout(checkState,15);
|
|
|
|
|
|
|
|
|
@ -533,6 +596,7 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
finally {
|
|
|
|
|
// reset attrs and remove "extra" input elements
|
|
|
|
|
form.setAttribute('action',a);
|
|
|
|
|
form.setAttribute('enctype', et); // #380
|
|
|
|
|
if(t) {
|
|
|
|
|
form.setAttribute('target', t);
|
|
|
|
|
} else {
|
|
|
|
@ -555,7 +619,7 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
if (xhr.aborted || callbackProcessed) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
doc = getDoc(io);
|
|
|
|
|
if(!doc) {
|
|
|
|
|
log('cannot access response document');
|
|
|
|
@ -574,13 +638,16 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
|
|
|
|
|
if (!doc || doc.location.href == s.iframeSrc) {
|
|
|
|
|
// response not received yet
|
|
|
|
|
if (!timedOut)
|
|
|
|
|
if (!timedOut) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (io.detachEvent)
|
|
|
|
|
if (io.detachEvent) {
|
|
|
|
|
io.detachEvent('onload', cb);
|
|
|
|
|
else
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
io.removeEventListener('load', cb, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var status = 'success', errMsg;
|
|
|
|
|
try {
|
|
|
|
@ -607,11 +674,12 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
var docRoot = doc.body ? doc.body : doc.documentElement;
|
|
|
|
|
xhr.responseText = docRoot ? docRoot.innerHTML : null;
|
|
|
|
|
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
|
|
|
|
|
if (isXml)
|
|
|
|
|
if (isXml) {
|
|
|
|
|
s.dataType = 'xml';
|
|
|
|
|
}
|
|
|
|
|
xhr.getResponseHeader = function(header){
|
|
|
|
|
var headers = {'content-type': s.dataType};
|
|
|
|
|
return headers[header];
|
|
|
|
|
return headers[header.toLowerCase()];
|
|
|
|
|
};
|
|
|
|
|
// support for XHR 'status' & 'statusText' emulation :
|
|
|
|
|
if (docRoot) {
|
|
|
|
@ -671,40 +739,52 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
|
|
|
|
|
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
|
|
|
|
|
if (status === 'success') {
|
|
|
|
|
if (s.success)
|
|
|
|
|
if (s.success) {
|
|
|
|
|
s.success.call(s.context, data, 'success', xhr);
|
|
|
|
|
}
|
|
|
|
|
deferred.resolve(xhr.responseText, 'success', xhr);
|
|
|
|
|
if (g)
|
|
|
|
|
if (g) {
|
|
|
|
|
$.event.trigger("ajaxSuccess", [xhr, s]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (status) {
|
|
|
|
|
if (errMsg === undefined)
|
|
|
|
|
if (errMsg === undefined) {
|
|
|
|
|
errMsg = xhr.statusText;
|
|
|
|
|
if (s.error)
|
|
|
|
|
}
|
|
|
|
|
if (s.error) {
|
|
|
|
|
s.error.call(s.context, xhr, status, errMsg);
|
|
|
|
|
}
|
|
|
|
|
deferred.reject(xhr, 'error', errMsg);
|
|
|
|
|
if (g)
|
|
|
|
|
if (g) {
|
|
|
|
|
$.event.trigger("ajaxError", [xhr, s, errMsg]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (g)
|
|
|
|
|
if (g) {
|
|
|
|
|
$.event.trigger("ajaxComplete", [xhr, s]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (g && ! --$.active) {
|
|
|
|
|
$.event.trigger("ajaxStop");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (s.complete)
|
|
|
|
|
if (s.complete) {
|
|
|
|
|
s.complete.call(s.context, xhr, status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callbackProcessed = true;
|
|
|
|
|
if (s.timeout)
|
|
|
|
|
if (s.timeout) {
|
|
|
|
|
clearTimeout(timeoutHandle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// clean up
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
if (!s.iframeTarget)
|
|
|
|
|
if (!s.iframeTarget) {
|
|
|
|
|
$io.remove();
|
|
|
|
|
}
|
|
|
|
|
else { //adding else to clean up existing iframe response.
|
|
|
|
|
$io.attr('src', s.iframeSrc);
|
|
|
|
|
}
|
|
|
|
|
xhr.responseXML = null;
|
|
|
|
|
}, 100);
|
|
|
|
|
}
|
|
|
|
@ -732,8 +812,9 @@ $.fn.ajaxSubmit = function(options) {
|
|
|
|
|
data = xml ? xhr.responseXML : xhr.responseText;
|
|
|
|
|
|
|
|
|
|
if (xml && data.documentElement.nodeName === 'parsererror') {
|
|
|
|
|
if ($.error)
|
|
|
|
|
if ($.error) {
|
|
|
|
|
$.error('parsererror');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (s && s.dataFilter) {
|
|
|
|
|
data = s.dataFilter(data, type);
|
|
|
|
@ -806,7 +887,7 @@ function doAjaxSubmit(e) {
|
|
|
|
|
var options = e.data;
|
|
|
|
|
if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
$(this).ajaxSubmit(options);
|
|
|
|
|
$(e.target).ajaxSubmit(options); // #365
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -865,8 +946,23 @@ $.fn.formToArray = function(semantic, elements) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var form = this[0];
|
|
|
|
|
var formId = this.attr('id');
|
|
|
|
|
var els = semantic ? form.getElementsByTagName('*') : form.elements;
|
|
|
|
|
if (!els) {
|
|
|
|
|
var els2;
|
|
|
|
|
|
|
|
|
|
if (els && !/MSIE 8/.test(navigator.userAgent)) { // #390
|
|
|
|
|
els = $(els).get(); // convert to standard array
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// #386; account for inputs outside the form which use the 'form' attribute
|
|
|
|
|
if ( formId ) {
|
|
|
|
|
els2 = $(':input[form=' + formId + ']').get();
|
|
|
|
|
if ( els2.length ) {
|
|
|
|
|
els = (els || []).concat(els2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!els || !els.length) {
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -889,15 +985,17 @@ $.fn.formToArray = function(semantic, elements) {
|
|
|
|
|
|
|
|
|
|
v = $.fieldValue(el, true);
|
|
|
|
|
if (v && v.constructor == Array) {
|
|
|
|
|
if (elements)
|
|
|
|
|
if (elements) {
|
|
|
|
|
elements.push(el);
|
|
|
|
|
}
|
|
|
|
|
for(j=0, jmax=v.length; j < jmax; j++) {
|
|
|
|
|
a.push({name: n, value: v[j]});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (feature.fileapi && el.type == 'file') {
|
|
|
|
|
if (elements)
|
|
|
|
|
if (elements) {
|
|
|
|
|
elements.push(el);
|
|
|
|
|
}
|
|
|
|
|
var files = el.files;
|
|
|
|
|
if (files.length) {
|
|
|
|
|
for (j=0; j < files.length; j++) {
|
|
|
|
@ -910,8 +1008,9 @@ $.fn.formToArray = function(semantic, elements) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (v !== null && typeof v != 'undefined') {
|
|
|
|
|
if (elements)
|
|
|
|
|
if (elements) {
|
|
|
|
|
elements.push(el);
|
|
|
|
|
}
|
|
|
|
|
a.push({name: n, value: v, type: el.type, required: el.required});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1007,10 +1106,12 @@ $.fn.fieldValue = function(successful) {
|
|
|
|
|
if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (v.constructor == Array)
|
|
|
|
|
if (v.constructor == Array) {
|
|
|
|
|
$.merge(val, v);
|
|
|
|
|
else
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
val.push(v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return val;
|
|
|
|
|
};
|
|
|
|
@ -1044,7 +1145,7 @@ $.fieldValue = function(el, successful) {
|
|
|
|
|
if (op.selected) {
|
|
|
|
|
var v = op.value;
|
|
|
|
|
if (!v) { // extra pain for IE...
|
|
|
|
|
v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
|
|
|
|
|
v = (op.attributes && op.attributes.value && !(op.attributes.value.specified)) ? op.text : op.value;
|
|
|
|
|
}
|
|
|
|
|
if (one) {
|
|
|
|
|
return v;
|
|
|
|
@ -1087,21 +1188,22 @@ $.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
|
|
|
|
|
else if (tag == 'select') {
|
|
|
|
|
this.selectedIndex = -1;
|
|
|
|
|
}
|
|
|
|
|
else if (t == "file") {
|
|
|
|
|
if (/MSIE/.test(navigator.userAgent)) {
|
|
|
|
|
$(this).replaceWith($(this).clone(true));
|
|
|
|
|
} else {
|
|
|
|
|
$(this).val('');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (t == "file") {
|
|
|
|
|
if (/MSIE/.test(navigator.userAgent)) {
|
|
|
|
|
$(this).replaceWith($(this).clone(true));
|
|
|
|
|
} else {
|
|
|
|
|
$(this).val('');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (includeHidden) {
|
|
|
|
|
// includeHidden can be the value true, or it can be a selector string
|
|
|
|
|
// indicating a special test; for example:
|
|
|
|
|
// $('#myForm').clearForm('.special:hidden')
|
|
|
|
|
// the above would clean hidden inputs that have the class of 'special'
|
|
|
|
|
if ( (includeHidden === true && /hidden/.test(t)) ||
|
|
|
|
|
(typeof includeHidden == 'string' && $(this).is(includeHidden)) )
|
|
|
|
|
(typeof includeHidden == 'string' && $(this).is(includeHidden)) ) {
|
|
|
|
|
this.value = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
@ -1160,8 +1262,9 @@ $.fn.ajaxSubmit.debug = false;
|
|
|
|
|
|
|
|
|
|
// helper fn for console logging
|
|
|
|
|
function log() {
|
|
|
|
|
if (!$.fn.ajaxSubmit.debug)
|
|
|
|
|
if (!$.fn.ajaxSubmit.debug) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
|
|
|
|
|
if (window.console && window.console.log) {
|
|
|
|
|
window.console.log(msg);
|
|
|
|
@ -1171,4 +1274,4 @@ function log() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})(jQuery);
|
|
|
|
|
}));
|
|
|
|
|