From: Mikael Nordfeldth Date: Fri, 6 Mar 2015 23:55:17 +0000 (+0100) Subject: jQuery Form Plugin updated X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a6c03e31274d530a96663c50c53e2e95a1264f11;p=quix0rs-gnu-social.git jQuery Form Plugin updated Source: http://malsup.com/jquery/form/ --- diff --git a/js/extlib/jquery.form.js b/js/extlib/jquery.form.js index be691bb4a6..591ad6f1fe 100644 --- a/js/extlib/jquery.form.js +++ b/js/extlib/jquery.form.js @@ -1,15 +1,28 @@ /*! * jQuery Form Plugin - * version: 3.43.0-2013.09.03 + * version: 3.51.0-2014.06.20 * Requires jQuery v1.5 or later - * Copyright (c) 2013 M. Alsup + * Copyright (c) 2014 M. Alsup * Examples and documentation at: http://malsup.com/jquery/form/ * Project repository: https://github.com/malsup/form * Dual licensed under the MIT and GPL licenses. * 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"; /* @@ -63,11 +76,13 @@ var hasProp = !!$.fn.prop; // 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); }; @@ -209,7 +224,7 @@ $.fn.ajaxSubmit = function(options) { // [value] (issue #113), also see comment: // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219 - var fileInputs = $('input[type=file]:enabled', this).filter(function() { return $(this).val() != ''; }); + var fileInputs = $('input[type=file]:enabled', this).filter(function() { return $(this).val() !== ''; }); var hasFileInputs = fileInputs.length > 0; var mp = 'multipart/form-data'; @@ -245,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]); @@ -278,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; @@ -312,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); } @@ -335,10 +360,12 @@ $.fn.ajaxSubmit = function(options) { // 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'); + } } } @@ -348,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 = $('