!function(n){"use strict";"function"==typeof define&&define.amd&&define(["jquery"],n);n("undefined"!=typeof module?require("jquery"):"undefined"!=typeof jQuery?jQuery:window.Zepto)}(function(n){"use strict";function r(t){var i=t.data;t.isDefaultPrevented()||(t.preventDefault(),n(t.target).closest("form").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=r.form;(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,u,e,o){function ct(t){for(var u,f=n.param(t,r.traditional).split("&"),o=f.length,e=[],i=0;i<o;i++)u=f[i].split("="),e.push([decodeURIComponent(u[0]),decodeURIComponent(u[1])]);return e}function lt(t){for(var f,u,o,e=new FormData,i=0;i<t.length;i++)e.append(t[i].name,t[i].value);if(r.extraData)for(f=ct(r.extraData),i=0;i<f.length;i++)f[i]&&e.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:l||"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,o=u.beforeSend,u.beforeSend=function(n,t){t.data=r.formData?r.formData:e;o&&o.call(this,n,t)},n.ajax(u)}function it(i){function ut(n){var i=null;try{n.contentWindow&&(i=n.contentWindow.document)}catch(n){t("cannot get iframe.contentWindow document: "+n)}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(c).readyState;t("state = "+n);n&&"uninitialized"==n.toLowerCase()&&setTimeout(f,50)}catch(n){t("Server abort: ",n," (",n.name,")");b(rt);g&&clearTimeout(g);g=void 0}}var e=s.attr2("target"),o=s.attr2("action"),y=s.attr("enctype")||s.attr("encoding")||"multipart/form-data",r,i,v;h.setAttribute("target",d);l&&!/post/i.test(l)||h.setAttribute("method","POST");o!=u.url&&h.setAttribute("action",u.url);u.skipEncodingOverride||l&&!/post/i.test(l)||s.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});u.timeout&&(g=setTimeout(function(){it=!0;b(et)},u.timeout));r=[];try{if(u.extraData)for(i in u.extraData)u.extraData.hasOwnProperty(i)&&(n.isPlainObject(u.extraData[i])&&u.extraData[i].hasOwnProperty("name")&&u.extraData[i].hasOwnProperty("value")?r.push(n('<input type="hidden" name="'+u.extraData[i].name+'">').val(u.extraData[i].value).appendTo(h)[0]):r.push(n('<input type="hidden" name="'+i+'">').val(u.extraData[i]).appendTo(h)[0]));u.iframeTarget||a.appendTo("body");c.attachEvent?c.attachEvent("onload",b):c.addEventListener("load",b,!1);setTimeout(f,15);try{h.submit()}catch(n){v=document.createElement("form").submit;v.apply(h)}}finally{h.setAttribute("action",o);h.setAttribute("enctype",y);e?h.setAttribute("target",e):s.removeAttr("target");n(r).remove()}}function b(i){var f,r,w,s,k,d,h,l,v;if(!e.aborted&&!ct){if(o=ut(c),o||(t("cannot access response document"),i=rt),i===et&&e)return e.abort("timeout"),void y.reject(e,"timeout");if(i==rt&&e)return e.abort("server abort"),void y.reject(e,"error","server abort");if(o&&o.location.href!=u.iframeSrc||it){c.detachEvent?c.detachEvent("onload",b):c.removeEventListener("load",b,!1);r="success";try{if(it)throw"timeout";if(w="xml"==u.dataType||o.XMLDocument||n.isXMLDoc(o),t("isXml="+w),!w&&window.opera&&(null===o.body||!o.body.innerHTML)&&--lt)return t("requeing onLoad callback, DOM not available"),void setTimeout(b,250);s=o.body?o.body:o.documentElement;e.responseText=s?s.innerHTML:null;e.responseXML=o.XMLDocument?o.XMLDocument:o;w&&(u.dataType="xml");e.getResponseHeader=function(n){var t={"content-type":u.dataType};return t[n.toLowerCase()]};s&&(e.status=Number(s.getAttribute("status"))||e.status,e.statusText=s.getAttribute("statusText")||e.statusText);k=(u.dataType||"").toLowerCase();d=/(json|script|text)/.test(k);d||u.textarea?(h=o.getElementsByTagName("textarea")[0],h?(e.responseText=h.value,e.status=Number(h.getAttribute("status"))||e.status,e.statusText=h.getAttribute("statusText")||e.statusText):d&&(l=o.getElementsByTagName("pre")[0],v=o.getElementsByTagName("body")[0],l?e.responseText=l.textContent?l.textContent:l.innerText:v&&(e.responseText=v.textContent?v.textContent:v.innerText))):"xml"==k&&!e.responseXML&&e.responseText&&(e.responseXML=at(e.responseText));try{ht=yt(e,k,u)}catch(n){r="parsererror";e.error=f=n||r}}catch(n){t("error caught: ",n);r="error";e.error=f=n||r}e.aborted&&(t("upload aborted"),r=null);e.status&&(r=e.status>=200&&e.status<300||304===e.status?"success":"error");"success"===r?(u.success&&u.success.call(u.context,ht,"success",e),y.resolve(e.responseText,"success",e),p&&n.event.trigger("ajaxSuccess",[e,u])):r&&(void 0===f&&(f=e.statusText),u.error&&u.error.call(u.context,e,r,f),y.reject(e,"error",f),p&&n.event.trigger("ajaxError",[e,u,f]));p&&n.event.trigger("ajaxComplete",[e,u]);p&&!--n.active&&n.event.trigger("ajaxStop");u.complete&&u.complete.call(u.context,e,r);ct=!0;u.timeout&&clearTimeout(g);setTimeout(function(){u.iframeTarget?a.attr("src",u.iframeSrc):a.remove();e.responseXML=null},100)}}}var tt,nt,u,p,d,a,c,e,k,w,it,g,h=s[0],y=n.Deferred();if(y.abort=function(n){e.abort(n)},i)for(nt=0;nt<v.length;nt++)tt=n(v[nt]),f?tt.prop("disabled",!1):tt.removeAttr("disabled");if(u=n.extend(!0,{},n.ajaxSettings,r),u.context=u.context||u,d="jqFormIO"+(new Date).getTime(),u.iframeTarget?(a=n(u.iframeTarget),w=a.attr2("name"),w?d=w:a.attr2("name",d)):(a=n('<iframe name="'+d+'" src="'+u.iframeSrc+'" />'),a.css({position:"absolute",top:"-1000px",left:"-1000px"})),c=a[0],e={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{c.contentWindow.document.execCommand&&c.contentWindow.document.execCommand("Stop")}catch(n){}a.attr("src",u.iframeSrc);e.error=r;u.error&&u.error.call(u.context,e,r,i);p&&n.event.trigger("ajaxError",[e,u,r]);u.complete&&u.complete.call(u.context,e,r)}},p=u.global,p&&0==n.active++&&n.event.trigger("ajaxStart"),p&&n.event.trigger("ajaxSend",[e,u]),u.beforeSend&&u.beforeSend.call(u.context,e,u)===!1)return u.global&&n.active--,y.reject(),y;if(e.aborted)return y.reject(),y;k=h.clk;k&&(w=k.name,w&&!k.disabled&&(u.extraData=u.extraData||{},u.extraData[w]=k.value,"image"==k.type&&(u.extraData[w+".x"]=h.clk_x,u.extraData[w+".y"]=h.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&&(u.extraData=u.extraData||{},u.extraData[st]=ot);u.forceSync?ft():setTimeout(ft,10);var ht,o,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(a){return window.eval("("+a+")")},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 l,g,a,s,p,w,b,v,h,nt,y,c,rt,ut,ft,k,ht,d;if(!this.length)return t("ajaxSubmit: skipping submit process - no element selected"),this;if(s=this,"function"==typeof r?r={success:r}:"string"==typeof r||r===!1&&arguments.length>0?(r={url:r,data:u,dataType:e},"function"==typeof o&&(r.success=o)):void 0===r&&(r={}),l=r.type||this.attr2("method"),g=r.url||this.attr2("action"),a="string"==typeof g?n.trim(g):"",a=a||window.location.href||"",a&&(a=(a.match(/^([^#]+)/)||[])[1]),r=n.extend(!0,{url:a,success:n.ajaxSettings.success,type:l||n.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},r),p={},this.trigger("form-pre-serialize",[this,r,p]),p.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(w=r.traditional,void 0===w&&(w=n.ajaxSettings.traditional),v=[],h=this.formToArray(r.semantic,v,r.filtering),r.data&&(nt=n.isFunction(r.data)?r.data(h):r.data,r.extraData=nt,b=n.param(nt,w)),r.beforeSubmit&&r.beforeSubmit(h,this,r)===!1)return t("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[h,this,r,p]),p.veto)return t("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;y=n.param(h,w);b&&(y=y?y+"&"+b:b);"GET"==r.type.toUpperCase()?(r.url+=(r.url.indexOf("?")>=0?"&":"?")+y,r.data=null):r.data=y;c=[];(r.resetForm&&c.push(function(){s.resetForm()}),r.clearForm&&c.push(function(){s.clearForm(r.includeHidden)}),!r.dataType&&r.target)?(rt=r.success||function(){},c.push(function(t){var i=r.replaceTarget?"replaceWith":"html";n(r.target)[i](t).each(rt,arguments)})):r.success&&(n.isArray(r.success)?n.merge(c,r.success):c.push(r.success));(r.success=function(n,t,i){for(var f=r.context||this,u=0,e=c.length;u<e;u++)c[u].apply(f,[n,t,i||s,s])},r.error)&&(ut=r.error,r.error=function(n,t,i){var u=r.context||this;ut.apply(u,[n,t,i,s])});r.complete&&(ft=r.complete,r.complete=function(n,t){var i=r.context||this;ft.apply(i,[n,t,s])});var at=n("input[type=file]:enabled",this).filter(function(){return""!==n(this).val()}),et=at.length>0,ot="multipart/form-data",st=s.attr("enctype")==ot||s.attr("encoding")==ot,tt=i.fileapi&&i.formdata;for(t("fileAPI :"+tt),ht=(et||st)&&!tt,r.iframe!==!1&&(r.iframe||ht)?r.closeKeepAlive?n.get(r.closeKeepAlive,function(){k=it(h)}):k=it(h):k=(et||st)&&tt?lt(h):n.ajax(r),s.removeData("jqxhr").data("jqxhr",k),d=0;d<v.length;d++)v[d]=null;return this.trigger("form-submit-notify",[this,r]),this};n.fn.ajaxForm=function(i,f,e,o){if(("string"==typeof i||i===!1&&arguments.length>0)&&(i={url:i,data:f,dataType:e},"function"==typeof o&&(i.success=o)),i=i||{},i.delegation=i.delegation&&n.isFunction(n.fn.on),!i.delegation&&0===this.length){var s={s:this.selector,c:this.context};return!n.isReady&&s.s?(t("DOM not ready, queuing ajaxForm"),n(function(){n(s.s,s.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().on("submit.form-plugin",i,r).on("click.form-plugin",i,u)};n.fn.ajaxFormUnbind=function(){return this.off("submit.form-plugin click.form-plugin")};n.fn.formToArray=function(t,r,u){var o=[],a,c,e,l,f,k,d,v,w,y;if(0===this.length)return o;var p,h=this[0],b=this.attr("id"),s=t?h.getElementsByTagName("*"):h.elements;if(s&&(s=n.makeArray(s)),b&&(p=n(':input[form="'+b+'"]').get(),p.length&&(s=(s||[]).concat(p))),!s||!s.length)return o;for(n.isFunction(u)&&(s=n.map(s,u)),a=0,k=s.length;a<k;a++)if(f=s[a],e=f.name,e&&!f.disabled)if(t&&h.clk&&"image"==f.type)h.clk==f&&(o.push({name:e,value:n(f).val(),type:f.type}),o.push({name:e+".x",value:h.clk_x},{name:e+".y",value:h.clk_y}));else if(l=n.fieldValue(f,!0),l&&l.constructor==Array)for(r&&r.push(f),c=0,d=l.length;c<d;c++)o.push({name:e,value:l[c]});else if(i.fileapi&&"file"==f.type)if(r&&r.push(f),v=f.files,v.length)for(c=0;c<v.length;c++)o.push({name:e,value:v[c],type:f.type});else o.push({name:e,value:"",type:f.type});else null!==l&&"undefined"!=typeof l&&(r&&r.push(f),o.push({name:e,value:l,type:f.type,required:f.required}));return!t&&h.clk&&(w=n(h.clk),y=w[0],e=y.name,e&&!y.disabled&&"image"==y.type&&(o.push({name:e,value:w.val()}),o.push({name:e+".x",value:h.clk_x},{name:e+".y",value:h.clk_y}))),o};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;u<e;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;u<e;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&&t.selectedIndex==-1))return null;if("select"==h){if(e=t.selectedIndex,e<0)return null;for(var c=[],l=t.options,o="select-one"==u,v=o?e+1:l.length,s=o?e:0;s<v;s++)if(r=l[s],r.selected&&!r.disabled){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(){var t=n(this),f=this.tagName.toLowerCase(),i,r,u;switch(f){case"input":this.checked=this.defaultChecked;case"textarea":return this.value=this.defaultValue,!0;case"option":case"optgroup":return i=t.parents("select"),i.length&&i[0].multiple?"option"==f?this.selected=this.defaultSelected:t.find("option").resetForm():i.resetForm(),!0;case"select":return t.find("option").each(function(n){if(this.selected=this.defaultSelected,this.defaultSelected&&!t[0].multiple)return t[0].selectedIndex=n,!1}),!0;case"label":return r=n(t.attr("for")),u=t.find("input,select,textarea"),r[0]&&u.unshift(r[0]),u.resetForm(),!0;case"form":return("function"==typeof this.reset||"object"==typeof this.reset&&!this.reset.nodeType)&&this.reset(),!0;default:return t.find("form,input,label,select,textarea").resetForm(),!0}})};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})