/*! * jQuery Form Plugin * version: 3.25.0-2013.01.18 * @requires jQuery v1.5 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(e){var c={};c.fileapi=e("").get(0).files!==undefined;c.formdata=window.FormData!==undefined;e.fn.ajaxSubmit=function(h){if(!this.length){d("ajaxSubmit: skipping submit process - no element selected");return this}var g,y,j,m=this;if(typeof h=="function"){h={success:h}}g=this.attr("method");y=this.attr("action");j=(typeof y==="string")?e.trim(y):"";j=j||window.location.href||"";if(j){j=(j.match(/^([^#]+)/)||[])[1]}h=e.extend(true,{url:j,success:e.ajaxSettings.success,type:g||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},h);var s={};this.trigger("form-pre-serialize",[this,h,s]);if(s.veto){d("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(h.beforeSerialize&&h.beforeSerialize(this,h)===false){d("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var l=h.traditional;if(l===undefined){l=e.ajaxSettings.traditional}var p=[];var B,C=this.formToArray(h.semantic,p);if(h.data){h.extraData=h.data;B=e.param(h.data,l)}if(h.beforeSubmit&&h.beforeSubmit(C,this,h)===false){d("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[C,this,h,s]);if(s.veto){d("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var w=e.param(C,l);if(B){w=(w?(w+"&"+B):B)}if(h.type.toUpperCase()=="GET"){h.url+=(h.url.indexOf("?")>=0?"&":"?")+w;h.data=null}else{h.data=w}var E=[];if(h.resetForm){E.push(function(){m.resetForm()})}if(h.clearForm){E.push(function(){m.clearForm(h.includeHidden)})}if(!h.dataType&&h.target){var i=h.success||function(){};E.push(function(q){var k=h.replaceTarget?"replaceWith":"html";e(h.target)[k](q).each(i,arguments)})}else{if(h.success){E.push(h.success)}}h.success=function(H,q,I){var G=h.context||this;for(var F=0,k=E.length;F0;var z="multipart/form-data";var v=(m.attr("enctype")==z||m.attr("encoding")==z);var u=c.fileapi&&c.formdata;d("fileAPI :"+u);var o=(n||v)&&!u;var t;if(h.iframe!==false&&(h.iframe||o)){if(h.closeKeepAlive){e.get(h.closeKeepAlive,function(){t=D(C)})}else{t=D(C)}}else{if((n||v)&&u){t=r(C)}else{t=e.ajax(h)}}m.removeData("jqxhr").data("jqxhr",t);for(var x=0;x');K.css({position:"absolute",top:"-1000px",left:"-1000px"})}O=K[0];M={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(ah){var ai=(ah==="timeout"?"timeout":"aborted");d("aborting upload... "+ai);this.aborted=1;try{if(O.contentWindow.document.execCommand){O.contentWindow.document.execCommand("Stop")}}catch(aj){}K.attr("src",T.iframeSrc);M.error=ai;if(T.error){T.error.call(T.context,M,ai,ah)}if(ab){e.event.trigger("ajaxError",[M,T,ai])}if(T.complete){T.complete.call(T.context,M,ai)}}};ab=T.global;if(ab&&0===e.active++){e.event.trigger("ajaxStart")}if(ab){e.event.trigger("ajaxSend",[M,T])}if(T.beforeSend&&T.beforeSend.call(T.context,M,T)===false){if(T.global){e.active--}ag.reject();return ag}if(M.aborted){ag.reject();return ag}N=I.clk;if(N){X=N.name;if(X&&!N.disabled){T.extraData=T.extraData||{};T.extraData[X]=N.value;if(N.type=="image"){T.extraData[X+".x"]=I.clk_x;T.extraData[X+".y"]=I.clk_y}}}var S=1;var P=2;function Q(ai){var ah=ai.contentWindow?ai.contentWindow.document:ai.contentDocument?ai.contentDocument:ai.document;return ah}var G=e("meta[name=csrf-token]").attr("content");var F=e("meta[name=csrf-param]").attr("content");if(F&&G){T.extraData=T.extraData||{};T.extraData[F]=G}function Y(){var aj=m.attr("target"),ah=m.attr("action");I.setAttribute("target",W);if(!g){I.setAttribute("method","POST")}if(ah!=T.url){I.setAttribute("action",T.url)}if(!T.skipEncodingOverride&&(!g||/post/i.test(g))){m.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(T.timeout){R=setTimeout(function(){aa=true;V(S)},T.timeout)}function ak(){try{var am=Q(O).readyState;d("state = "+am);if(am&&am.toLowerCase()=="uninitialized"){setTimeout(ak,50)}}catch(an){d("Server abort: ",an," (",an.name,")");V(P);if(R){clearTimeout(R)}R=undefined}}var ai=[];try{if(T.extraData){for(var al in T.extraData){if(T.extraData.hasOwnProperty(al)){if(e.isPlainObject(T.extraData[al])&&T.extraData[al].hasOwnProperty("name")&&T.extraData[al].hasOwnProperty("value")){ai.push(e('').val(T.extraData[al].value).appendTo(I)[0])}else{ai.push(e('').val(T.extraData[al]).appendTo(I)[0])}}}}if(!T.iframeTarget){K.appendTo("body");if(O.attachEvent){O.attachEvent("onload",V)}else{O.addEventListener("load",V,false)}}setTimeout(ak,15);I.submit()}finally{I.setAttribute("action",ah);if(aj){I.setAttribute("target",aj)}else{m.removeAttr("target")}e(ai).remove()}}if(T.forceSync){Y()}else{setTimeout(Y,10)}var ae,af,ac=50,J;function V(am){if(M.aborted||J){return}try{af=Q(O)}catch(ap){d("cannot access response document: ",ap);am=P}if(am===S&&M){M.abort("timeout");ag.reject(M,"timeout");return}else{if(am==P&&M){M.abort("server abort");ag.reject(M,"error","server abort");return}}if(!af||af.location.href==T.iframeSrc){if(!aa){return}}if(O.detachEvent){O.detachEvent("onload",V)}else{O.removeEventListener("load",V,false)}var ak="success",ao;try{if(aa){throw"timeout"}var aj=T.dataType=="xml"||af.XMLDocument||e.isXMLDoc(af);d("isXml="+aj);if(!aj&&window.opera&&(af.body===null||!af.body.innerHTML)){if(--ac){d("requeing onLoad callback, DOM not available");setTimeout(V,250);return}}var aq=af.body?af.body:af.documentElement;M.responseText=aq?aq.innerHTML:null;M.responseXML=af.XMLDocument?af.XMLDocument:af;if(aj){T.dataType="xml"}M.getResponseHeader=function(au){var at={"content-type":T.dataType};return at[au]};if(aq){M.status=Number(aq.getAttribute("status"))||M.status;M.statusText=aq.getAttribute("statusText")||M.statusText}var ah=(T.dataType||"").toLowerCase();var an=/(json|script|text)/.test(ah);if(an||T.textarea){var al=af.getElementsByTagName("textarea")[0];if(al){M.responseText=al.value;M.status=Number(al.getAttribute("status"))||M.status;M.statusText=al.getAttribute("statusText")||M.statusText}else{if(an){var ai=af.getElementsByTagName("pre")[0];var ar=af.getElementsByTagName("body")[0];if(ai){M.responseText=ai.textContent?ai.textContent:ai.innerText}else{if(ar){M.responseText=ar.textContent?ar.textContent:ar.innerText}}}}}else{if(ah=="xml"&&!M.responseXML&&M.responseText){M.responseXML=U(M.responseText)}}try{ae=k(M,ah,T)}catch(am){ak="parsererror";M.error=ao=(am||ak)}}catch(am){d("error caught: ",am);ak="error";M.error=ao=(am||ak)}if(M.aborted){d("upload aborted");ak=null}if(M.status){ak=(M.status>=200&&M.status<300||M.status===304)?"success":"error"}if(ak==="success"){if(T.success){T.success.call(T.context,ae,"success",M)}ag.resolve(M.responseText,"success",M);if(ab){e.event.trigger("ajaxSuccess",[M,T])}}else{if(ak){if(ao===undefined){ao=M.statusText}if(T.error){T.error.call(T.context,M,ak,ao)}ag.reject(M,"error",ao);if(ab){e.event.trigger("ajaxError",[M,T,ao])}}}if(ab){e.event.trigger("ajaxComplete",[M,T])}if(ab&&!--e.active){e.event.trigger("ajaxStop")}if(T.complete){T.complete.call(T.context,M,ak)}J=true;if(T.timeout){clearTimeout(R)}setTimeout(function(){if(!T.iframeTarget){K.remove()}M.responseXML=null},100)}var U=e.parseXML||function(ah,ai){if(window.ActiveXObject){ai=new ActiveXObject("Microsoft.XMLDOM");ai.async="false";ai.loadXML(ah)}else{ai=(new DOMParser()).parseFromString(ah,"text/xml")}return(ai&&ai.documentElement&&ai.documentElement.nodeName!="parsererror")?ai:null};var q=e.parseJSON||function(ah){return window["eval"]("("+ah+")")};var k=function(am,ak,aj){var ai=am.getResponseHeader("content-type")||"",ah=ak==="xml"||!ak&&ai.indexOf("xml")>=0,al=ah?am.responseXML:am.responseText;if(ah&&al.documentElement.nodeName==="parsererror"){if(e.error){e.error("parsererror")}}if(aj&&aj.dataFilter){al=aj.dataFilter(al,ak)}if(typeof al==="string"){if(ak==="json"||!ak&&ai.indexOf("json")>=0){al=q(al)}else{if(ak==="script"||!ak&&ai.indexOf("javascript")>=0){e.globalEval(al)}}}return al};return ag}};e.fn.ajaxForm=function(f){f=f||{};f.delegation=f.delegation&&e.isFunction(e.fn.on);if(!f.delegation&&this.length===0){var g={s:this.selector,c:this.context};if(!e.isReady&&g.s){d("DOM not ready, queuing ajaxForm");e(function(){e(g.s,g.c).ajaxForm(f)});return this}d("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)"));return this}if(f.delegation){e(document).off("submit.form-plugin",this.selector,b).off("click.form-plugin",this.selector,a).on("submit.form-plugin",this.selector,f,b).on("click.form-plugin",this.selector,f,a);return this}return this.ajaxFormUnbind().bind("submit.form-plugin",f,b).bind("click.form-plugin",f,a)};function b(g){var f=g.data;if(!g.isDefaultPrevented()){g.preventDefault();e(this).ajaxSubmit(f)}}function a(j){var i=j.target;var g=e(i);if(!(g.is("[type=submit],[type=image]"))){var f=g.closest("[type=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 e.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)}e.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};e.fn.formToArray=function(w,f){var u=[];if(this.length===0){return u}var k=this[0];var o=w?k.getElementsByTagName("*"):k.elements;if(!o){return u}var q,p,m,x,l,s,h;for(q=0,s=o.length;q