diff --git a/js/jquery.form.js b/js/jquery.form.js
index 2b853df428..14e14572af 100644
--- a/js/jquery.form.js
+++ b/js/jquery.form.js
@@ -1,6 +1,6 @@
/*!
* jQuery Form Plugin
- * version: 2.49 (18-OCT-2010)
+ * version: 2.63 (29-JAN-2011)
* @requires jQuery v1.3.2 or later
*
* Examples and documentation at: http://malsup.com/jquery/form/
@@ -54,7 +54,8 @@ $.fn.ajaxSubmit = function(options) {
options = { success: options };
}
- var url = $.trim(this.attr('action'));
+ var action = this.attr('action');
+ var url = (typeof action === 'string') ? $.trim(action) : '';
if (url) {
// clean url (don't include hash vaue)
url = (url.match(/^([^#]+)/)||[])[1];
@@ -63,7 +64,7 @@ $.fn.ajaxSubmit = function(options) {
options = $.extend(true, {
url: url,
- type: this.attr('method') || 'GET',
+ type: this[0].getAttribute('method') || 'GET', // IE7 massage (see issue 57)
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
}, options);
@@ -167,7 +168,7 @@ $.fn.ajaxSubmit = function(options) {
}
}
else {
- $.ajax(options);
+ $.ajax(options);
}
// fire 'notify' event
@@ -189,15 +190,7 @@ $.fn.ajaxSubmit = function(options) {
var s = $.extend(true, {}, $.ajaxSettings, options);
s.context = s.context || s;
var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
- window[fn] = function() {
- var f = $io.data('form-plugin-onload');
- if (f) {
- f();
- window[fn] = undefined;
- try { delete window[fn]; } catch(e){}
- }
- }
- var $io = $('');
+ var $io = $('');
var io = $io[0];
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
@@ -236,7 +229,6 @@ $.fn.ajaxSubmit = function(options) {
return;
}
- var cbInvoked = false;
var timedOut = 0;
// add submitting element to data if we know it
@@ -293,7 +285,7 @@ $.fn.ajaxSubmit = function(options) {
// add iframe to doc and submit the form
$io.appendTo('body');
- $io.data('form-plugin-onload', cb);
+ io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
form.submit();
}
finally {
@@ -318,20 +310,19 @@ $.fn.ajaxSubmit = function(options) {
var data, doc, domCheckCount = 50;
function cb() {
- if (cbInvoked) {
+ doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
+ if (!doc || doc.location.href == s.iframeSrc) {
+ // response not received yet
return;
}
+ io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
- $io.removeData('form-plugin-onload');
-
var ok = true;
try {
if (timedOut) {
throw 'timeout';
}
- // extract the server response from the iframe
- doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
-
+
var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
log('isXml='+isXml);
if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
@@ -348,8 +339,7 @@ $.fn.ajaxSubmit = function(options) {
}
//log('response detected');
- cbInvoked = true;
- xhr.responseText = doc.documentElement ? doc.documentElement.innerHTML : null;
+ xhr.responseText = doc.body ? doc.body.innerHTML : doc.documentElement ? doc.documentElement.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
xhr.getResponseHeader = function(header){
var headers = {'content-type': s.dataType};
@@ -368,7 +358,7 @@ $.fn.ajaxSubmit = function(options) {
var pre = doc.getElementsByTagName('pre')[0];
var b = doc.getElementsByTagName('body')[0];
if (pre) {
- xhr.responseText = pre.innerHTML;
+ xhr.responseText = pre.textContent;
}
else if (b) {
xhr.responseText = b.innerHTML;
@@ -378,31 +368,35 @@ $.fn.ajaxSubmit = function(options) {
else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
xhr.responseXML = toXml(xhr.responseText);
}
- data = $.httpData(xhr, s.dataType);
+
+ data = httpData(xhr, s.dataType, s);
}
catch(e){
log('error caught:',e);
ok = false;
xhr.error = e;
- $.handleError(s, xhr, 'error', e);
+ s.error.call(s.context, xhr, 'error', e);
+ g && $.event.trigger("ajaxError", [xhr, s, e]);
+ }
+
+ if (xhr.aborted) {
+ log('upload aborted');
+ ok = false;
}
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (ok) {
s.success.call(s.context, data, 'success', xhr);
- if (g) {
- $.event.trigger("ajaxSuccess", [xhr, s]);
- }
- }
- if (g) {
- $.event.trigger("ajaxComplete", [xhr, s]);
+ g && $.event.trigger("ajaxSuccess", [xhr, s]);
}
+
+ g && $.event.trigger("ajaxComplete", [xhr, s]);
+
if (g && ! --$.active) {
$.event.trigger("ajaxStop");
}
- if (s.complete) {
- s.complete.call(s.context, xhr, ok ? 'success' : 'error');
- }
+
+ s.complete && s.complete.call(s.context, xhr, ok ? 'success' : 'error');
// clean up
setTimeout(function() {
@@ -412,7 +406,7 @@ $.fn.ajaxSubmit = function(options) {
}, 100);
}
- function toXml(s, doc) {
+ var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
if (window.ActiveXObject) {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
@@ -421,8 +415,32 @@ $.fn.ajaxSubmit = function(options) {
else {
doc = (new DOMParser()).parseFromString(s, 'text/xml');
}
- return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
- }
+ return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
+ };
+ var parseJSON = $.parseJSON || function(s) {
+ return window['eval']('(' + s + ')');
+ };
+
+ var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4
+ var ct = xhr.getResponseHeader('content-type') || '',
+ xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if (xml && data.documentElement.nodeName === 'parsererror') {
+ $.error && $.error('parsererror');
+ }
+ if (s && s.dataFilter) {
+ data = s.dataFilter(data, type);
+ }
+ if (typeof data === 'string') {
+ if (type === 'json' || !type && ct.indexOf('json') >= 0) {
+ data = parseJSON(data);
+ } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
+ $.globalEval(data);
+ }
+ }
+ return data;
+ };
}
};
diff --git a/js/jquery.form.min.js b/js/jquery.form.min.js
index 04c26a6ece..7ecc4ca923 100644
--- a/js/jquery.form.min.js
+++ b/js/jquery.form.min.js
@@ -1,6 +1,6 @@
/*
* jQuery Form Plugin
- * version: 2.49 (18-OCT-2010)
+ * version: 2.63 (29-JAN-2011)
* @requires jQuery v1.3.2 or later
*
* Examples and documentation at: http://malsup.com/jquery/form/
@@ -8,4 +8,4 @@
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
-(function(b){b.fn.ajaxSubmit=function(s){if(!this.length){a("ajaxSubmit: skipping submit process - no element selected");return this}if(typeof s=="function"){s={success:s}}var d=b.trim(this.attr("action"));if(d){d=(d.match(/^([^#]+)/)||[])[1]}d=d||window.location.href||"";s=b.extend(true,{url:d,type:this.attr("method")||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},s);var t={};this.trigger("form-pre-serialize",[this,s,t]);if(t.veto){a("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(s.beforeSerialize&&s.beforeSerialize(this,s)===false){a("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var f,o,l=this.formToArray(s.semantic);if(s.data){s.extraData=s.data;for(f in s.data){if(s.data[f] instanceof Array){for(var h in s.data[f]){l.push({name:f,value:s.data[f][h]})}}else{o=s.data[f];o=b.isFunction(o)?o():o;l.push({name:f,value:o})}}}if(s.beforeSubmit&&s.beforeSubmit(l,this,s)===false){a("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[l,this,s,t]);if(t.veto){a("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var c=b.param(l);if(s.type.toUpperCase()=="GET"){s.url+=(s.url.indexOf("?")>=0?"&":"?")+c;s.data=null}else{s.data=c}var r=this,j=[];if(s.resetForm){j.push(function(){r.resetForm()})}if(s.clearForm){j.push(function(){r.clearForm()})}if(!s.dataType&&s.target){var p=s.success||function(){};j.push(function(n){var k=s.replaceTarget?"replaceWith":"html";b(s.target)[k](n).each(p,arguments)})}else{if(s.success){j.push(s.success)}}s.success=function(v,n,w){var u=s.context||s;for(var q=0,k=j.length;q0;var e="multipart/form-data";var i=(r.attr("enctype")==e||r.attr("encoding")==e);if(s.iframe!==false&&(g||s.iframe||i)){if(s.closeKeepAlive){b.get(s.closeKeepAlive,m)}else{m()}}else{b.ajax(s)}this.trigger("form-submit-notify",[this,s]);return this;function m(){var k=r[0];if(b(":input[name=submit],:input[id=submit]",k).length){alert('Error: Form elements must not have name or id of "submit".');return}var y=b.extend(true,{},b.ajaxSettings,s);y.context=y.context||y;var B="jqFormIO"+(new Date().getTime()),w="_"+B;window[w]=function(){var n=q.data("form-plugin-onload");if(n){n();window[w]=undefined;try{delete window[w]}catch(K){}}};var q=b('');var x=q[0];q.css({position:"absolute",top:"-1000px",left:"-1000px"});var u={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;q.attr("src",y.iframeSrc)}};var G=y.global;if(G&&!b.active++){b.event.trigger("ajaxStart")}if(G){b.event.trigger("ajaxSend",[u,y])}if(y.beforeSend&&y.beforeSend.call(y.context,u,y)===false){if(y.global){b.active--}return}if(u.aborted){return}var C=false;var F=0;var v=k.clk;if(v){var D=v.name;if(D&&!v.disabled){y.extraData=y.extraData||{};y.extraData[D]=v.value;if(v.type=="image"){y.extraData[D+".x"]=k.clk_x;y.extraData[D+".y"]=k.clk_y}}}function E(){var M=r.attr("target"),K=r.attr("action");k.setAttribute("target",B);if(k.getAttribute("method")!="POST"){k.setAttribute("method","POST")}if(k.getAttribute("action")!=y.url){k.setAttribute("action",y.url)}if(!y.skipEncodingOverride){r.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(y.timeout){setTimeout(function(){F=true;A()},y.timeout)}var L=[];try{if(y.extraData){for(var N in y.extraData){L.push(b('').appendTo(k)[0])}}q.appendTo("body");q.data("form-plugin-onload",A);k.submit()}finally{k.setAttribute("action",K);if(M){k.setAttribute("target",M)}else{r.removeAttr("target")}b(L).remove()}}if(y.forceSync){E()}else{setTimeout(E,10)}var I,J,H=50;function A(){if(C){return}q.removeData("form-plugin-onload");var L=true;try{if(F){throw"timeout"}J=x.contentWindow?x.contentWindow.document:x.contentDocument?x.contentDocument:x.document;var P=y.dataType=="xml"||J.XMLDocument||b.isXMLDoc(J);a("isXml="+P);if(!P&&window.opera&&(J.body==null||J.body.innerHTML=="")){if(--H){a("requeing onLoad callback, DOM not available");setTimeout(A,250);return}}C=true;u.responseText=J.documentElement?J.documentElement.innerHTML:null;u.responseXML=J.XMLDocument?J.XMLDocument:J;u.getResponseHeader=function(R){var Q={"content-type":y.dataType};return Q[R]};var O=/(json|script)/.test(y.dataType);if(O||y.textarea){var K=J.getElementsByTagName("textarea")[0];if(K){u.responseText=K.value}else{if(O){var N=J.getElementsByTagName("pre")[0];var n=J.getElementsByTagName("body")[0];if(N){u.responseText=N.innerHTML}else{if(n){u.responseText=n.innerHTML}}}}}else{if(y.dataType=="xml"&&!u.responseXML&&u.responseText!=null){u.responseXML=z(u.responseText)}}I=b.httpData(u,y.dataType)}catch(M){a("error caught:",M);L=false;u.error=M;b.handleError(y,u,"error",M)}if(L){y.success.call(y.context,I,"success",u);if(G){b.event.trigger("ajaxSuccess",[u,y])}}if(G){b.event.trigger("ajaxComplete",[u,y])}if(G&&!--b.active){b.event.trigger("ajaxStop")}if(y.complete){y.complete.call(y.context,u,L?"success":"error")}setTimeout(function(){q.removeData("form-plugin-onload");q.remove();u.responseXML=null},100)}function z(n,K){if(window.ActiveXObject){K=new ActiveXObject("Microsoft.XMLDOM");K.async="false";K.loadXML(n)}else{K=(new DOMParser()).parseFromString(n,"text/xml")}return(K&&K.documentElement&&K.documentElement.tagName!="parsererror")?K:null}}};b.fn.ajaxForm=function(c){if(this.length===0){var d={s:this.selector,c:this.context};if(!b.isReady&&d.s){a("DOM not ready, queuing ajaxForm");b(function(){b(d.s,d.c).ajaxForm(c)});return this}a("terminating; zero elements found by selector"+(b.isReady?"":" (DOM not ready)"));return this}return this.ajaxFormUnbind().bind("submit.form-plugin",function(f){if(!f.isDefaultPrevented()){f.preventDefault();b(this).ajaxSubmit(c)}}).bind("click.form-plugin",function(j){var i=j.target;var g=b(i);if(!(g.is(":submit,input:image"))){var f=g.closest(":submit");if(f.length==0){return}i=f[0]}var h=this;h.clk=i;if(i.type=="image"){if(j.offsetX!=undefined){h.clk_x=j.offsetX;h.clk_y=j.offsetY}else{if(typeof b.fn.offset=="function"){var k=g.offset();h.clk_x=j.pageX-k.left;h.clk_y=j.pageY-k.top}else{h.clk_x=j.pageX-i.offsetLeft;h.clk_y=j.pageY-i.offsetTop}}}setTimeout(function(){h.clk=h.clk_x=h.clk_y=null},100)})};b.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};b.fn.formToArray=function(q){var p=[];if(this.length===0){return p}var d=this[0];var g=q?d.getElementsByTagName("*"):d.elements;if(!g){return p}var k,h,f,r,e,m,c;for(k=0,m=g.length;k=0?"&":"?")+c;t.data=null}else{t.data=c}var s=this,l=[];if(t.resetForm){l.push(function(){s.resetForm()})}if(t.clearForm){l.push(function(){s.clearForm()})}if(!t.dataType&&t.target){var r=t.success||function(){};l.push(function(n){var k=t.replaceTarget?"replaceWith":"html";b(t.target)[k](n).each(r,arguments)})}else{if(t.success){l.push(t.success)}}t.success=function(w,n,x){var v=t.context||t;for(var q=0,k=l.length;q0;var e="multipart/form-data";var j=(s.attr("enctype")==e||s.attr("encoding")==e);if(t.iframe!==false&&(g||t.iframe||j)){if(t.closeKeepAlive){b.get(t.closeKeepAlive,o)}else{o()}}else{b.ajax(t)}this.trigger("form-submit-notify",[this,t]);return this;function o(){var v=s[0];if(b(":input[name=submit],:input[id=submit]",v).length){alert('Error: Form elements must not have name or id of "submit".');return}var B=b.extend(true,{},b.ajaxSettings,t);B.context=B.context||B;var E="jqFormIO"+(new Date().getTime()),z="_"+E;var w=b('');var A=w[0];w.css({position:"absolute",top:"-1000px",left:"-1000px"});var x={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;w.attr("src",B.iframeSrc)}};var I=B.global;if(I&&!b.active++){b.event.trigger("ajaxStart")}if(I){b.event.trigger("ajaxSend",[x,B])}if(B.beforeSend&&B.beforeSend.call(B.context,x,B)===false){if(B.global){b.active--}return}if(x.aborted){return}var H=0;var y=v.clk;if(y){var F=y.name;if(F&&!y.disabled){B.extraData=B.extraData||{};B.extraData[F]=y.value;if(y.type=="image"){B.extraData[F+".x"]=v.clk_x;B.extraData[F+".y"]=v.clk_y}}}function G(){var O=s.attr("target"),M=s.attr("action");v.setAttribute("target",E);if(v.getAttribute("method")!="POST"){v.setAttribute("method","POST")}if(v.getAttribute("action")!=B.url){v.setAttribute("action",B.url)}if(!B.skipEncodingOverride){s.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(B.timeout){setTimeout(function(){H=true;D()},B.timeout)}var N=[];try{if(B.extraData){for(var P in B.extraData){N.push(b('').appendTo(v)[0])}}w.appendTo("body");A.attachEvent?A.attachEvent("onload",D):A.addEventListener("load",D,false);v.submit()}finally{v.setAttribute("action",M);if(O){v.setAttribute("target",O)}else{s.removeAttr("target")}b(N).remove()}}if(B.forceSync){G()}else{setTimeout(G,10)}var K,L,J=50;function D(){L=A.contentWindow?A.contentWindow.document:A.contentDocument?A.contentDocument:A.document;if(!L||L.location.href==B.iframeSrc){return}A.detachEvent?A.detachEvent("onload",D):A.removeEventListener("load",D,false);var N=true;try{if(H){throw"timeout"}var R=B.dataType=="xml"||L.XMLDocument||b.isXMLDoc(L);a("isXml="+R);if(!R&&window.opera&&(L.body==null||L.body.innerHTML=="")){if(--J){a("requeing onLoad callback, DOM not available");setTimeout(D,250);return}}x.responseText=L.body?L.body.innerHTML:L.documentElement?L.documentElement.innerHTML:null;x.responseXML=L.XMLDocument?L.XMLDocument:L;x.getResponseHeader=function(T){var S={"content-type":B.dataType};return S[T]};var Q=/(json|script)/.test(B.dataType);if(Q||B.textarea){var M=L.getElementsByTagName("textarea")[0];if(M){x.responseText=M.value}else{if(Q){var P=L.getElementsByTagName("pre")[0];var n=L.getElementsByTagName("body")[0];if(P){x.responseText=P.textContent}else{if(n){x.responseText=n.innerHTML}}}}}else{if(B.dataType=="xml"&&!x.responseXML&&x.responseText!=null){x.responseXML=C(x.responseText)}}K=k(x,B.dataType,B)}catch(O){a("error caught:",O);N=false;x.error=O;B.error.call(B.context,x,"error",O);I&&b.event.trigger("ajaxError",[x,B,O])}if(x.aborted){a("upload aborted");N=false}if(N){B.success.call(B.context,K,"success",x);I&&b.event.trigger("ajaxSuccess",[x,B])}I&&b.event.trigger("ajaxComplete",[x,B]);if(I&&!--b.active){b.event.trigger("ajaxStop")}B.complete&&B.complete.call(B.context,x,N?"success":"error");setTimeout(function(){w.removeData("form-plugin-onload");w.remove();x.responseXML=null},100)}var C=b.parseXML||function(n,M){if(window.ActiveXObject){M=new ActiveXObject("Microsoft.XMLDOM");M.async="false";M.loadXML(n)}else{M=(new DOMParser()).parseFromString(n,"text/xml")}return(M&&M.documentElement&&M.documentElement.nodeName!="parsererror")?M:null};var q=b.parseJSON||function(n){return window["eval"]("("+n+")")};var k=function(Q,O,N){var M=Q.getResponseHeader("content-type")||"",n=O==="xml"||!O&&M.indexOf("xml")>=0,P=n?Q.responseXML:Q.responseText;if(n&&P.documentElement.nodeName==="parsererror"){b.error&&b.error("parsererror")}if(N&&N.dataFilter){P=N.dataFilter(P,O)}if(typeof P==="string"){if(O==="json"||!O&&M.indexOf("json")>=0){P=q(P)}else{if(O==="script"||!O&&M.indexOf("javascript")>=0){b.globalEval(P)}}}return P}}};b.fn.ajaxForm=function(c){if(this.length===0){var d={s:this.selector,c:this.context};if(!b.isReady&&d.s){a("DOM not ready, queuing ajaxForm");b(function(){b(d.s,d.c).ajaxForm(c)});return this}a("terminating; zero elements found by selector"+(b.isReady?"":" (DOM not ready)"));return this}return this.ajaxFormUnbind().bind("submit.form-plugin",function(f){if(!f.isDefaultPrevented()){f.preventDefault();b(this).ajaxSubmit(c)}}).bind("click.form-plugin",function(j){var i=j.target;var g=b(i);if(!(g.is(":submit,input:image"))){var f=g.closest(":submit");if(f.length==0){return}i=f[0]}var h=this;h.clk=i;if(i.type=="image"){if(j.offsetX!=undefined){h.clk_x=j.offsetX;h.clk_y=j.offsetY}else{if(typeof b.fn.offset=="function"){var k=g.offset();h.clk_x=j.pageX-k.left;h.clk_y=j.pageY-k.top}else{h.clk_x=j.pageX-i.offsetLeft;h.clk_y=j.pageY-i.offsetTop}}}setTimeout(function(){h.clk=h.clk_x=h.clk_y=null},100)})};b.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};b.fn.formToArray=function(q){var p=[];if(this.length===0){return p}var d=this[0];var g=q?d.getElementsByTagName("*"):d.elements;if(!g){return p}var k,h,f,r,e,m,c;for(k=0,m=g.length;k