From 42da3c143b0fb0401dfb1b280b5f23226bb2c201 Mon Sep 17 00:00:00 2001 From: Brendan Byrd Date: Sun, 8 Apr 2012 19:51:25 -0300 Subject: [PATCH 001/178] Improve resetForm to work on individual elements and non-FORM tags --- jquery.form.js | 56 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index c337dbfe..b799ee76 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -1002,15 +1002,61 @@ $.fn.clearFields = $.fn.clearInputs = function(includeHidden) { }); }; + /** - * Resets the form data. Causes all form elements to be reset to their original value. + * Resets the form data or individual elements. Takes the following actions + * on the selected tags: + * - all fields within form elements will be reset to their original value + * - input / textarea / select fields will be reset to their original value + * - option / optgroup fields (for multi-selects) will defaulted individually + * - non-multiple options will find the right select to default + * - label elements will be searched against its 'for' attribute + * - all others will be searched for appropriate children to default */ $.fn.resetForm = function() { return this.each(function() { - // guard against an input with the name of 'reset' - // note that IE reports the reset function as an 'object' - if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) { - this.reset(); + var el = $(this); + var tag = this.tagName.toLowerCase(); + switch (tag) { + case 'input': + this.checked = this.defaultChecked; + // fall-through + case 'textarea': + this.value = this.defaultValue; + return true; + case 'option': + case 'optgroup': + var select = el.parents('select'); + if (select.length && select[0].multiple) { + if (tag == 'option') this.selected = this.defaultSelected; + else el.find('option').resetForm(); + } + else select.resetForm(); + return true; + case 'select': + el.find('option').each(function(i) { + this.selected = this.defaultSelected; + if (this.defaultSelected && !el[0].multiple) { + el[0].selectedIndex = i; + return false; + } + }); + return true; + case 'label': + var forEl = $(el.attr('for')); + var list = el.find('input,select,textarea'); + if (forEl[0]) list.unshift( forEl[0] ); + list.resetForm(); + return true; + case 'form': + // guard against an input with the name of 'reset' + // note that IE reports the reset function as an 'object' + if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) + this.reset(); + return true; + default: + el.find('form,input,label,select,textarea').resetForm(); + return true; } }); }; From 3fe23f55b9481d5feac453f461d1629b3eff33c0 Mon Sep 17 00:00:00 2001 From: Loic Jaures Date: Sun, 12 Aug 2012 22:01:17 +0200 Subject: [PATCH 002/178] add a filtering option Filtering is a function used to filter form elements --- README.md | 12 +++++++++++- jquery.form.js | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 242baa7f..3ff0d176 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,16 @@ beforeSubmit: function(arr, $form, options) { } ```` +###filtering +Callback function invoked before processing fiels. This provides a way to filter elements. +````javascript +filtering: function(el, index) { + if ( !$(el).hasClass('ignore') ) { + return el; + } +} +```` + ###clearForm Boolean flag indicating whether the form should be cleared if the submit is successful @@ -179,7 +189,7 @@ The jQuery Form plugin is dual licensed under the MIT and GPL licenses: * [MIT](http://malsup.github.com/mit-license.txt) * [GPL](http://malsup.github.com/gpl-license-v2.txt) -You may use either license. The MIT License is recommended for most projects because it is simple and easy to understand and it places almost no restrictions on what you can do with the plugin. +You may use either license. The MIT License is recommended for most projects because it is simple and easy to understand and it places almost no restrictions on what you can do with the plugin. If the GPL suits your project better you are also free to use the plugin under that license. diff --git a/jquery.form.js b/jquery.form.js index 13e9a55c..40b05114 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -113,7 +113,7 @@ $.fn.ajaxSubmit = function(options) { } var elements = []; - var qx, a = this.formToArray(options.semantic, elements); + var qx, a = this.formToArray(options.semantic, elements, options.filtering); if (options.data) { options.extraData = options.data; qx = $.param(options.data, traditional); @@ -780,7 +780,7 @@ $.fn.ajaxFormUnbind = function() { * It is this array that is passed to pre-submit callback functions provided to the * ajaxSubmit() and ajaxForm() methods. */ -$.fn.formToArray = function(semantic, elements) { +$.fn.formToArray = function(semantic, elements, filtering) { var a = []; if (this.length === 0) { return a; @@ -791,6 +791,10 @@ $.fn.formToArray = function(semantic, elements) { if (!els) { return a; } + + if ($.isFunction(filtering)) { + var els = $.map(els, filtering); + } var i,j,n,v,el,max,jmax; for(i=0, max=els.length; i < max; i++) { From 10676ff5fbec4f2dccebd53b40b73c3c59d9eee6 Mon Sep 17 00:00:00 2001 From: Francisco Ruiz Date: Thu, 20 Dec 2012 15:32:57 +0000 Subject: [PATCH 003/178] Added support for functions in 'data' option for ajaxForm and ajaxSubmit. --- jquery.form.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index aedd6491..fd7aa72c 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -115,8 +115,14 @@ $.fn.ajaxSubmit = function(options) { var elements = []; var qx, a = this.formToArray(options.semantic, elements); if (options.data) { - options.extraData = options.data; - qx = $.param(options.data, traditional); + var extraData; + if ($.isFunction(options.data)) { + extraData = options.data(a); + } else { + extraData = options.data; + } + options.extraData = extraData; + qx = $.param(extraData, traditional); } // give pre-submit callback an opportunity to abort the submit From cb6d50a08c8d46bd4db134c9dd8e79328f00c3fe Mon Sep 17 00:00:00 2001 From: Euan Goddard Date: Tue, 8 Jan 2013 15:55:32 +0000 Subject: [PATCH 004/178] Fixed incorrect serialization of extraData --- jquery.form.js | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index fd7aa72c..a1ce2b43 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -115,14 +115,9 @@ $.fn.ajaxSubmit = function(options) { var elements = []; var qx, a = this.formToArray(options.semantic, elements); if (options.data) { - var extraData; - if ($.isFunction(options.data)) { - extraData = options.data(a); - } else { - extraData = options.data; - } - options.extraData = extraData; - qx = $.param(extraData, traditional); + var optionsData = $.isFunction(options.data) ? options.data(a) : options.data; + options.extraData = optionsData; + qx = $.param(optionsData, traditional); } // give pre-submit callback an opportunity to abort the submit @@ -224,22 +219,7 @@ $.fn.ajaxSubmit = function(options) { this.trigger('form-submit-notify', [this, options]); return this; - // utility fn for deep serialization - function deepSerialize(extraData){ - var serialized = $.param(extraData).split('&'); - var len = serialized.length; - var result = {}; - var i, part; - for (i=0; i < len; i++) { - // #252; undo param space replacement - serialized[i] = serialized[i].replace(/\+/g,' '); - part = serialized[i].split('='); - result[decodeURIComponent(part[0])] = decodeURIComponent(part[1]); - } - return result; - } - - // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) + // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) function fileUploadXhr(a) { var formdata = new FormData(); @@ -248,10 +228,9 @@ $.fn.ajaxSubmit = function(options) { } if (options.extraData) { - var serializedData = deepSerialize(options.extraData); - for (var p in serializedData) - if (serializedData.hasOwnProperty(p)) - formdata.append(p, serializedData[p]); + $.each(options.extraData, function (key, value) { + formdata.append(key, value); + }); } options.data = null; From 97cd97b2faebfa5223fbe2af77783d3d1683dbca Mon Sep 17 00:00:00 2001 From: Francisco Ruiz Date: Mon, 4 Feb 2013 17:35:02 +0000 Subject: [PATCH 005/178] Reverted customizations for file uploading. --- jquery.form.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index a1ce2b43..8c88a6ec 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -219,6 +219,19 @@ $.fn.ajaxSubmit = function(options) { this.trigger('form-submit-notify', [this, options]); return this; + // utility fn for deep serialization + function deepSerialize(extraData){ + var serialized = $.param(extraData).split('&'); + var len = serialized.length; + var result = {}; + var i, part; + for (i=0; i < len; i++) { + part = serialized[i].split('='); + result[decodeURIComponent(part[0])] = decodeURIComponent(part[1]); + } + return result; + } + // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) function fileUploadXhr(a) { var formdata = new FormData(); @@ -228,9 +241,10 @@ $.fn.ajaxSubmit = function(options) { } if (options.extraData) { - $.each(options.extraData, function (key, value) { - formdata.append(key, value); - }); + var serializedData = deepSerialize(options.extraData); + for (var p in serializedData) + if (serializedData.hasOwnProperty(p)) + formdata.append(p, serializedData[p]); } options.data = null; From 13b1a6ec74ed09e0b461419d4e5f597709f7df30 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 20 Feb 2013 14:41:22 -0500 Subject: [PATCH 006/178] Update jquery.form.js --- jquery.form.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index 89d54306..254b4d8b 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -419,7 +419,7 @@ $.fn.ajaxSubmit = function(options) { form.setAttribute('action', s.url); } - // ie borks in some cases when setting encoding + // ie breaks in some cases when setting encoding if (! s.skipEncodingOverride && (!method || /post/i.test(method))) { $form.attr({ encoding: 'multipart/form-data', @@ -427,7 +427,7 @@ $.fn.ajaxSubmit = function(options) { }); } - // support timout + // client timeout support if (s.timeout) { timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout); } From 66044ee589a86c3421937e5028fbbe2d92730963 Mon Sep 17 00:00:00 2001 From: Raffa - Home Date: Sat, 22 Mar 2014 13:17:52 +0100 Subject: [PATCH 007/178] Short initialization --- jquery.form.js | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index 9606f91f..7933fb67 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -89,8 +89,13 @@ $.fn.attr2 = function() { /** * ajaxSubmit() provides a mechanism for immediately submitting * an HTML form using AJAX. + * + * @param object|string options jquery.form.js parameters or custom url for submission + * @param object data extraData + * @param string dataType ajax dataType + * @param function onSuccess ajax success callback function */ -$.fn.ajaxSubmit = function(options) { +$.fn.ajaxSubmit = function(options, data, dataType, onSuccess) { /*jshint scripturl:true */ // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) @@ -98,12 +103,23 @@ $.fn.ajaxSubmit = function(options) { log('ajaxSubmit: skipping submit process - no element selected'); return this; } - var method, action, url, $form = this; if (typeof options == 'function') { options = { success: options }; } + else if ( typeof options == 'string' || ( options === false && arguments.length > 0 ) ) { + options = { + 'url' : options, + 'data' : data, + 'dataType' : dataType, + }; + + if(typeof onSuccess == 'function') + { + options.success = onSuccess; + } + } else if ( options === undefined ) { options = {}; } @@ -117,14 +133,16 @@ $.fn.ajaxSubmit = function(options) { // clean url (don't include hash vaue) url = (url.match(/^([^#]+)/)||[])[1]; } - + options = $.extend(true, { url: url, success: $.ajaxSettings.success, type: method || $.ajaxSettings.type, + resetForm : $form.attr2('data-reset'), + clearForm : $form.attr2('data-clear'), iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' }, options); - + // hook for manipulating the form data before it is extracted; // convenient for use with rich editors like tinyMCE or FCKEditor var veto = {}; @@ -848,10 +866,24 @@ $.fn.ajaxSubmit = function(options) { * passes the options argument along after properly binding events for submit elements and * the form itself. */ -$.fn.ajaxForm = function(options) { - options = options || {}; - options.delegation = options.delegation && $.isFunction($.fn.on); +$.fn.ajaxForm = function(options, data, dataType, onSuccess) { + + if ( typeof options == 'string' || ( options === false && arguments.length > 0 ) ) { + options = { + 'url' : options, + 'data' : data, + 'dataType' : dataType, + }; + if(typeof onSuccess == 'function') + { + options.success = onSuccess; + } + } + + options = options || {}; + options.delegation = options.delegation && $.isFunction($.fn.on); + // in jQuery 1.3+ we can fix mistakes with the ready state if (!options.delegation && this.length === 0) { var o = { s: this.selector, c: this.context }; @@ -885,6 +917,7 @@ $.fn.ajaxForm = function(options) { function doAjaxSubmit(e) { /*jshint validthis:true */ var options = e.data; + if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed e.preventDefault(); $(e.target).ajaxSubmit(options); // #365 From 592949fbe55b6a2bd198965b420cddce78288829 Mon Sep 17 00:00:00 2001 From: Raffa - Home Date: Sat, 22 Mar 2014 20:00:00 +0100 Subject: [PATCH 008/178] handle form data attribute to set resetForm and clearForm options --- jquery.form.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index 7933fb67..84a0f9ea 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -138,11 +138,11 @@ $.fn.ajaxSubmit = function(options, data, dataType, onSuccess) { url: url, success: $.ajaxSettings.success, type: method || $.ajaxSettings.type, - resetForm : $form.attr2('data-reset'), - clearForm : $form.attr2('data-clear'), + resetForm : ($form.attr2('data-reset') === 'true'), + clearForm : ($form.attr2('data-clear') === 'true'), iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' }, options); - + // hook for manipulating the form data before it is extracted; // convenient for use with rich editors like tinyMCE or FCKEditor var veto = {}; From bbc7d22a2d771be2ac352a91f624d2bd72b1e3f0 Mon Sep 17 00:00:00 2001 From: Alexandre Mathieu Date: Wed, 21 May 2014 10:14:03 +0200 Subject: [PATCH 009/178] options.success may be an array of callback functions --- jquery.form.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jquery.form.js b/jquery.form.js index 9606f91f..d354291d 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -194,7 +194,12 @@ $.fn.ajaxSubmit = function(options) { }); } else if (options.success) { - callbacks.push(options.success); + if ($.isArray(options.success)) { + $.merge(callbacks, options.success); + } + else { + callbaks.push(options.success); + } } options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg From 01d26735cbad40a304a551270ea721dfd732a090 Mon Sep 17 00:00:00 2001 From: Tobias Weinert Date: Sun, 25 May 2014 03:37:27 +0200 Subject: [PATCH 010/178] options.success can be an array of functions The jQuery doc of $.ajax states: "As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn." This improvement takes this in account. --- jquery.form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.form.js b/jquery.form.js index 9606f91f..fcd73f9e 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -194,7 +194,7 @@ $.fn.ajaxSubmit = function(options) { }); } else if (options.success) { - callbacks.push(options.success); + $.isArray(options.success) ? callbacks.push.apply(callbacks, options.success) : callbacks.push(options.success); } options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg From a607b434556b8734b155e674db6041a022034729 Mon Sep 17 00:00:00 2001 From: Nick Smith Date: Tue, 2 Dec 2014 13:56:25 +0000 Subject: [PATCH 011/178] #390 alternative fix for IE8 --- jquery.form.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index 591ad6f1..5ea7184f 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -950,8 +950,8 @@ $.fn.formToArray = function(semantic, elements) { var els = semantic ? form.getElementsByTagName('*') : form.elements; var els2; - if (els && !/MSIE [678]/.test(navigator.userAgent)) { // #390 - els = $(els).get(); // convert to standard array + if (els) { + els = $.makeArray(els); // convert to standard array } // #386; account for inputs outside the form which use the 'form' attribute From cce1853385759838e53eaa1563f298f20fa9c18c Mon Sep 17 00:00:00 2001 From: Cyril-Roques Date: Thu, 7 May 2015 16:58:48 +0200 Subject: [PATCH 012/178] Change the way of submited form is retreived In certain conditions 'this' is not the form but the window, this cause the submit button to not be found when checked if button is clicked This patch retrieve form from the input element --- jquery.form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.form.js b/jquery.form.js index 591ad6f1..a0312180 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -903,7 +903,7 @@ function captureSubmittingElement(e) { } target = t[0]; } - var form = this; + var form = target.form; form.clk = target; if (target.type == 'image') { if (e.offsetX !== undefined) { From 3b80d4c5f5b6ca5f4c474bfa75d4696a1bb4f4c7 Mon Sep 17 00:00:00 2001 From: Christian Walde Date: Tue, 19 May 2015 17:01:07 +0200 Subject: [PATCH 013/178] restore value capturing for forms without submit button In our code base we have a few tiny forms like this, that are just a checkbox that trigger an ajax post:
Before the fix for #365 was included this worked perfectly fine, but after its inclusion the value for domain stopped being sent along, since e.target points at the checkbox input and ajaxSubmit sends that input to formToArray, which has no clue as to what to do with it and fails to extract the form values. --- jquery.form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.form.js b/jquery.form.js index 591ad6f1..840870e6 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -887,7 +887,7 @@ function doAjaxSubmit(e) { var options = e.data; if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed e.preventDefault(); - $(e.target).ajaxSubmit(options); // #365 + $(e.target).closest('form').ajaxSubmit(options); // #365 } } From 0c4724db0b6a46ef45278721d8d82d57dfd47dd6 Mon Sep 17 00:00:00 2001 From: George Mauer Date: Tue, 8 Sep 2015 17:30:53 -0500 Subject: [PATCH 014/178] Add main key to package.json To allow proper installation via jspm --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a7355869..d5d751b7 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "upload", "ajax" ], - "version": "3.51.0", + "version": "3.51.1", "author": { "name": "M. Alsup", "url": "http://jquery.malsup.com" @@ -29,6 +29,7 @@ "dependencies": { "jquery": ">=1.5" }, + "main": "jquery.form.js", "jam": { "main": "jquery.form.js", "dependencies": { From b8f7e0abc82690d74b3fda8c3e0647d7b07fa95f Mon Sep 17 00:00:00 2001 From: Erick Calder Date: Mon, 18 Apr 2016 17:46:37 -0700 Subject: [PATCH 015/178] node.js support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit for node.js environments (typically used with browserify), there is no ’jQuery’ variable predefined in the `window` since there are no windows. in that case we require jQuery and everything just works. alternatively, the module needs to be shimmed. --- jquery.form.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jquery.form.js b/jquery.form.js index 591ad6f1..dc00fea8 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -16,6 +16,8 @@ if (typeof define === 'function' && define.amd) { // using AMD; register as anon module define(['jquery'], factory); + } if (typeof module !== 'undefined' { + factory(require('jquery')); } else { // no AMD; invoke directly factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto ); From 78e8997451696f9ef5a778a5e5755290307e619b Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Thu, 7 Jul 2016 11:04:40 -0400 Subject: [PATCH 016/178] Changes jQuery function 'bind' and 'unbind' to 'on' and 'off' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ‘bind’ functions have been deprecated in jQuery 3.0.0 https://github.com/jquery/jquery-migrate/blob/master/warnings.md#jqmigra te-jqueryfnunbind-is-deprecated https://api.jquery.com/bind/ --- jquery.form.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index 591ad6f1..36c8b70c 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -877,8 +877,8 @@ $.fn.ajaxForm = function(options) { } return this.ajaxFormUnbind() - .bind('submit.form-plugin', options, doAjaxSubmit) - .bind('click.form-plugin', options, captureSubmittingElement); + .on('submit.form-plugin', options, doAjaxSubmit) + .on('click.form-plugin', options, captureSubmittingElement); }; // private event handlers @@ -925,7 +925,7 @@ function captureSubmittingElement(e) { // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm $.fn.ajaxFormUnbind = function() { - return this.unbind('submit.form-plugin click.form-plugin'); + return this.off('submit.form-plugin click.form-plugin'); }; /** From eddc9ea49a3fbfbcfe87922ea8cb12f229c82ca8 Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Sun, 24 Jul 2016 12:26:05 -0600 Subject: [PATCH 017/178] Moving the beforeSubmit event above where the options are appended to the URL so you can change the options before submit. --- jquery.form.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jquery.form.js b/jquery.form.js index 591ad6f1..329128d5 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -145,6 +145,12 @@ $.fn.ajaxSubmit = function(options) { traditional = $.ajaxSettings.traditional; } + // give pre-submit callback an opportunity to abort the submit + if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSubmit callback'); + return this; + } + var elements = []; var qx, a = this.formToArray(options.semantic, elements); if (options.data) { @@ -152,11 +158,7 @@ $.fn.ajaxSubmit = function(options) { qx = $.param(options.data, traditional); } - // give pre-submit callback an opportunity to abort the submit - if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSubmit callback'); - return this; - } + // fire vetoable 'validate' event this.trigger('form-submit-validate', [a, this, options, veto]); From 7203b0b32943e301b20ed98f525a1cbc21d1c253 Mon Sep 17 00:00:00 2001 From: talal424 Date: Fri, 28 Oct 2016 21:02:41 +0300 Subject: [PATCH 018/178] Update jquery.form.js --- jquery.form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.form.js b/jquery.form.js index 591ad6f1..41513082 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -1142,7 +1142,7 @@ $.fieldValue = function(el, successful) { var max = (one ? index+1 : ops.length); for(var i=(one ? index : 0); i < max; i++) { var op = ops[i]; - if (op.selected) { + if (op.selected && !op.disabled) { var v = op.value; if (!v) { // extra pain for IE... v = (op.attributes && op.attributes.value && !(op.attributes.value.specified)) ? op.text : op.value; From 18db6a665d9f79c875871f9820b96d805b51e6b1 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 20 Feb 2017 15:43:33 -0500 Subject: [PATCH 019/178] Adds license and contributor information --- CONTRIBUTORS.md | 10 +++ LICENSE | 21 ++++++ LICENSE-LGPLv3 | 165 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 18 ++---- 4 files changed, 203 insertions(+), 11 deletions(-) create mode 100644 CONTRIBUTORS.md create mode 100644 LICENSE create mode 100644 LICENSE-LGPLv3 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 00000000..9995b4fd --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,10 @@ +#Contributors + +###Copyright 2017 Kevin Morris +Continuing Work [jQuery Form](https://github.com/jquery-form/form/) by Kevin Morris +Project Home: [github.com/jquery-form/form](https://github.com/jquery-form/form/) + +###Copyright 2006-2014 Mike Alsup +Original work [jQuery Form](https://github.com/malsup/form/) by Mike Alsup +Project Home: [jquery.malsup.com/form](http://jquery.malsup.com/form/) +The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..bade8ab7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 jquery-form + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LICENSE-LGPLv3 b/LICENSE-LGPLv3 new file mode 100644 index 00000000..02bbb60b --- /dev/null +++ b/LICENSE-LGPLv3 @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. \ No newline at end of file diff --git a/README.md b/README.md index 52a6fc92..09ec8389 100644 --- a/README.md +++ b/README.md @@ -188,20 +188,16 @@ The Form Plugin supports use of [XMLHttpRequest Level 2]("http://www.w3.org/TR/X ##CDN Support `` -##Copyright and License -Copyright 2006-2013 (c) M. Alsup +##Contributors +This project has transferred from [github.com/malsup/form](https://github.com/malsup/form/), courtesy of [Mike Alsup](https://github.com/malsup). +See [CONTRIBUTORS](CONTRIBUTORS.md) for details. -All versions, present and past, of the jQuery Form plugin are dual licensed under the MIT and GPL licenses: +##License -* [MIT](http://malsup.github.com/mit-license.txt) -* [GPL](http://malsup.github.com/gpl-license-v2.txt) - -You may use either license. The MIT License is recommended for most projects because it is simple and easy to understand and it places almost no restrictions on what you can do with the plugin. - -If the GPL suits your project better you are also free to use the plugin under that license. - -You don't have to do anything special to choose one license or the other and you don't have to notify anyone which license you are using. You are free to use the jQuery Form Plugin in commercial projects as long as the copyright header is left intact. +This project is dual licensed under the MIT and LGPLv3 licenses: +* [MIT](LICENSE) +* [GNU Lesser General Public License v3.0](LICENSE-LGPLv3) --- From aac61547e13cb641170cd33a550b5c5ad368c08e Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 20 Feb 2017 15:44:14 -0500 Subject: [PATCH 020/178] Adds Code of Conduct and contribution guidelines --- CODE_OF_CONDUCT.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 6 ++++ 3 files changed, 154 insertions(+) create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..9c1c6216 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..9bcb67aa --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,74 @@ +# Contributing to jQuery Form + +Want to contribute to jQuery Form? That's great! Contributions are most welcome! +Here are a couple of guidelines that will help you contribute. Before we get started: Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md) to ensure that this project is a welcoming place for **everyone** to contribute to. By participating in this project you agree to abide by its terms. + +#### Overview +* [Contribution workflow](#contribution-workflow) +* [Reporting a bug](#reporting-a-bug) +* [Contributing to an existing issue](#contributing-to-an-existing-issue) +* [Feature Requests](#feature-requests) +* [Additional info](#additional-info) + +## Contribution workflow + +* Fork the repository in GitHub with the `Fork` button. +* Switch to a new branch (ie. `new-feature`), and work from there: + `git checkout -b new-feature` +* Make your feature addition or bug fix. +* Send a pull request (PR). Bonus points for topic branches. + * Please make sure all of your commits are atomic (one feature per commit). + * Use sensible commit messages. + * Always write a clear log message for your commits. One-line messages are fine for small changes, but bigger changes should look like this: + +```shell + $ git commit -m "A brief summary of the commit" + > + > A paragraph describing what changed and its impact." +``` + + * If your PR fixes a separate issue number, include it in the commit message. + +### Things to keep in mind +* Smaller PRs are likely to be merged more quickly than bigger changes. +* If it is a useful PR it **will** get merged in eventually. +* This project is using [Semantic Versioning 2.0.0](http://semver.org/) + +## Reporting a bug + +So you've found a bug, and want to help us fix it? Before filing a bug report, please double-check the bug hasn't already been reported. You can do so [on our issue tracker](https://github.com/jquery-form/form/issues?q=is%3Aopen+is%3Aissue). If something hasn't been raised, you can go ahead and create a new issue with the following information: + +* Which version of the plugin are you using? +* How can the error be reproduced? +* If possible, include a link to a [JSFiddle](https://jsfiddle.net/) or [CodePen](https://codepen.io/) example of the error. + +If you want to be really thorough, there is a great overview on Stack Overflow of [what you should consider when reporting a bug](https://stackoverflow.com/questions/240323/how-to-report-bugs-the-smart-way). + +It goes without saying that you're welcome to help investigate further and/or find a fix for the bug. If you want to do so, just mention it in your bug report and offer your help! + +## Contributing to an existing issue + +### Finding an issue to work on + +We've got a few open issues and are always glad to get help on that front. You can view the list of issues [here](https://github.com/jquery-form/form/issues). (Here's [a good article](https://medium.freecodecamp.com/finding-your-first-open-source-project-or-bug-to-work-on-1712f651e5ba) on how to find your first bug to fix). + +Before getting to work, take a look at the issue and at the conversation around it. Has someone already offered to work on the issue? Has someone been assigned to the issue? If so, you might want to check with them to see whether they're still actively working on it. + +If the issue is a few months old, it might be a good idea to write a short comment to double-check that the issue or feature is still a valid one to jump on. + +Feel free to ask for more detail on what is expected: are there any more details or specifications you need to know? +And if at any point you get stuck: don't hesitate to ask for help. + +### Making your contribution + +We've outlined the contribution workflow [here](#contribution-workflow). If you're a first-timer, don't worry! GitHub has a ton of guides to help you through your first pull request: You can find out more about pull requests [here](https://help.github.com/articles/about-pull-requests/) and about creating a pull request [here](https://help.github.com/articles/creating-a-pull-request/). + +## Feature Requests +* You can _request_ a new feature by [submitting an issue](https://github.com/jquery-form/form/issues). +* If you would like to _implement_ a new feature: + * For a **Major Feature**, first open an issue and outline your proposal so that it can be discussed. This will also allow us to better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project. + * **Small Features** can be crafted and directly [submitted as a Pull Request](#contribution-workflow). + +## Additional info + +Especially if you're a newcomer to Open Source and you've found some little bumps along the way while contributing, we recommend you write about them. [Here](https://medium.freecodecamp.com/new-contributors-to-open-source-please-blog-more-920af14cffd)'s a great article about why writing about your experience is important; this will encourage other beginners to try their luck at Open Source, too! diff --git a/README.md b/README.md index 09ec8389..4af2676e 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,12 @@ The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms No special markup is needed, just a normal form. Submitting a form with AJAX doesn't get any easier than this! +##Community +Want to contribute to jQuery Form? Awesome! See [CONTRIBUTING](CONTRIBUTING.md) for more information. + +###Code of Conduct +Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md) to ensure that this project is a welcoming place for **everyone** to contribute to. By participating in this project you agree to abide by its terms. + --- ##API From d62e1763086e2d029b0ca5d5d6670d620b5e10fa Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 20 Feb 2017 15:44:43 -0500 Subject: [PATCH 021/178] Adds dev environment files --- .editorconfig | 21 ++++ .gitignore | 262 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..69cfa45f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# http://editorconfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = tab +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +[{*.md,*.scss,*.css,*.php,*.yml,package.json}] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..352f810d --- /dev/null +++ b/.gitignore @@ -0,0 +1,262 @@ +cache/ +deploy.txt +.svn +node_modules +*.scssc +.settings +.project + + +############# +## OS generated files +############# +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac crap +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes + + +################# +## Compiled source +################# + +*.com +*.class +*.dll +*.exe +*.o +*.so + + +################# +## Packages +################# +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + + +################# +## Logs and databases +################# +*.log +*.sql +*.sqlite + + +################# +## Eclipse +################# + +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.vspscc +*.vssscc +.builds +*.pidb +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml +*.publishproj + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +#packages/ + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + + +############# +## Python +############# + +*.py[cod] + +# Packages +*.egg +*.egg-info +build/ +eggs/ +parts/ +var/ +sdist/ +develop-eggs/ +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg +prepros.cfg From 18219ec3d28a1f1119bc8c9edec5e36a874865ff Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 20 Feb 2017 15:47:40 -0500 Subject: [PATCH 022/178] Cleans up README --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4af2676e..67e7651f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#[jQuery Form Plugin](http://jquery.malsup.com/form/) +#jQuery Form ##Overview The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process. Both of these methods support numerous options which allows you to have full control over how the data is submitted. @@ -18,6 +18,7 @@ Please note that this project is released with a [Contributor Code of Conduct](C ###jqXHR The jqXHR object is stored in element data-cache with the jqxhr key after each ajaxSubmit call. It can be accessed like this: + ````javascript var form = $('#myForm').ajaxSubmit({ /* options */ }); var xhr = form.data('jqxhr'); @@ -55,7 +56,7 @@ $('form').on('submit', function(e) { --- ##Options -Note: all standard [$.ajax](http://api.jquery.com/jQuery.ajax) options can be used. +**Note:** All standard [$.ajax](http://api.jquery.com/jQuery.ajax) options can be used. ###beforeSerialize Callback function invoked prior to form serialization. Provides an opportunity to manipulate the form before its values are retrieved. Returning `false` from the callback will prevent the form from being submitted. The callback is invoked with two arguments: the jQuery wrapped form object and the options object. @@ -67,7 +68,7 @@ beforeSerialize: function($form, options) { ```` ###beforeSubmit -Callback function invoked prior to form submission. This provides an opportunity to manipulate the form before it's values are retrieved. Returning `false` from the callback will prevent the form from being submitted. The callback is invoked with three arguments: the form data in array format, the jQuery wrapped form object, and the options Oobject. +Callback function invoked prior to form submission. This provides an opportunity to manipulate the form before it's values are retrieved. Returning `false` from the callback will prevent the form from being submitted. The callback is invoked with three arguments: the form data in array format, the jQuery wrapped form object, and the options object. ````javascript beforeSubmit: function(arr, $form, options) { @@ -83,7 +84,7 @@ Boolean flag indicating whether the form should be cleared if the submit is succ ###data An object containing extra data that should be submitted along with the form. -````javascript +```` data: { key1: 'value1', key2: 'value2' } ```` @@ -116,7 +117,7 @@ Set to `true` to remove the short delay before posting form when uploading files Boolean flag indicating whether the form should *always* target the server response to an iframe instead of leveraging XHR when possible. ###iframeSrc -String value that should be used for the iframe's src attribute when/if an iframe is used. +String value that should be used for the iframe's src attribute when an iframe is used. ###iframeTarget Identifies the iframe element to be used as the response target for file uploads. By default, the plugin will create a temporary iframe element to capture the response when uploading files. This options allows you to use an existing iframe if you wish. When using this option the plugin will make no attempt at handling the response from the server. @@ -207,4 +208,4 @@ This project is dual licensed under the MIT and LGPLv3 licenses: --- -Additional documentation and examples at: http://malsup.com/jquery/form/ +Additional documentation and examples for version 3.51- at: [http://malsup.com/jquery/form/](http://malsup.com/jquery/form/) From 26a728221cadbbc94b460655fe517d231b8874c8 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 20 Feb 2017 16:53:01 -0500 Subject: [PATCH 023/178] Whitespace --- README.md | 24 +- jquery.form.js | 2387 ++++++++++++++++++++++++------------------------ 2 files changed, 1204 insertions(+), 1207 deletions(-) diff --git a/README.md b/README.md index 84d1de1c..a533ac60 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ #jQuery Form ##Overview -The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process. Both of these methods support numerous options which allows you to have full control over how the data is submitted. +The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process. Both of these methods support numerous options which allows you to have full control over how the data is submitted. No special markup is needed, just a normal form. Submitting a form with AJAX doesn't get any easier than this! @@ -12,7 +12,7 @@ Want to contribute to jQuery Form? Awesome! See [CONTRIBUTING](CONTRIBUTING.md) Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md) to ensure that this project is a welcoming place for **everyone** to contribute to. By participating in this project you agree to abide by its terms. --- - + ##API ###jqXHR @@ -40,7 +40,7 @@ $('form').ajaxForm({ ```` ###ajaxSubmit( options ) -Immediately submits the form via AJAX. In the most common use case this is invoked in response to the user clicking a submit button on the form. +Immediately submits the form via AJAX. In the most common use case this is invoked in response to the user clicking a submit button on the form. Use ajaxSubmit if you want to bind your own submit handler to the form. ````javascript @@ -62,8 +62,8 @@ $('form').on('submit', function(e) { Callback function invoked prior to form serialization. Provides an opportunity to manipulate the form before its values are retrieved. Returning `false` from the callback will prevent the form from being submitted. The callback is invoked with two arguments: the jQuery wrapped form object and the options object. ````javascript -beforeSerialize: function($form, options) { - // return false to cancel submit +beforeSerialize: function($form, options) { + // return false to cancel submit } ```` @@ -71,15 +71,16 @@ beforeSerialize: function($form, options) { Callback function invoked prior to form submission. This provides an opportunity to manipulate the form before it's values are retrieved. Returning `false` from the callback will prevent the form from being submitted. The callback is invoked with three arguments: the form data in array format, the jQuery wrapped form object, and the options object. ````javascript -beforeSubmit: function(arr, $form, options) { +beforeSubmit: function(arr, $form, options) { // form data array is an array of objects with name and value properties - // [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] - // return false to cancel submit + // [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] + // return false to cancel submit } ```` ###filtering -Callback function invoked before processing fiels. This provides a way to filter elements. +Callback function invoked before processing fields. This provides a way to filter elements. + ````javascript filtering: function(el, index) { if ( !$(el).hasClass('ignore') ) { @@ -121,7 +122,7 @@ Callback function to be invoked upon error. ###forceSync Only applicable when explicity using the iframe option or when uploading files on browses that don't support XHR2. -Set to `true` to remove the short delay before posting form when uploading files. The delay is used to allow the browser to render DOM updates prior to performing a native form submit. This improves usability when displaying notifications to the user, such as "Please Wait..." +Set to `true` to remove the short delay before posting form when uploading files. The delay is used to allow the browser to render DOM updates prior to performing a native form submit. This improves usability when displaying notifications to the user, such as "Please Wait..." ###iframe Boolean flag indicating whether the form should *always* target the server response to an iframe instead of leveraging XHR when possible. @@ -133,7 +134,7 @@ String value that should be used for the iframe's src attribute when an iframe i Identifies the iframe element to be used as the response target for file uploads. By default, the plugin will create a temporary iframe element to capture the response when uploading files. This options allows you to use an existing iframe if you wish. When using this option the plugin will make no attempt at handling the response from the server. ###replaceTarget -Optionally used along with the the target option. Set to true if the target should be replaced or false if only the target contents should be replaced. +Optionally used along with the the target option. Set to true if the target should be replaced or false if only the target contents should be replaced. ###resetForm Boolean flag indicating whether the form should be reset if the submit is successful @@ -205,6 +206,7 @@ The Form Plugin supports use of [XMLHttpRequest Level 2]("http://www.w3.org/TR/X ##CDN Support `` + ##Contributors This project has transferred from [github.com/malsup/form](https://github.com/malsup/form/), courtesy of [Mike Alsup](https://github.com/malsup). See [CONTRIBUTORS](CONTRIBUTORS.md) for details. diff --git a/jquery.form.js b/jquery.form.js index 762cf40c..cd5332fb 100644 --- a/jquery.form.js +++ b/jquery.form.js @@ -12,56 +12,56 @@ // AMD support (function (factory) { - "use strict"; - if (typeof define === 'function' && define.amd) { - // using AMD; register as anon module - define(['jquery'], factory); - } if (typeof module !== 'undefined' { + "use strict"; + if (typeof define === 'function' && define.amd) { + // using AMD; register as anon module + define(['jquery'], factory); + } if (typeof module !== 'undefined' { factory(require('jquery')); - } else { - // no AMD; invoke directly - factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto ); - } + } else { + // no AMD; invoke directly + factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto ); + } } (function($) { "use strict"; /* - Usage Note: - ----------- - Do not use both ajaxSubmit and ajaxForm on the same form. These - functions are mutually exclusive. Use ajaxSubmit if you want - to bind your own submit handler to the form. For example, - - $(document).ready(function() { - $('#myForm').on('submit', function(e) { - e.preventDefault(); // <-- important - $(this).ajaxSubmit({ - target: '#output' - }); - }); - }); - - Use ajaxForm when you want the plugin to manage all the event binding - for you. For example, - - $(document).ready(function() { - $('#myForm').ajaxForm({ - target: '#output' - }); - }); - - You can also use ajaxForm with delegation (requires jQuery v1.7+), so the - form does not have to exist when you invoke ajaxForm: - - $('#myForm').ajaxForm({ - delegation: true, - target: '#output' - }); - - When using ajaxForm, the ajaxSubmit function will be invoked for you - at the appropriate time. + Usage Note: + ----------- + Do not use both ajaxSubmit and ajaxForm on the same form. These + functions are mutually exclusive. Use ajaxSubmit if you want + to bind your own submit handler to the form. For example, + + $(document).ready(function() { + $('#myForm').on('submit', function(e) { + e.preventDefault(); // <-- important + $(this).ajaxSubmit({ + target: '#output' + }); + }); + }); + + Use ajaxForm when you want the plugin to manage all the event binding + for you. For example, + + $(document).ready(function() { + $('#myForm').ajaxForm({ + target: '#output' + }); + }); + + You can also use ajaxForm with delegation (requires jQuery v1.7+), so the + form does not have to exist when you invoke ajaxForm: + + $('#myForm').ajaxForm({ + delegation: true, + target: '#output' + }); + + When using ajaxForm, the ajaxSubmit function will be invoked for you + at the appropriate time. */ /** @@ -74,789 +74,787 @@ 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 ) { - return this.attr.apply(this, arguments); - } - var val = this.prop.apply(this, arguments); - if ( ( val && val.jquery ) || typeof val === 'string' ) { - return val; - } - return this.attr.apply(this, arguments); + if ( ! hasProp ) { + return this.attr.apply(this, arguments); + } + var val = this.prop.apply(this, arguments); + if ( ( val && val.jquery ) || typeof val === 'string' ) { + return val; + } + return this.attr.apply(this, arguments); }; /** * ajaxSubmit() provides a mechanism for immediately submitting * an HTML form using AJAX. - * - * @param object|string options jquery.form.js parameters or custom url for submission - * @param object data extraData - * @param string dataType ajax dataType - * @param function onSuccess ajax success callback function + * + * @param object|string options jquery.form.js parameters or custom url for submission + * @param object data extraData + * @param string dataType ajax dataType + * @param function onSuccess ajax success callback function */ $.fn.ajaxSubmit = function(options, data, dataType, onSuccess) { - /*jshint scripturl:true */ - - // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) - if (!this.length) { - log('ajaxSubmit: skipping submit process - no element selected'); - return this; - } - var method, action, url, $form = this; - - if (typeof options == 'function') { - options = { success: options }; - } - else if ( typeof options == 'string' || ( options === false && arguments.length > 0 ) ) { - options = { - 'url' : options, - 'data' : data, - 'dataType' : dataType, - }; - - if(typeof onSuccess == 'function') - { - options.success = onSuccess; - } - } - else if ( options === undefined ) { - options = {}; - } - - method = options.type || this.attr2('method'); - action = options.url || this.attr2('action'); - - url = (typeof action === 'string') ? $.trim(action) : ''; - url = url || window.location.href || ''; - if (url) { - // clean url (don't include hash vaue) - url = (url.match(/^([^#]+)/)||[])[1]; - } - - options = $.extend(true, { - url: url, - success: $.ajaxSettings.success, - type: method || $.ajaxSettings.type, - resetForm : ($form.attr2('data-reset') === 'true'), - clearForm : ($form.attr2('data-clear') === 'true'), - iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' - }, options); - - // hook for manipulating the form data before it is extracted; - // convenient for use with rich editors like tinyMCE or FCKEditor - var veto = {}; - this.trigger('form-pre-serialize', [this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); - return this; - } - - // provide opportunity to alter form data before it is serialized - if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSerialize callback'); - return this; - } - - var traditional = options.traditional; - if ( traditional === undefined ) { - traditional = $.ajaxSettings.traditional; - } + /*jshint scripturl:true */ + + // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) + if (!this.length) { + log('ajaxSubmit: skipping submit process - no element selected'); + return this; + } + + var method, action, url, $form = this; + + if (typeof options == 'function') { + options = { success: options }; + + } else if ( typeof options == 'string' || ( options === false && arguments.length > 0 ) ) { + options = { + 'url' : options, + 'data' : data, + 'dataType' : dataType, + }; + + if(typeof onSuccess == 'function') + { + options.success = onSuccess; + } + + } else if ( options === undefined ) { + options = {}; + } + + method = options.type || this.attr2('method'); + action = options.url || this.attr2('action'); + + url = (typeof action === 'string') ? $.trim(action) : ''; + url = url || window.location.href || ''; + if (url) { + // clean url (don't include hash vaue) + url = (url.match(/^([^#]+)/)||[])[1]; + } + + options = $.extend(true, { + url: url, + success: $.ajaxSettings.success, + type: method || $.ajaxSettings.type, + iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' + }, options); + + // hook for manipulating the form data before it is extracted; + // convenient for use with rich editors like tinyMCE or FCKEditor + var veto = {}; + this.trigger('form-pre-serialize', [this, options, veto]); + if (veto.veto) { + log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); + return this; + } + + // provide opportunity to alter form data before it is serialized + if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSerialize callback'); + return this; + } + + var traditional = options.traditional; + if ( traditional === undefined ) { + traditional = $.ajaxSettings.traditional; + } // give pre-submit callback an opportunity to abort the submit - if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSubmit callback'); - return this; - } - - var elements = []; - var qx, a = this.formToArray(options.semantic, elements, options.filtering); - if (options.data) { - var optionsData = $.isFunction(options.data) ? options.data(a) : options.data; - options.extraData = optionsData; - qx = $.param(optionsData, traditional); - } - - - - // fire vetoable 'validate' event - 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, traditional); - if (qx) { - q = ( q ? (q + '&' + qx) : qx ); - } - if (options.type.toUpperCase() == 'GET') { - options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; - options.data = null; // data is null for 'get' - } - else { - options.data = q; // data is the query string for 'post' - } - - var callbacks = []; - if (options.resetForm) { - callbacks.push(function() { $form.resetForm(); }); - } - if (options.clearForm) { - callbacks.push(function() { $form.clearForm(options.includeHidden); }); - } - - // perform a load on the target only if dataType is not provided - 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) { - if ($.isArray(options.success)) { - $.merge(callbacks, options.success); - } - else { - callbacks.push(options.success); - } - } - - options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg - var context = options.context || this ; // jQuery 1.4+ supports scope context - for (var i=0, max=callbacks.length; i < max; i++) { - callbacks[i].apply(context, [data, status, xhr || $form, $form]); - } - }; - - 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', this).filter(function() { return $(this).val() !== ''; }); - - var hasFileInputs = fileInputs.length > 0; - var mp = 'multipart/form-data'; - var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); - - var fileAPI = feature.fileapi && feature.formdata; - log("fileAPI :" + fileAPI); - var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; - - var jqxhr; - - // options.iframe allows user to force iframe mode - // 06-NOV-09: now defaulting to iframe mode if file input is detected - if (options.iframe !== false && (options.iframe || shouldUseFrame)) { - // hack to fix Safari hang (thanks to Tim Molendijk for this) - // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d - if (options.closeKeepAlive) { - $.get(options.closeKeepAlive, function() { - jqxhr = fileUploadIframe(a); - }); - } - else { - jqxhr = fileUploadIframe(a); - } - } - else if ((hasFileInputs || multipart) && fileAPI) { - jqxhr = fileUploadXhr(a); - } - else { - jqxhr = $.ajax(options); - } - - $form.removeData('jqxhr').data('jqxhr', jqxhr); - - // clear element array - for (var k=0; k < elements.length; k++) { - elements[k] = null; - } - - // fire 'notify' event - this.trigger('form-submit-notify', [this, options]); - return this; - - // utility fn for deep serialization - function deepSerialize(extraData){ - var serialized = $.param(extraData, options.traditional).split('&'); - var len = serialized.length; - var result = []; - var i, part; - for (i=0; i < len; i++) { - part = serialized[i].split('='); - // #278; use array instead of object storage, favoring array serializations - result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]); - } - return result; - } - - // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) - function fileUploadXhr(a) { - var formdata = new FormData(); - - for (var i=0; i < a.length; i++) { - formdata.append(a[i].name, a[i].value); - } - - if (options.extraData) { - var serializedData = deepSerialize(options.extraData); - for (i=0; i < serializedData.length; i++) { - if (serializedData[i]) { - formdata.append(serializedData[i][0], serializedData[i][1]); - } - } - } - - options.data = null; - - var s = $.extend(true, {}, $.ajaxSettings, options, { - contentType: false, - processData: false, - cache: false, - type: method || 'POST' - }); - - if (options.uploadProgress) { - // workaround because jqXHR does not expose upload property - s.xhr = function() { - var xhr = $.ajaxSettings.xhr(); - if (xhr.upload) { - xhr.upload.addEventListener('progress', function(event) { - var percent = 0; - var position = event.loaded || event.position; /*event.position is deprecated*/ - var total = event.total; - if (event.lengthComputable) { - percent = Math.ceil(position / total * 100); - } - options.uploadProgress(event, position, total, percent); - }, false); - } - return xhr; - }; - } - - s.data = null; - 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); - } - }; - return $.ajax(s); - } - - // private function for handling file uploads (hat tip to YAHOO!) - function fileUploadIframe(a) { - 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 ) { - el.prop('disabled', false); - } - else { - el.removeAttr('disabled'); - } - } - } - - s = $.extend(true, {}, $.ajaxSettings, options); - s.context = s.context || s; - id = 'jqFormIO' + (new Date().getTime()); - if (s.iframeTarget) { - $io = $(s.iframeTarget); - n = $io.attr2('name'); - if (!n) { - $io.attr2('name', id); - } - else { - id = n; - } - } - else { - $io = $('