Mise à jour librairie en version 2.43

This commit is contained in:
Michael RICOIS 2010-06-23 08:55:17 +00:00
parent 06843f7e14
commit b713da6c55

View File

@ -1,6 +1,6 @@
/*
/*!
* jQuery Form Plugin
* version: 2.39 (19-FEB-2010)
* version: 2.43 (12-MAR-2010)
* @requires jQuery v1.3.2 or later
*
* Examples and documentation at: http://malsup.com/jquery/form/
@ -124,7 +124,8 @@ $.fn.ajaxSubmit = function(options) {
if (!options.dataType && options.target) {
var oldSuccess = options.success || function(){};
callbacks.push(function(data) {
$(options.target).html(data).each(oldSuccess, arguments);
var fn = options.replaceTarget ? 'replaceWith' : 'html';
$(options.target)[fn](data).each(oldSuccess, arguments);
});
}
else if (options.success)
@ -209,7 +210,7 @@ $.fn.ajaxSubmit = function(options) {
if (xhr.aborted)
return;
var cbInvoked = 0;
var cbInvoked = false;
var timedOut = 0;
// add submitting element to data if we know it
@ -220,8 +221,8 @@ $.fn.ajaxSubmit = function(options) {
opts.extraData = opts.extraData || {};
opts.extraData[n] = sub.value;
if (sub.type == "image") {
opts.extraData[name+'.x'] = form.clk_x;
opts.extraData[name+'.y'] = form.clk_y;
opts.extraData[n+'.x'] = form.clk_x;
opts.extraData[n+'.y'] = form.clk_y;
}
}
}
@ -277,12 +278,11 @@ $.fn.ajaxSubmit = function(options) {
else
setTimeout(doSubmit, 10); // this lets dom updates render
var domCheckCount = 50;
var domCheckCount = 100;
function cb() {
if (cbInvoked++) return;
$io.removeData('form-plugin-onload');
if (cbInvoked)
return;
var ok = true;
try {
@ -298,14 +298,16 @@ $.fn.ajaxSubmit = function(options) {
if (--domCheckCount) {
// in some browsers (Opera) the iframe DOM is not always traversable when
// the onload callback fires, so we loop a bit to accommodate
cbInvoked = 0;
setTimeout(cb, 100);
log('requeing onLoad callback, DOM not available');
setTimeout(cb, 250);
return;
}
log('Could not access iframe DOM after 50 tries.');
log('Could not access iframe DOM after 100 tries.');
return;
}
log('response detected');
cbInvoked = true;
xhr.responseText = doc.body ? doc.body.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
xhr.getResponseHeader = function(header){
@ -331,7 +333,9 @@ $.fn.ajaxSubmit = function(options) {
data = $.httpData(xhr, opts.dataType);
}
catch(e){
log('error caught:',e);
ok = false;
xhr.error = e;
$.handleError(opts, xhr, 'error', e);
}
@ -346,6 +350,7 @@ $.fn.ajaxSubmit = function(options) {
// clean up
setTimeout(function() {
$io.removeData('form-plugin-onload');
$io.remove();
xhr.responseXML = null;
}, 100);
@ -380,9 +385,9 @@ $.fn.ajaxSubmit = function(options) {
* the form itself.
*/
$.fn.ajaxForm = function(options) {
return this.ajaxFormUnbind().bind('submit.form-plugin', function() {
return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
e.preventDefault();
$(this).ajaxSubmit(options);
return false;
}).bind('click.form-plugin', function(e) {
var target = e.target;
var $el = $(target);
@ -658,8 +663,13 @@ $.fn.selected = function(select) {
// helper fn for console logging
// set $.fn.ajaxSubmit.debug to true to enable debug logging
function log() {
if ($.fn.ajaxSubmit.debug && window.console && window.console.log)
window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments,''));
if ($.fn.ajaxSubmit.debug) {
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
if (window.console && window.console.log)
window.console.log(msg);
else if (window.opera && window.opera.postError)
window.opera.postError(msg);
}
};
})(jQuery);