Skip to content

Commit

Permalink
v2.35 - added iframeSrc option and defaulted iframe option to true if…
Browse files Browse the repository at this point in the history
… file input detected;
  • Loading branch information
Mike authored and Mike committed Nov 6, 2009
1 parent 8114b37 commit ce43241
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions jquery.form.js
@@ -1,6 +1,6 @@
/*
* jQuery Form Plugin
* version: 2.34 (04-NOV-2009)
* version: 2.35 (06-NOV-2009)
* @requires jQuery v1.2.6 or later
*
* Examples and documentation at: http://malsup.com/jquery/form/
Expand Down Expand Up @@ -62,7 +62,8 @@ $.fn.ajaxSubmit = function(options) {

options = $.extend({
url: url,
type: this.attr('method') || 'GET'
type: this.attr('method') || 'GET',
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
}, options || {});

// hook for manipulating the form data before it is extracted;
Expand Down Expand Up @@ -146,7 +147,8 @@ $.fn.ajaxSubmit = function(options) {
// multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);

// options.iframe allows user to force iframe mode
if (options.iframe || found || multipart) {
// 06-NOV-09: now defaulting to iframe mode if file input is detected
if ((files.length && options.iframe !== false) || 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 (options.closeKeepAlive)
Expand Down Expand Up @@ -175,7 +177,7 @@ $.fn.ajaxSubmit = function(options) {
var s = $.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);

var id = 'jqFormIO' + (new Date().getTime());
var $io = $('<iframe id="' + id + '" name="' + id + '" src="about:blank" />');
var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ opts.iframeSrc +'" />');
var io = $io[0];

$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
Expand All @@ -191,7 +193,7 @@ $.fn.ajaxSubmit = function(options) {
setRequestHeader: function() {},
abort: function() {
this.aborted = 1;
$io.attr('src','about:blank'); // abort op in progress
$io.attr('src', opts.iframeSrc); // abort op in progress
}
};

Expand Down Expand Up @@ -402,7 +404,7 @@ $.fn.ajaxForm = function(options) {
}
}
// clear form vars
setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 10);
setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
});
};

Expand Down

0 comments on commit ce43241

Please sign in to comment.