!function(n){"use strict";"function"==typeof define&&define.amd?define(["jquery"],n):n("undefined"!=typeof jQuery?jQuery:window.Zepto)}(function(n){"use strict";function r(t){var i=t.data;t.isDefaultPrevented()||(t.preventDefault(),n(t.target).ajaxSubmit(i))}function u(t){var r=t.target,u=n(r),f,i,e;if(!u.is("[type=submit],[type=image]")){if(f=u.closest("[type=submit]"),0===f.length)return;r=f[0]}i=this;(i.clk=r,"image"==r.type)&&(void 0!==t.offsetX?(i.clk_x=t.offsetX,i.clk_y=t.offsetY):"function"==typeof n.fn.offset?(e=u.offset(),i.clk_x=t.pageX-e.left,i.clk_y=t.pageY-e.top):(i.clk_x=t.pageX-r.offsetLeft,i.clk_y=t.pageY-r.offsetTop));setTimeout(function(){i.clk=i.clk_x=i.clk_y=null},100)}function t(){if(n.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(t):window.opera&&window.opera.postError&&window.opera.postError(t)}}var i={},f;i.fileapi=void 0!==n("<input type='file'/>").get(0).files;i.formdata=void 0!==window.FormData;f=!!n.fn.prop;n.fn.attr2=function(){if(!f)return this.attr.apply(this,arguments);var n=this.prop.apply(this,arguments);return n&&n.jquery||"string"==typeof n?n:this.attr.apply(this,arguments)};n.fn.ajaxSubmit=function(r){function et(t){for(var f,u=n.param(t,r.traditional).split("&"),o=u.length,e=[],i=0;o>i;i++)u[i]=u[i].replace(/\+/g," "),f=u[i].split("="),e.push([decodeURIComponent(f[0]),decodeURIComponent(f[1])]);return e}function ot(t){for(var f,u,s,o=new FormData,i=0;i<t.length;i++)o.append(t[i].name,t[i].value);if(r.extraData)for(f=et(r.extraData),i=0;i<f.length;i++)f[i]&&o.append(f[i][0],f[i][1]);return r.data=null,u=n.extend(!0,{},n.ajaxSettings,r,{contentType:!1,processData:!1,cache:!1,type:e||"POST"}),r.uploadProgress&&(u.xhr=function(){var t=n.ajaxSettings.xhr();return t.upload&&t.upload.addEventListener("progress",function(n){var t=0,i=n.loaded||n.position,u=n.total;n.lengthComputable&&(t=Math.ceil(i/u*100));r.uploadProgress(n,i,u,t)},!1),t}),u.data=null,s=u.beforeSend,u.beforeSend=function(n,t){t.data=r.formData?r.formData:o;s&&s.call(this,n,t)},n.ajax(u)}function d(i){function ut(n){var i=null;try{n.contentWindow&&(i=n.contentWindow.document)}catch(r){t("cannot get iframe.contentWindow document: "+r)}if(i)return i;try{i=n.contentDocument?n.contentDocument:n.document}catch(r){t("cannot get iframe.contentDocument: "+r);i=n.document}return i}function ft(){function f(){try{var n=ut(a).readyState;t("state = "+n);n&&"uninitialized"==n.toLowerCase()&&setTimeout(f,50)}catch(i){t("Server abort: ",i," (",i.name,")");b(rt);g&&clearTimeout(g);g=void 0}}var s=u.attr2("target"),h=u.attr2("action"),y=u.attr("enctype")||u.attr("encoding")||"multipart/form-data",r,i,c;l.setAttribute("target",d);(!e||/post/i.test(e))&&l.setAttribute("method","POST");h!=o.url&&l.setAttribute("action",o.url);o.skipEncodingOverride||e&&!/post/i.test(e)||u.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});o.timeout&&(g=setTimeout(function(){it=!0;b(et)},o.timeout));r=[];try{if(o.extraData)for(i in o.extraData)o.extraData.hasOwnProperty(i)&&r.push(n.isPlainObject(o.extraData[i])&&o.extraData[i].hasOwnProperty("name")&&o.extraData[i].hasOwnProperty("value")?n('<input type="hidden" name="'+o.extraData[i].name+'">').val(o.extraData[i].value).appendTo(l)[0]:n('<input type="hidden" name="'+i+'">').val(o.extraData[i]).appendTo(l)[0]);o.iframeTarget||v.appendTo("body");a.attachEvent?a.attachEvent("onload",b):a.addEventListener("load",b,!1);setTimeout(f,15);try{l.submit()}catch(p){c=document.createElement("form").submit;c.apply(l)}}finally{l.setAttribute("action",h);l.setAttribute("enctype",y);s?l.setAttribute("target",s):u.removeAttr("target");n(r).remove()}}function b(i){var u,r,w,f,k,d,e,c,l;if(!s.aborted&&!ct){if(h=ut(a),h||(t("cannot access response document"),i=rt),i===et&&s)return s.abort("timeout"),void y.reject(s,"timeout");if(i==rt&&s)return s.abort("server abort"),void y.reject(s,"error","server abort");if(h&&h.location.href!=o.iframeSrc||it){a.detachEvent?a.detachEvent("onload",b):a.removeEventListener("load",b,!1);r="success";try{if(it)throw"timeout";if(w="xml"==o.dataType||h.XMLDocument||n.isXMLDoc(h),t("isXml="+w),!w&&window.opera&&(null===h.body||!h.body.innerHTML)&&--lt)return t("requeing onLoad callback, DOM not available"),void setTimeout(b,250);f=h.body?h.body:h.documentElement;s.responseText=f?f.innerHTML:null;s.responseXML=h.XMLDocument?h.XMLDocument:h;w&&(o.dataType="xml");s.getResponseHeader=function(n){var t={"content-type":o.dataType};return t[n.toLowerCase()]};f&&(s.status=Number(f.getAttribute("status"))||s.status,s.statusText=f.getAttribute("statusText")||s.statusText);k=(o.dataType||"").toLowerCase();d=/(json|script|text)/.test(k);d||o.textarea?(e=h.getElementsByTagName("textarea")[0],e?(s.responseText=e.value,s.status=Number(e.getAttribute("status"))||s.status,s.statusText=e.getAttribute("statusText")||s.statusText):d&&(c=h.getElementsByTagName("pre")[0],l=h.getElementsByTagName("body")[0],c?s.responseText=c.textContent?c.textContent:c.innerText:l&&(s.responseText=l.textContent?l.textContent:l.innerText))):"xml"==k&&!s.responseXML&&s.responseText&&(s.responseXML=at(s.responseText));try{ht=yt(s,k,o)}catch(nt){r="parsererror";s.error=u=nt||r}}catch(nt){t("error caught: ",nt);r="error";s.error=u=nt||r}s.aborted&&(t("upload aborted"),r=null);s.status&&(r=s.status>=200&&s.status<300||304===s.status?"success":"error");"success"===r?(o.success&&o.success.call(o.context,ht,"success",s),y.resolve(s.responseText,"success",s),p&&n.event.trigger("ajaxSuccess",[s,o])):r&&(void 0===u&&(u=s.statusText),o.error&&o.error.call(o.context,s,r,u),y.reject(s,"error",u),p&&n.event.trigger("ajaxError",[s,o,u]));p&&n.event.trigger("ajaxComplete",[s,o]);p&&!--n.active&&n.event.trigger("ajaxStop");o.complete&&o.complete.call(o.context,s,r);ct=!0;o.timeout&&clearTimeout(g);setTimeout(function(){o.iframeTarget?v.attr("src",o.iframeSrc):v.remove();s.responseXML=null},100)}}}var tt,nt,o,p,d,v,a,s,k,w,it,g,l=u[0],y=n.Deferred();if(y.abort=function(n){s.abort(n)},i)for(nt=0;nt<c.length;nt++)tt=n(c[nt]),f?tt.prop("disabled",!1):tt.removeAttr("disabled");if(o=n.extend(!0,{},n.ajaxSettings,r),o.context=o.context||o,d="jqFormIO"+(new Date).getTime(),o.iframeTarget?(v=n(o.iframeTarget),w=v.attr2("name"),w?d=w:v.attr2("name",d)):(v=n('<iframe name="'+d+'" src="'+o.iframeSrc+'" />'),v.css({position:"absolute",top:"-1000px",left:"-1000px"})),a=v[0],s={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(i){var r="timeout"===i?"timeout":"aborted";t("aborting upload... "+r);this.aborted=1;try{a.contentWindow.document.execCommand&&a.contentWindow.document.execCommand("Stop")}catch(u){}v.attr("src",o.iframeSrc);s.error=r;o.error&&o.error.call(o.context,s,r,i);p&&n.event.trigger("ajaxError",[s,o,r]);o.complete&&o.complete.call(o.context,s,r)}},p=o.global,p&&0==n.active++&&n.event.trigger("ajaxStart"),p&&n.event.trigger("ajaxSend",[s,o]),o.beforeSend&&o.beforeSend.call(o.context,s,o)===!1)return o.global&&n.active--,y.reject(),y;if(s.aborted)return y.reject(),y;k=l.clk;k&&(w=k.name,w&&!k.disabled&&(o.extraData=o.extraData||{},o.extraData[w]=k.value,"image"==k.type&&(o.extraData[w+".x"]=l.clk_x,o.extraData[w+".y"]=l.clk_y)));var et=1,rt=2,ot=n("meta[name=csrf-token]").attr("content"),st=n("meta[name=csrf-param]").attr("content");st&&ot&&(o.extraData=o.extraData||{},o.extraData[st]=ot);o.forceSync?ft():setTimeout(ft,10);var ht,h,ct,lt=50,at=n.parseXML||function(n,t){return window.ActiveXObject?(t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(n)):t=(new DOMParser).parseFromString(n,"text/xml"),t&&t.documentElement&&"parsererror"!=t.documentElement.nodeName?t:null},vt=n.parseJSON||function(e){return window.eval("("+e+")")},yt=function(t,i,r){var f=t.getResponseHeader("content-type")||"",e="xml"===i||!i&&f.indexOf("xml")>=0,u=e?t.responseXML:t.responseText;return e&&"parsererror"===u.documentElement.nodeName&&n.error&&n.error("parsererror"),r&&r.dataFilter&&(u=r.dataFilter(u,i)),"string"==typeof u&&("json"===i||!i&&f.indexOf("json")>=0?u=vt(u):("script"===i||!i&&f.indexOf("javascript")>=0)&&n.globalEval(u)),u};return y}var e,b,o,u,a,v,y,c,s,l,h,g,nt,tt,p,ft,w;if(!this.length)return t("ajaxSubmit: skipping submit process - no element selected"),this;if(u=this,"function"==typeof r?r={success:r}:void 0===r&&(r={}),e=r.type||this.attr2("method"),b=r.url||this.attr2("action"),o="string"==typeof b?n.trim(b):"",o=o||window.location.href||"",o&&(o=(o.match(/^([^#]+)/)||[])[1]),r=n.extend(!0,{url:o,success:n.ajaxSettings.success,type:e||n.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},r),a={},this.trigger("form-pre-serialize",[this,r,a]),a.veto)return t("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(r.beforeSerialize&&r.beforeSerialize(this,r)===!1)return t("ajaxSubmit: submit aborted via beforeSerialize callback"),this;if(v=r.traditional,void 0===v&&(v=n.ajaxSettings.traditional),c=[],s=this.formToArray(r.semantic,c),r.data&&(r.extraData=r.data,y=n.param(r.data,v)),r.beforeSubmit&&r.beforeSubmit(s,this,r)===!1)return t("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[s,this,r,a]),a.veto)return t("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;l=n.param(s,v);y&&(l=l?l+"&"+y:y);"GET"==r.type.toUpperCase()?(r.url+=(r.url.indexOf("?")>=0?"&":"?")+l,r.data=null):r.data=l;h=[];(r.resetForm&&h.push(function(){u.resetForm()}),r.clearForm&&h.push(function(){u.clearForm(r.includeHidden)}),!r.dataType&&r.target)?(g=r.success||function(){},h.push(function(t){var i=r.replaceTarget?"replaceWith":"html";n(r.target)[i](t).each(g,arguments)})):r.success&&h.push(r.success);(r.success=function(n,t,i){for(var e=r.context||this,f=0,o=h.length;o>f;f++)h[f].apply(e,[n,t,i||u,u])},r.error)&&(nt=r.error,r.error=function(n,t,i){var f=r.context||this;nt.apply(f,[n,t,i,u])});r.complete&&(tt=r.complete,r.complete=function(n,t){var i=r.context||this;tt.apply(i,[n,t,u])});var st=n("input[type=file]:enabled",this).filter(function(){return""!==n(this).val()}),it=st.length>0,rt="multipart/form-data",ut=u.attr("enctype")==rt||u.attr("encoding")==rt,k=i.fileapi&&i.formdata;for(t("fileAPI :"+k),ft=(it||ut)&&!k,r.iframe!==!1&&(r.iframe||ft)?r.closeKeepAlive?n.get(r.closeKeepAlive,function(){p=d(s)}):p=d(s):p=(it||ut)&&k?ot(s):n.ajax(r),u.removeData("jqxhr").data("jqxhr",p),w=0;w<c.length;w++)c[w]=null;return this.trigger("form-submit-notify",[this,r]),this};n.fn.ajaxForm=function(i){if(i=i||{},i.delegation=i.delegation&&n.isFunction(n.fn.on),!i.delegation&&0===this.length){var f={s:this.selector,c:this.context};return!n.isReady&&f.s?(t("DOM not ready, queuing ajaxForm"),n(function(){n(f.s,f.c).ajaxForm(i)}),this):(t("terminating; zero elements found by selector"+(n.isReady?"":" (DOM not ready)")),this)}return i.delegation?(n(document).off("submit.form-plugin",this.selector,r).off("click.form-plugin",this.selector,u).on("submit.form-plugin",this.selector,i,r).on("click.form-plugin",this.selector,i,u),this):this.ajaxFormUnbind().bind("submit.form-plugin",i,r).bind("click.form-plugin",i,u)};n.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};n.fn.formToArray=function(t,r){var e=[],l,h,f,c,u,b,k,a,p,v;if(0===this.length)return e;var y,o=this[0],w=this.attr("id"),s=t?o.getElementsByTagName("*"):o.elements;if(s&&!/MSIE [678]/.test(navigator.userAgent)&&(s=n(s).get()),w&&(y=n(':input[form="'+w+'"]').get(),y.length&&(s=(s||[]).concat(y))),!s||!s.length)return e;for(l=0,b=s.length;b>l;l++)if(u=s[l],f=u.name,f&&!u.disabled)if(t&&o.clk&&"image"==u.type)o.clk==u&&(e.push({name:f,value:n(u).val(),type:u.type}),e.push({name:f+".x",value:o.clk_x},{name:f+".y",value:o.clk_y}));else if(c=n.fieldValue(u,!0),c&&c.constructor==Array)for(r&&r.push(u),h=0,k=c.length;k>h;h++)e.push({name:f,value:c[h]});else if(i.fileapi&&"file"==u.type)if(r&&r.push(u),a=u.files,a.length)for(h=0;h<a.length;h++)e.push({name:f,value:a[h],type:u.type});else e.push({name:f,value:"",type:u.type});else null!==c&&"undefined"!=typeof c&&(r&&r.push(u),e.push({name:f,value:c,type:u.type,required:u.required}));return!t&&o.clk&&(p=n(o.clk),v=p[0],f=v.name,f&&!v.disabled&&"image"==v.type&&(e.push({name:f,value:p.val()}),e.push({name:f+".x",value:o.clk_x},{name:f+".y",value:o.clk_y}))),e};n.fn.formSerialize=function(t){return n.param(this.formToArray(t))};n.fn.fieldSerialize=function(t){var i=[];return this.each(function(){var f=this.name,r,u,e;if(f)if(r=n.fieldValue(this,t),r&&r.constructor==Array)for(u=0,e=r.length;e>u;u++)i.push({name:f,value:r[u]});else null!==r&&"undefined"!=typeof r&&i.push({name:this.name,value:r})}),n.param(i)};n.fn.fieldValue=function(t){for(var f,i,r=[],u=0,e=this.length;e>u;u++)f=this[u],i=n.fieldValue(f,t),null!==i&&"undefined"!=typeof i&&(i.constructor!=Array||i.length)&&(i.constructor==Array?n.merge(r,i):r.push(i));return r};n.fieldValue=function(t,i){var a=t.name,u=t.type,h=t.tagName.toLowerCase(),e,r,f;if(void 0===i&&(i=!0),i&&(!a||t.disabled||"reset"==u||"button"==u||("checkbox"==u||"radio"==u)&&!t.checked||("submit"==u||"image"==u)&&t.form&&t.form.clk!=t||"select"==h&&-1==t.selectedIndex))return null;if("select"==h){if(e=t.selectedIndex,0>e)return null;for(var c=[],l=t.options,o="select-one"==u,v=o?e+1:l.length,s=o?e:0;v>s;s++)if(r=l[s],r.selected){if(f=r.value,f||(f=r.attributes&&r.attributes.value&&!r.attributes.value.specified?r.text:r.value),o)return f;c.push(f)}return c}return n(t).val()};n.fn.clearForm=function(t){return this.each(function(){n("input,select,textarea",this).clearFields(t)})};n.fn.clearFields=n.fn.clearInputs=function(t){var i=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var r=this.type,u=this.tagName.toLowerCase();i.test(r)||"textarea"==u?this.value="":"checkbox"==r||"radio"==r?this.checked=!1:"select"==u?this.selectedIndex=-1:"file"==r?/MSIE/.test(navigator.userAgent)?n(this).replaceWith(n(this).clone(!0)):n(this).val(""):t&&(t===!0&&/hidden/.test(r)||"string"==typeof t&&n(this).is(t))&&(this.value="")})};n.fn.resetForm=function(){return this.each(function(){"function"!=typeof this.reset&&("object"!=typeof this.reset||this.reset.nodeType)||this.reset()})};n.fn.enable=function(n){return void 0===n&&(n=!0),this.each(function(){this.disabled=!n})};n.fn.selected=function(t){return void 0===t&&(t=!0),this.each(function(){var r=this.type,i;"checkbox"==r||"radio"==r?this.checked=t:"option"==this.tagName.toLowerCase()&&(i=n(this).parent("select"),t&&i[0]&&"select-one"==i[0].type&&i.find("option").selected(!1),this.selected=t)})};n.fn.ajaxSubmit.debug=!1})