From ed46f6d82b80825695ee7d951721c759dc7d1103 Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Fri, 16 Jan 2009 10:04:18 +0000 Subject: Update jquery.form to 2.18 in order to fix compatibility issues with jQuery 1.3, in particular COUCHDB-211. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@734953 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/jquery.form.js | 77 +++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 23 deletions(-) diff --git a/share/www/script/jquery.form.js b/share/www/script/jquery.form.js index 659baa98..91eb688d 100644 --- a/share/www/script/jquery.form.js +++ b/share/www/script/jquery.form.js @@ -1,6 +1,6 @@ /* * jQuery Form Plugin - * version: 2.12 (06/07/2008) + * version: 2.18 (06-JAN-2009) * @requires jQuery v1.2.2 or later * * Examples and documentation at: http://malsup.com/jquery/form/ @@ -10,7 +10,7 @@ * * Revision: $Id$ */ -(function($) { +;(function($) { /* Usage Note: @@ -67,13 +67,25 @@ $.fn.ajaxSubmit = function(options) { 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 a = this.formToArray(options.semantic); if (options.data) { options.extraData = options.data; - for (var n in options.data) - a.push( { name: n, value: options.data[n] } ); + 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] } ) + } + else + a.push( { name: n, value: options.data[n] } ); + } } // give pre-submit callback an opportunity to abort the submit @@ -114,7 +126,7 @@ $.fn.ajaxSubmit = function(options) { options.success = function(data, status) { for (var i=0, max=callbacks.length; i < max; i++) - callbacks[i](data, status, $form); + callbacks[i].apply(options, [data, status, $form]); }; // are there files to upload? @@ -145,12 +157,13 @@ $.fn.ajaxSubmit = function(options) { 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 id = 'jqFormIO' + (new Date().getTime()); var $io = $('