From aef6c1e75075dbb78da2e914355cce2e2a45dc1f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 20 Jun 2009 17:47:13 -0700 Subject: Updated jquery.form to a9c8862544aa3dde81c0aa1554edce148b31742d (2.28) --- lib/jquery.form.js | 90 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 40 deletions(-) (limited to 'lib/jquery.form.js') diff --git a/lib/jquery.form.js b/lib/jquery.form.js index 329d47b9..c027f19c 100644 --- a/lib/jquery.form.js +++ b/lib/jquery.form.js @@ -1,14 +1,12 @@ /* * jQuery Form Plugin - * version: 2.17 (06-NOV-2008) + * version: 2.28 (10-MAY-2009) * @requires jQuery v1.2.2 or later * * Examples and documentation at: http://malsup.com/jquery/form/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html - * - * Revision: $Id$ */ ;(function($) { @@ -55,8 +53,15 @@ $.fn.ajaxSubmit = function(options) { if (typeof options == 'function') options = { success: options }; + var url = $.trim(this.attr('action')); + if (url) { + // clean url (don't include hash vaue) + url = (url.match(/^([^#]+)/)||[])[1]; + } + url = url || window.location.href || '' + options = $.extend({ - url: this.attr('action') || window.location.toString(), + url: url, type: this.attr('method') || 'GET' }, options || {}); @@ -81,7 +86,7 @@ $.fn.ajaxSubmit = function(options) { for (var n in options.data) { if(options.data[n] instanceof Array) { for (var k in options.data[n]) - a.push( { name: n, value: options.data[n][k] } ) + a.push( { name: n, value: options.data[n][k] } ); } else a.push( { name: n, value: options.data[n] } ); @@ -136,11 +141,15 @@ $.fn.ajaxSubmit = function(options) { if (files[j]) found = true; + var multipart = false; +// var mp = 'multipart/form-data'; +// multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); + // options.iframe allows user to force iframe mode - if (options.iframe || found) { + if (options.iframe || found || multipart) { // hack to fix Safari hang (thanks to Tim Molendijk for this) // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d - if ($.browser.safari && options.closeKeepAlive) + if (options.closeKeepAlive) $.get(options.closeKeepAlive, fileUpload); else fileUpload(); @@ -156,22 +165,19 @@ $.fn.ajaxSubmit = function(options) { // private function for handling file uploads (hat tip to YAHOO!) function fileUpload() { var form = $form[0]; - /* - if ($(':input[@name=submit]', form).length) { + + if ($(':input[name=submit]', form).length) { alert('Error: Form elements must not be named "submit".'); return; } - */ var opts = $.extend({}, $.ajaxSettings, options); - var s = jQuery.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts); + var s = $.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts); var id = 'jqFormIO' + (new Date().getTime()); - var $io = $('