/*! * jQuery Form Plugin * version: 3.09 (16-APR-2012) * @requires jQuery v1.3.2 or later * * Examples and documentation at: http://malsup.com/jquery/form/ * Project repository: https://github.com/malsup/form * Dual licensed under the MIT and GPL licenses: * http://malsup.github.com/mit-license.txt * http://malsup.github.com/gpl-license-v2.txt */ (function(b){function s(a){var f=a.data;a.isDefaultPrevented()||(a.preventDefault(),b(this).ajaxSubmit(f))}function v(a){var f=a.target,g=b(f);if(!g.is(":submit,input:image")){f=g.closest(":submit");if(0===f.length)return;f=f[0]}var d=this;d.clk=f;"image"==f.type&&(void 0!==a.offsetX?(d.clk_x=a.offsetX,d.clk_y=a.offsetY):"function"==typeof b.fn.offset?(g=g.offset(),d.clk_x=a.pageX-g.left,d.clk_y=a.pageY-g.top):(d.clk_x=a.pageX-f.offsetLeft,d.clk_y=a.pageY-f.offsetTop));setTimeout(function(){d.clk= d.clk_x=d.clk_y=null},100)}function p(){if(b.fn.ajaxSubmit.debug){var a="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(a):window.opera&&window.opera.postError&&window.opera.postError(a)}}var u,w;u=void 0!==b("").get(0).files;w=void 0!==window.FormData;b.fn.ajaxSubmit=function(a){function f(d){for(var c=new FormData,f=0;f').attr("value",e.extraData[m]).appendTo(i)[0]);e.iframeTarget||(t.appendTo("body"),o.attachEvent?o.attachEvent("onload",g):o.addEventListener("load",g,!1));setTimeout(a,15);i.submit()}finally{i.setAttribute("action",h),c?i.setAttribute("target",c):k.removeAttr("target"),b(j).remove()}}function g(a){if(!h.aborted&& !z){try{q=o.contentWindow?o.contentWindow.document:o.contentDocument?o.contentDocument:o.document}catch(c){p("cannot access response document: ",c),a=u}if(a===v&&h)h.abort("timeout");else if(a==u&&h)h.abort("server abort");else if(q&&q.location.href!=e.iframeSrc||s){o.detachEvent?o.detachEvent("onload",g):o.removeEventListener("load",g,!1);var a="success",d;try{if(s)throw"timeout";var f="xml"==e.dataType||q.XMLDocument||b.isXMLDoc(q);p("isXml="+f);if(!f&&(window.opera&&(null===q.body||!q.body.innerHTML))&& --B){p("requeing onLoad callback, DOM not available");setTimeout(g,250);return}var i=q.body?q.body:q.documentElement;h.responseText=i?i.innerHTML:null;h.responseXML=q.XMLDocument?q.XMLDocument:q;f&&(e.dataType="xml");h.getResponseHeader=function(a){return{"content-type":e.dataType}[a]};i&&(h.status=Number(i.getAttribute("status"))||h.status,h.statusText=i.getAttribute("statusText")||h.statusText);var j=(e.dataType||"").toLowerCase(),k=/(json|script|text)/.test(j);if(k||e.textarea){var l=q.getElementsByTagName("textarea")[0]; if(l)h.responseText=l.value,h.status=Number(l.getAttribute("status"))||h.status,h.statusText=l.getAttribute("statusText")||h.statusText;else if(k){var n=q.getElementsByTagName("pre")[0],r=q.getElementsByTagName("body")[0];n?h.responseText=n.textContent?n.textContent:n.innerText:r&&(h.responseText=r.textContent?r.textContent:r.innerText)}}else"xml"==j&&(!h.responseXML&&h.responseText)&&(h.responseXML=C(h.responseText));try{w=D(h,j,e)}catch(A){a="parsererror",h.error=d=A||a}}catch(y){p("error caught: ", y),a="error",h.error=d=y||a}h.aborted&&(p("upload aborted"),a=null);h.status&&(a=200<=h.status&&300>h.status||304===h.status?"success":"error");"success"===a?(e.success&&e.success.call(e.context,w,"success",h),m&&b.event.trigger("ajaxSuccess",[h,e])):a&&(void 0===d&&(d=h.statusText),e.error&&e.error.call(e.context,h,a,d),m&&b.event.trigger("ajaxError",[h,e,d]));m&&b.event.trigger("ajaxComplete",[h,e]);m&&!--b.active&&b.event.trigger("ajaxStop");e.complete&&e.complete.call(e.context,h,a);z=!0;e.timeout&& clearTimeout(x);setTimeout(function(){e.iframeTarget||t.remove();h.responseXML=null},100)}}}var i=k[0],j,e,m,n,t,o,h,r,s,x;r=!!b.fn.prop;if(b(":input[name=submit],:input[id=submit]",i).length)alert('Error: Form elements must not have name or id of "submit".');else{if(c)for(j=0;j'),t.css({position:"absolute",top:"-1000px",left:"-1000px"}));o=t[0];h={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(a){var c=a==="timeout"?"timeout":"aborted";p("aborting upload... "+c);this.aborted=1;t.attr("src",e.iframeSrc);h.error=c;e.error&&e.error.call(e.context,h,c,a);m&&b.event.trigger("ajaxError", [h,e,c]);e.complete&&e.complete.call(e.context,h,c)}};(m=e.global)&&0===b.active++&&b.event.trigger("ajaxStart");m&&b.event.trigger("ajaxSend",[h,e]);if(e.beforeSend&&!1===e.beforeSend.call(e.context,h,e))e.global&&b.active--;else if(!h.aborted){if(r=i.clk)if((c=r.name)&&!r.disabled)e.extraData=e.extraData||{},e.extraData[c]=r.value,"image"==r.type&&(e.extraData[c+".x"]=i.clk_x,e.extraData[c+".y"]=i.clk_y);var v=1,u=2;r=b("meta[name=csrf-token]").attr("content");if((c=b("meta[name=csrf-param]").attr("content"))&& r)e.extraData=e.extraData||{},e.extraData[c]=r;e.forceSync?f():setTimeout(f,10);var w,q,B=50,z,C=b.parseXML||function(a,b){if(window.ActiveXObject){b=new ActiveXObject("Microsoft.XMLDOM");b.async="false";b.loadXML(a)}else b=(new DOMParser).parseFromString(a,"text/xml");return b&&b.documentElement&&b.documentElement.nodeName!="parsererror"?b:null},E=b.parseJSON||function(a){return window.eval("("+a+")")},D=function(a,c,d){var e=a.getResponseHeader("content-type")||"",f=c==="xml"||!c&&e.indexOf("xml")>= 0,a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&b.error&&b.error("parsererror");d&&d.dataFilter&&(a=d.dataFilter(a,c));typeof a==="string"&&(c==="json"||!c&&e.indexOf("json")>=0?a=E(a):(c==="script"||!c&&e.indexOf("javascript")>=0)&&b.globalEval(a));return a}}}}if(!this.length)return p("ajaxSubmit: skipping submit process - no element selected"),this;var d,c,k=this;"function"==typeof a&&(a={success:a});d=this.attr("method");c=this.attr("action");(c=(c="string"=== typeof c?b.trim(c):"")||window.location.href||"")&&(c=(c.match(/^([^#]+)/)||[])[1]);a=b.extend(!0,{url:c,success:b.ajaxSettings.success,type:d||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},a);c={};this.trigger("form-pre-serialize",[this,a,c]);if(c.veto)return p("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(a.beforeSerialize&&!1===a.beforeSerialize(this,a))return p("ajaxSubmit: submit aborted via beforeSerialize callback"),this;var m= a.traditional;void 0===m&&(m=b.ajaxSettings.traditional);var l=[],i,j=this.formToArray(a.semantic,l);a.data&&(a.extraData=a.data,i=b.param(a.data,m));if(a.beforeSubmit&&!1===a.beforeSubmit(j,this,a))return p("ajaxSubmit: submit aborted via beforeSubmit callback"),this;this.trigger("form-submit-validate",[j,this,a,c]);if(c.veto)return p("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;c=b.param(j,m);i&&(c=c?c+"&"+i:i);"GET"==a.type.toUpperCase()?(a.url+=(0<=a.url.indexOf("?")?"&": "?")+c,a.data=null):a.data=c;var n=[];a.resetForm&&n.push(function(){k.resetForm()});a.clearForm&&n.push(function(){k.clearForm(a.includeHidden)});if(!a.dataType&&a.target){var s=a.success||function(){};n.push(function(c){var d=a.replaceTarget?"replaceWith":"html";b(a.target)[d](c).each(s,arguments)})}else a.success&&n.push(a.success);a.success=function(b,c,d){for(var f=a.context||a,g=0,e=n.length;gk)return null;for(var g=[],c=a.options,m=(d="select-one"==d)?k+1:c.length,k=d?k:0;k