Commit a3f41ac9 by TingSong-Syu

rename jquery.form to fit cdnjs

parent aafcafd5
!function(factory){"use strict";"function"==typeof define&&define.amd?define(["jquery"],factory):factory("undefined"!=typeof jQuery?jQuery:window.Zepto)}(function($){"use strict";function doAjaxSubmit(e){var options=e.data;e.isDefaultPrevented()||(e.preventDefault(),$(e.target).ajaxSubmit(options))}function captureSubmittingElement(e){var target=e.target,$el=$(target);if(!$el.is("[type=submit],[type=image]")){var t=$el.closest("[type=submit]");if(0===t.length)return;target=t[0]}var form=this;if(form.clk=target,"image"==target.type)if(void 0!==e.offsetX)form.clk_x=e.offsetX,form.clk_y=e.offsetY;else if("function"==typeof $.fn.offset){var offset=$el.offset();form.clk_x=e.pageX-offset.left,form.clk_y=e.pageY-offset.top}else form.clk_x=e.pageX-target.offsetLeft,form.clk_y=e.pageY-target.offsetTop;setTimeout(function(){form.clk=form.clk_x=form.clk_y=null},100)}function log(){if($.fn.ajaxSubmit.debug){var msg="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(msg):window.opera&&window.opera.postError&&window.opera.postError(msg)}}var feature={};feature.fileapi=void 0!==$("<input type='file'/>").get(0).files,feature.formdata=void 0!==window.FormData;var hasProp=!!$.fn.prop;$.fn.attr2=function(){if(!hasProp)return this.attr.apply(this,arguments);var val=this.prop.apply(this,arguments);return val&&val.jquery||"string"==typeof val?val:this.attr.apply(this,arguments)},$.fn.ajaxSubmit=function(options){function deepSerialize(extraData){var i,part,serialized=$.param(extraData,options.traditional).split("&"),len=serialized.length,result=[];for(i=0;len>i;i++)serialized[i]=serialized[i].replace(/\+/g," "),part=serialized[i].split("="),result.push([decodeURIComponent(part[0]),decodeURIComponent(part[1])]);return result}function fileUploadXhr(a){for(var formdata=new FormData,i=0;i<a.length;i++)formdata.append(a[i].name,a[i].value);if(options.extraData){var serializedData=deepSerialize(options.extraData);for(i=0;i<serializedData.length;i++)serializedData[i]&&formdata.append(serializedData[i][0],serializedData[i][1])}options.data=null;var s=$.extend(!0,{},$.ajaxSettings,options,{contentType:!1,processData:!1,cache:!1,type:method||"POST"});options.uploadProgress&&(s.xhr=function(){var xhr=$.ajaxSettings.xhr();return xhr.upload&&xhr.upload.addEventListener("progress",function(event){var percent=0,position=event.loaded||event.position,total=event.total;event.lengthComputable&&(percent=Math.ceil(position/total*100)),options.uploadProgress(event,position,total,percent)},!1),xhr}),s.data=null;var beforeSend=s.beforeSend;return s.beforeSend=function(xhr,o){options.formData?o.data=options.formData:o.data=formdata,beforeSend&&beforeSend.call(this,xhr,o)},$.ajax(s)}function fileUploadIframe(a){function getDoc(frame){var doc=null;try{frame.contentWindow&&(doc=frame.contentWindow.document)}catch(err){log("cannot get iframe.contentWindow document: "+err)}if(doc)return doc;try{doc=frame.contentDocument?frame.contentDocument:frame.document}catch(err){log("cannot get iframe.contentDocument: "+err),doc=frame.document}return doc}function doSubmit(){function checkState(){try{var state=getDoc(io).readyState;log("state = "+state),state&&"uninitialized"==state.toLowerCase()&&setTimeout(checkState,50)}catch(e){log("Server abort: ",e," (",e.name,")"),cb(SERVER_ABORT),timeoutHandle&&clearTimeout(timeoutHandle),timeoutHandle=void 0}}var t=$form.attr2("target"),a=$form.attr2("action"),mp="multipart/form-data",et=$form.attr("enctype")||$form.attr("encoding")||mp;form.setAttribute("target",id),(!method||/post/i.test(method))&&form.setAttribute("method","POST"),a!=s.url&&form.setAttribute("action",s.url),s.skipEncodingOverride||method&&!/post/i.test(method)||$form.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),s.timeout&&(timeoutHandle=setTimeout(function(){timedOut=!0,cb(CLIENT_TIMEOUT_ABORT)},s.timeout));var extraInputs=[];try{if(s.extraData)for(var n in s.extraData)s.extraData.hasOwnProperty(n)&&($.isPlainObject(s.extraData[n])&&s.extraData[n].hasOwnProperty("name")&&s.extraData[n].hasOwnProperty("value")?extraInputs.push($('<input type="hidden" name="'+s.extraData[n].name+'">').val(s.extraData[n].value).appendTo(form)[0]):extraInputs.push($('<input type="hidden" name="'+n+'">').val(s.extraData[n]).appendTo(form)[0]));s.iframeTarget||$io.appendTo("body"),io.attachEvent?io.attachEvent("onload",cb):io.addEventListener("load",cb,!1),setTimeout(checkState,15);try{form.submit()}catch(err){var submitFn=document.createElement("form").submit;submitFn.apply(form)}}finally{form.setAttribute("action",a),form.setAttribute("enctype",et),t?form.setAttribute("target",t):$form.removeAttr("target"),$(extraInputs).remove()}}function cb(e){if(!xhr.aborted&&!callbackProcessed){if(doc=getDoc(io),doc||(log("cannot access response document"),e=SERVER_ABORT),e===CLIENT_TIMEOUT_ABORT&&xhr)return xhr.abort("timeout"),void deferred.reject(xhr,"timeout");if(e==SERVER_ABORT&&xhr)return xhr.abort("server abort"),void deferred.reject(xhr,"error","server abort");if(doc&&doc.location.href!=s.iframeSrc||timedOut){io.detachEvent?io.detachEvent("onload",cb):io.removeEventListener("load",cb,!1);var errMsg,status="success";try{if(timedOut)throw"timeout";var isXml="xml"==s.dataType||doc.XMLDocument||$.isXMLDoc(doc);if(log("isXml="+isXml),!isXml&&window.opera&&(null===doc.body||!doc.body.innerHTML)&&--domCheckCount)return log("requeing onLoad callback, DOM not available"),void setTimeout(cb,250);var docRoot=doc.body?doc.body:doc.documentElement;xhr.responseText=docRoot?docRoot.innerHTML:null,xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc,isXml&&(s.dataType="xml"),xhr.getResponseHeader=function(header){var headers={"content-type":s.dataType};return headers[header.toLowerCase()]},docRoot&&(xhr.status=Number(docRoot.getAttribute("status"))||xhr.status,xhr.statusText=docRoot.getAttribute("statusText")||xhr.statusText);var dt=(s.dataType||"").toLowerCase(),scr=/(json|script|text)/.test(dt);if(scr||s.textarea){var ta=doc.getElementsByTagName("textarea")[0];if(ta)xhr.responseText=ta.value,xhr.status=Number(ta.getAttribute("status"))||xhr.status,xhr.statusText=ta.getAttribute("statusText")||xhr.statusText;else if(scr){var pre=doc.getElementsByTagName("pre")[0],b=doc.getElementsByTagName("body")[0];pre?xhr.responseText=pre.textContent?pre.textContent:pre.innerText:b&&(xhr.responseText=b.textContent?b.textContent:b.innerText)}}else"xml"==dt&&!xhr.responseXML&&xhr.responseText&&(xhr.responseXML=toXml(xhr.responseText));try{data=httpData(xhr,dt,s)}catch(err){status="parsererror",xhr.error=errMsg=err||status}}catch(err){log("error caught: ",err),status="error",xhr.error=errMsg=err||status}xhr.aborted&&(log("upload aborted"),status=null),xhr.status&&(status=xhr.status>=200&&xhr.status<300||304===xhr.status?"success":"error"),"success"===status?(s.success&&s.success.call(s.context,data,"success",xhr),deferred.resolve(xhr.responseText,"success",xhr),g&&$.event.trigger("ajaxSuccess",[xhr,s])):status&&(void 0===errMsg&&(errMsg=xhr.statusText),s.error&&s.error.call(s.context,xhr,status,errMsg),deferred.reject(xhr,"error",errMsg),g&&$.event.trigger("ajaxError",[xhr,s,errMsg])),g&&$.event.trigger("ajaxComplete",[xhr,s]),g&&!--$.active&&$.event.trigger("ajaxStop"),s.complete&&s.complete.call(s.context,xhr,status),callbackProcessed=!0,s.timeout&&clearTimeout(timeoutHandle),setTimeout(function(){s.iframeTarget?$io.attr("src",s.iframeSrc):$io.remove(),xhr.responseXML=null},100)}}}var el,i,s,g,id,$io,io,xhr,sub,n,timedOut,timeoutHandle,form=$form[0],deferred=$.Deferred();if(deferred.abort=function(status){xhr.abort(status)},a)for(i=0;i<elements.length;i++)el=$(elements[i]),hasProp?el.prop("disabled",!1):el.removeAttr("disabled");if(s=$.extend(!0,{},$.ajaxSettings,options),s.context=s.context||s,id="jqFormIO"+(new Date).getTime(),s.iframeTarget?($io=$(s.iframeTarget),n=$io.attr2("name"),n?id=n:$io.attr2("name",id)):($io=$('<iframe name="'+id+'" src="'+s.iframeSrc+'" />'),$io.css({position:"absolute",top:"-1000px",left:"-1000px"})),io=$io[0],xhr={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(status){var e="timeout"===status?"timeout":"aborted";log("aborting upload... "+e),this.aborted=1;try{io.contentWindow.document.execCommand&&io.contentWindow.document.execCommand("Stop")}catch(ignore){}$io.attr("src",s.iframeSrc),xhr.error=e,s.error&&s.error.call(s.context,xhr,e,status),g&&$.event.trigger("ajaxError",[xhr,s,e]),s.complete&&s.complete.call(s.context,xhr,e)}},g=s.global,g&&0===$.active++&&$.event.trigger("ajaxStart"),g&&$.event.trigger("ajaxSend",[xhr,s]),s.beforeSend&&s.beforeSend.call(s.context,xhr,s)===!1)return s.global&&$.active--,deferred.reject(),deferred;if(xhr.aborted)return deferred.reject(),deferred;sub=form.clk,sub&&(n=sub.name,n&&!sub.disabled&&(s.extraData=s.extraData||{},s.extraData[n]=sub.value,"image"==sub.type&&(s.extraData[n+".x"]=form.clk_x,s.extraData[n+".y"]=form.clk_y)));var CLIENT_TIMEOUT_ABORT=1,SERVER_ABORT=2,csrf_token=$("meta[name=csrf-token]").attr("content"),csrf_param=$("meta[name=csrf-param]").attr("content");csrf_param&&csrf_token&&(s.extraData=s.extraData||{},s.extraData[csrf_param]=csrf_token),s.forceSync?doSubmit():setTimeout(doSubmit,10);var data,doc,callbackProcessed,domCheckCount=50,toXml=$.parseXML||function(s,doc){return window.ActiveXObject?(doc=new ActiveXObject("Microsoft.XMLDOM"),doc.async="false",doc.loadXML(s)):doc=(new DOMParser).parseFromString(s,"text/xml"),doc&&doc.documentElement&&"parsererror"!=doc.documentElement.nodeName?doc:null},parseJSON=$.parseJSON||function(s){return window.eval("("+s+")")},httpData=function(xhr,type,s){var ct=xhr.getResponseHeader("content-type")||"",xml="xml"===type||!type&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;return xml&&"parsererror"===data.documentElement.nodeName&&$.error&&$.error("parsererror"),s&&s.dataFilter&&(data=s.dataFilter(data,type)),"string"==typeof data&&("json"===type||!type&&ct.indexOf("json")>=0?data=parseJSON(data):("script"===type||!type&&ct.indexOf("javascript")>=0)&&$.globalEval(data)),data};return deferred}if(!this.length)return log("ajaxSubmit: skipping submit process - no element selected"),this;var method,action,url,$form=this;"function"==typeof options?options={success:options}:void 0===options&&(options={}),method=options.type||this.attr2("method"),action=options.url||this.attr2("action"),url="string"==typeof action?$.trim(action):"",url=url||window.location.href||"",url&&(url=(url.match(/^([^#]+)/)||[])[1]),options=$.extend(!0,{url:url,success:$.ajaxSettings.success,type:method||$.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},options);var veto={};if(this.trigger("form-pre-serialize",[this,options,veto]),veto.veto)return log("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(options.beforeSerialize&&options.beforeSerialize(this,options)===!1)return log("ajaxSubmit: submit aborted via beforeSerialize callback"),this;var traditional=options.traditional;void 0===traditional&&(traditional=$.ajaxSettings.traditional);var qx,elements=[],a=this.formToArray(options.semantic,elements);if(options.data&&(options.extraData=options.data,qx=$.param(options.data,traditional)),options.beforeSubmit&&options.beforeSubmit(a,this,options)===!1)return log("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[a,this,options,veto]),veto.veto)return log("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;var q=$.param(a,traditional);qx&&(q=q?q+"&"+qx:qx),"GET"==options.type.toUpperCase()?(options.url+=(options.url.indexOf("?")>=0?"&":"?")+q,options.data=null):options.data=q;var callbacks=[];if(options.resetForm&&callbacks.push(function(){$form.resetForm()}),options.clearForm&&callbacks.push(function(){$form.clearForm(options.includeHidden)}),!options.dataType&&options.target){var oldSuccess=options.success||function(){};callbacks.push(function(data){var fn=options.replaceTarget?"replaceWith":"html";$(options.target)[fn](data).each(oldSuccess,arguments)})}else options.success&&callbacks.push(options.success);if(options.success=function(data,status,xhr){for(var context=options.context||this,i=0,max=callbacks.length;max>i;i++)callbacks[i].apply(context,[data,status,xhr||$form,$form])},options.error){var oldError=options.error;options.error=function(xhr,status,error){var context=options.context||this;oldError.apply(context,[xhr,status,error,$form])}}if(options.complete){var oldComplete=options.complete;options.complete=function(xhr,status){var context=options.context||this;oldComplete.apply(context,[xhr,status,$form])}}var fileInputs=$("input[type=file]:enabled",this).filter(function(){return""!==$(this).val()}),hasFileInputs=fileInputs.length>0,mp="multipart/form-data",multipart=$form.attr("enctype")==mp||$form.attr("encoding")==mp,fileAPI=feature.fileapi&&feature.formdata;log("fileAPI :"+fileAPI);var jqxhr,shouldUseFrame=(hasFileInputs||multipart)&&!fileAPI;options.iframe!==!1&&(options.iframe||shouldUseFrame)?options.closeKeepAlive?$.get(options.closeKeepAlive,function(){jqxhr=fileUploadIframe(a)}):jqxhr=fileUploadIframe(a):jqxhr=(hasFileInputs||multipart)&&fileAPI?fileUploadXhr(a):$.ajax(options),$form.removeData("jqxhr").data("jqxhr",jqxhr);for(var k=0;k<elements.length;k++)elements[k]=null;return this.trigger("form-submit-notify",[this,options]),this},$.fn.ajaxForm=function(options){if(options=options||{},options.delegation=options.delegation&&$.isFunction($.fn.on),!options.delegation&&0===this.length){var o={s:this.selector,c:this.context};return!$.isReady&&o.s?(log("DOM not ready, queuing ajaxForm"),$(function(){$(o.s,o.c).ajaxForm(options)}),this):(log("terminating; zero elements found by selector"+($.isReady?"":" (DOM not ready)")),this)}return options.delegation?($(document).off("submit.form-plugin",this.selector,doAjaxSubmit).off("click.form-plugin",this.selector,captureSubmittingElement).on("submit.form-plugin",this.selector,options,doAjaxSubmit).on("click.form-plugin",this.selector,options,captureSubmittingElement),this):this.ajaxFormUnbind().bind("submit.form-plugin",options,doAjaxSubmit).bind("click.form-plugin",options,captureSubmittingElement)},$.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")},$.fn.formToArray=function(semantic,elements){var a=[];if(0===this.length)return a;var els2,form=this[0],formId=this.attr("id"),els=semantic?form.getElementsByTagName("*"):form.elements;if(els&&!/MSIE [678]/.test(navigator.userAgent)&&(els=$(els).get()),formId&&(els2=$(':input[form="'+formId+'"]').get(),els2.length&&(els=(els||[]).concat(els2))),!els||!els.length)return a;var i,j,n,v,el,max,jmax;for(i=0,max=els.length;max>i;i++)if(el=els[i],n=el.name,n&&!el.disabled)if(semantic&&form.clk&&"image"==el.type)form.clk==el&&(a.push({name:n,value:$(el).val(),type:el.type}),a.push({name:n+".x",value:form.clk_x},{name:n+".y",value:form.clk_y}));else if(v=$.fieldValue(el,!0),v&&v.constructor==Array)for(elements&&elements.push(el),j=0,jmax=v.length;jmax>j;j++)a.push({name:n,value:v[j]});else if(feature.fileapi&&"file"==el.type){elements&&elements.push(el);var files=el.files;if(files.length)for(j=0;j<files.length;j++)a.push({name:n,value:files[j],type:el.type});else a.push({name:n,value:"",type:el.type})}else null!==v&&"undefined"!=typeof v&&(elements&&elements.push(el),a.push({name:n,value:v,type:el.type,required:el.required}));if(!semantic&&form.clk){var $input=$(form.clk),input=$input[0];n=input.name,n&&!input.disabled&&"image"==input.type&&(a.push({name:n,value:$input.val()}),a.push({name:n+".x",value:form.clk_x},{name:n+".y",value:form.clk_y}))}return a},$.fn.formSerialize=function(semantic){return $.param(this.formToArray(semantic))},$.fn.fieldSerialize=function(successful){var a=[];return this.each(function(){var n=this.name;if(n){var v=$.fieldValue(this,successful);if(v&&v.constructor==Array)for(var i=0,max=v.length;max>i;i++)a.push({name:n,value:v[i]});else null!==v&&"undefined"!=typeof v&&a.push({name:this.name,value:v})}}),$.param(a)},$.fn.fieldValue=function(successful){for(var val=[],i=0,max=this.length;max>i;i++){var el=this[i],v=$.fieldValue(el,successful);null===v||"undefined"==typeof v||v.constructor==Array&&!v.length||(v.constructor==Array?$.merge(val,v):val.push(v))}return val},$.fieldValue=function(el,successful){var n=el.name,t=el.type,tag=el.tagName.toLowerCase();if(void 0===successful&&(successful=!0),successful&&(!n||el.disabled||"reset"==t||"button"==t||("checkbox"==t||"radio"==t)&&!el.checked||("submit"==t||"image"==t)&&el.form&&el.form.clk!=el||"select"==tag&&-1==el.selectedIndex))return null;if("select"==tag){var index=el.selectedIndex;if(0>index)return null;for(var a=[],ops=el.options,one="select-one"==t,max=one?index+1:ops.length,i=one?index:0;max>i;i++){var op=ops[i];if(op.selected){var v=op.value;if(v||(v=op.attributes&&op.attributes.value&&!op.attributes.value.specified?op.text:op.value),one)return v;a.push(v)}}return a}return $(el).val()},$.fn.clearForm=function(includeHidden){return this.each(function(){$("input,select,textarea",this).clearFields(includeHidden)})},$.fn.clearFields=$.fn.clearInputs=function(includeHidden){var re=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var t=this.type,tag=this.tagName.toLowerCase();re.test(t)||"textarea"==tag?this.value="":"checkbox"==t||"radio"==t?this.checked=!1:"select"==tag?this.selectedIndex=-1:"file"==t?/MSIE/.test(navigator.userAgent)?$(this).replaceWith($(this).clone(!0)):$(this).val(""):includeHidden&&(includeHidden===!0&&/hidden/.test(t)||"string"==typeof includeHidden&&$(this).is(includeHidden))&&(this.value="")})},$.fn.resetForm=function(){return this.each(function(){("function"==typeof this.reset||"object"==typeof this.reset&&!this.reset.nodeType)&&this.reset()})},$.fn.enable=function(b){return void 0===b&&(b=!0),this.each(function(){this.disabled=!b})},$.fn.selected=function(select){return void 0===select&&(select=!0),this.each(function(){var t=this.type;if("checkbox"==t||"radio"==t)this.checked=select;else if("option"==this.tagName.toLowerCase()){var $sel=$(this).parent("select");select&&$sel[0]&&"select-one"==$sel[0].type&&$sel.find("option").selected(!1),this.selected=select}})},$.fn.ajaxSubmit.debug=!1});
\ No newline at end of file
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("undefined"!=typeof jQuery?jQuery:window.Zepto)}(function(e){"use strict";function t(t){var r=t.data;t.isDefaultPrevented()||(t.preventDefault(),e(t.target).ajaxSubmit(r))}function r(t){var r=t.target,a=e(r);if(!a.is("[type=submit],[type=image]")){var n=a.closest("[type=submit]");if(0===n.length)return;r=n[0]}var i=this;if(i.clk=r,"image"==r.type)if(void 0!==t.offsetX)i.clk_x=t.offsetX,i.clk_y=t.offsetY;else if("function"==typeof e.fn.offset){var o=a.offset();i.clk_x=t.pageX-o.left,i.clk_y=t.pageY-o.top}else 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 a(){if(e.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 n={};n.fileapi=void 0!==e("<input type='file'/>").get(0).files,n.formdata=void 0!==window.FormData;var i=!!e.fn.prop;e.fn.attr2=function(){if(!i)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},e.fn.ajaxSubmit=function(t){function r(r){var a,n,i=e.param(r,t.traditional).split("&"),o=i.length,s=[];for(a=0;o>a;a++)i[a]=i[a].replace(/\+/g," "),n=i[a].split("="),s.push([decodeURIComponent(n[0]),decodeURIComponent(n[1])]);return s}function o(a){for(var n=new FormData,i=0;i<a.length;i++)n.append(a[i].name,a[i].value);if(t.extraData){var o=r(t.extraData);for(i=0;i<o.length;i++)o[i]&&n.append(o[i][0],o[i][1])}t.data=null;var s=e.extend(!0,{},e.ajaxSettings,t,{contentType:!1,processData:!1,cache:!1,type:u||"POST"});t.uploadProgress&&(s.xhr=function(){var r=e.ajaxSettings.xhr();return r.upload&&r.upload.addEventListener("progress",function(e){var r=0,a=e.loaded||e.position,n=e.total;e.lengthComputable&&(r=Math.ceil(a/n*100)),t.uploadProgress(e,a,n,r)},!1),r}),s.data=null;var c=s.beforeSend;return s.beforeSend=function(e,r){r.data=t.formData?t.formData:n,c&&c.call(this,e,r)},e.ajax(s)}function s(r){function n(e){var t=null;try{e.contentWindow&&(t=e.contentWindow.document)}catch(r){a("cannot get iframe.contentWindow document: "+r)}if(t)return t;try{t=e.contentDocument?e.contentDocument:e.document}catch(r){a("cannot get iframe.contentDocument: "+r),t=e.document}return t}function o(){function t(){try{var e=n(g).readyState;a("state = "+e),e&&"uninitialized"==e.toLowerCase()&&setTimeout(t,50)}catch(r){a("Server abort: ",r," (",r.name,")"),s(k),j&&clearTimeout(j),j=void 0}}var r=f.attr2("target"),i=f.attr2("action"),o="multipart/form-data",c=f.attr("enctype")||f.attr("encoding")||o;w.setAttribute("target",p),(!u||/post/i.test(u))&&w.setAttribute("method","POST"),i!=m.url&&w.setAttribute("action",m.url),m.skipEncodingOverride||u&&!/post/i.test(u)||f.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),m.timeout&&(j=setTimeout(function(){T=!0,s(D)},m.timeout));var l=[];try{if(m.extraData)for(var d in m.extraData)m.extraData.hasOwnProperty(d)&&l.push(e.isPlainObject(m.extraData[d])&&m.extraData[d].hasOwnProperty("name")&&m.extraData[d].hasOwnProperty("value")?e('<input type="hidden" name="'+m.extraData[d].name+'">').val(m.extraData[d].value).appendTo(w)[0]:e('<input type="hidden" name="'+d+'">').val(m.extraData[d]).appendTo(w)[0]);m.iframeTarget||v.appendTo("body"),g.attachEvent?g.attachEvent("onload",s):g.addEventListener("load",s,!1),setTimeout(t,15);try{w.submit()}catch(h){var x=document.createElement("form").submit;x.apply(w)}}finally{w.setAttribute("action",i),w.setAttribute("enctype",c),r?w.setAttribute("target",r):f.removeAttr("target"),e(l).remove()}}function s(t){if(!x.aborted&&!F){if(M=n(g),M||(a("cannot access response document"),t=k),t===D&&x)return x.abort("timeout"),void S.reject(x,"timeout");if(t==k&&x)return x.abort("server abort"),void S.reject(x,"error","server abort");if(M&&M.location.href!=m.iframeSrc||T){g.detachEvent?g.detachEvent("onload",s):g.removeEventListener("load",s,!1);var r,i="success";try{if(T)throw"timeout";var o="xml"==m.dataType||M.XMLDocument||e.isXMLDoc(M);if(a("isXml="+o),!o&&window.opera&&(null===M.body||!M.body.innerHTML)&&--O)return a("requeing onLoad callback, DOM not available"),void setTimeout(s,250);var u=M.body?M.body:M.documentElement;x.responseText=u?u.innerHTML:null,x.responseXML=M.XMLDocument?M.XMLDocument:M,o&&(m.dataType="xml"),x.getResponseHeader=function(e){var t={"content-type":m.dataType};return t[e.toLowerCase()]},u&&(x.status=Number(u.getAttribute("status"))||x.status,x.statusText=u.getAttribute("statusText")||x.statusText);var c=(m.dataType||"").toLowerCase(),l=/(json|script|text)/.test(c);if(l||m.textarea){var f=M.getElementsByTagName("textarea")[0];if(f)x.responseText=f.value,x.status=Number(f.getAttribute("status"))||x.status,x.statusText=f.getAttribute("statusText")||x.statusText;else if(l){var p=M.getElementsByTagName("pre")[0],h=M.getElementsByTagName("body")[0];p?x.responseText=p.textContent?p.textContent:p.innerText:h&&(x.responseText=h.textContent?h.textContent:h.innerText)}}else"xml"==c&&!x.responseXML&&x.responseText&&(x.responseXML=X(x.responseText));try{E=_(x,c,m)}catch(y){i="parsererror",x.error=r=y||i}}catch(y){a("error caught: ",y),i="error",x.error=r=y||i}x.aborted&&(a("upload aborted"),i=null),x.status&&(i=x.status>=200&&x.status<300||304===x.status?"success":"error"),"success"===i?(m.success&&m.success.call(m.context,E,"success",x),S.resolve(x.responseText,"success",x),d&&e.event.trigger("ajaxSuccess",[x,m])):i&&(void 0===r&&(r=x.statusText),m.error&&m.error.call(m.context,x,i,r),S.reject(x,"error",r),d&&e.event.trigger("ajaxError",[x,m,r])),d&&e.event.trigger("ajaxComplete",[x,m]),d&&!--e.active&&e.event.trigger("ajaxStop"),m.complete&&m.complete.call(m.context,x,i),F=!0,m.timeout&&clearTimeout(j),setTimeout(function(){m.iframeTarget?v.attr("src",m.iframeSrc):v.remove(),x.responseXML=null},100)}}}var c,l,m,d,p,v,g,x,y,b,T,j,w=f[0],S=e.Deferred();if(S.abort=function(e){x.abort(e)},r)for(l=0;l<h.length;l++)c=e(h[l]),i?c.prop("disabled",!1):c.removeAttr("disabled");if(m=e.extend(!0,{},e.ajaxSettings,t),m.context=m.context||m,p="jqFormIO"+(new Date).getTime(),m.iframeTarget?(v=e(m.iframeTarget),b=v.attr2("name"),b?p=b:v.attr2("name",p)):(v=e('<iframe name="'+p+'" src="'+m.iframeSrc+'" />'),v.css({position:"absolute",top:"-1000px",left:"-1000px"})),g=v[0],x={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(t){var r="timeout"===t?"timeout":"aborted";a("aborting upload... "+r),this.aborted=1;try{g.contentWindow.document.execCommand&&g.contentWindow.document.execCommand("Stop")}catch(n){}v.attr("src",m.iframeSrc),x.error=r,m.error&&m.error.call(m.context,x,r,t),d&&e.event.trigger("ajaxError",[x,m,r]),m.complete&&m.complete.call(m.context,x,r)}},d=m.global,d&&0===e.active++&&e.event.trigger("ajaxStart"),d&&e.event.trigger("ajaxSend",[x,m]),m.beforeSend&&m.beforeSend.call(m.context,x,m)===!1)return m.global&&e.active--,S.reject(),S;if(x.aborted)return S.reject(),S;y=w.clk,y&&(b=y.name,b&&!y.disabled&&(m.extraData=m.extraData||{},m.extraData[b]=y.value,"image"==y.type&&(m.extraData[b+".x"]=w.clk_x,m.extraData[b+".y"]=w.clk_y)));var D=1,k=2,A=e("meta[name=csrf-token]").attr("content"),L=e("meta[name=csrf-param]").attr("content");L&&A&&(m.extraData=m.extraData||{},m.extraData[L]=A),m.forceSync?o():setTimeout(o,10);var E,M,F,O=50,X=e.parseXML||function(e,t){return window.ActiveXObject?(t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!=t.documentElement.nodeName?t:null},C=e.parseJSON||function(e){return window.eval("("+e+")")},_=function(t,r,a){var n=t.getResponseHeader("content-type")||"",i="xml"===r||!r&&n.indexOf("xml")>=0,o=i?t.responseXML:t.responseText;return i&&"parsererror"===o.documentElement.nodeName&&e.error&&e.error("parsererror"),a&&a.dataFilter&&(o=a.dataFilter(o,r)),"string"==typeof o&&("json"===r||!r&&n.indexOf("json")>=0?o=C(o):("script"===r||!r&&n.indexOf("javascript")>=0)&&e.globalEval(o)),o};return S}if(!this.length)return a("ajaxSubmit: skipping submit process - no element selected"),this;var u,c,l,f=this;"function"==typeof t?t={success:t}:void 0===t&&(t={}),u=t.type||this.attr2("method"),c=t.url||this.attr2("action"),l="string"==typeof c?e.trim(c):"",l=l||window.location.href||"",l&&(l=(l.match(/^([^#]+)/)||[])[1]),t=e.extend(!0,{url:l,success:e.ajaxSettings.success,type:u||e.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},t);var m={};if(this.trigger("form-pre-serialize",[this,t,m]),m.veto)return a("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(t.beforeSerialize&&t.beforeSerialize(this,t)===!1)return a("ajaxSubmit: submit aborted via beforeSerialize callback"),this;var d=t.traditional;void 0===d&&(d=e.ajaxSettings.traditional);var p,h=[],v=this.formToArray(t.semantic,h);if(t.data&&(t.extraData=t.data,p=e.param(t.data,d)),t.beforeSubmit&&t.beforeSubmit(v,this,t)===!1)return a("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[v,this,t,m]),m.veto)return a("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;var g=e.param(v,d);p&&(g=g?g+"&"+p:p),"GET"==t.type.toUpperCase()?(t.url+=(t.url.indexOf("?")>=0?"&":"?")+g,t.data=null):t.data=g;var x=[];if(t.resetForm&&x.push(function(){f.resetForm()}),t.clearForm&&x.push(function(){f.clearForm(t.includeHidden)}),!t.dataType&&t.target){var y=t.success||function(){};x.push(function(r){var a=t.replaceTarget?"replaceWith":"html";e(t.target)[a](r).each(y,arguments)})}else t.success&&x.push(t.success);if(t.success=function(e,r,a){for(var n=t.context||this,i=0,o=x.length;o>i;i++)x[i].apply(n,[e,r,a||f,f])},t.error){var b=t.error;t.error=function(e,r,a){var n=t.context||this;b.apply(n,[e,r,a,f])}}if(t.complete){var T=t.complete;t.complete=function(e,r){var a=t.context||this;T.apply(a,[e,r,f])}}var j=e("input[type=file]:enabled",this).filter(function(){return""!==e(this).val()}),w=j.length>0,S="multipart/form-data",D=f.attr("enctype")==S||f.attr("encoding")==S,k=n.fileapi&&n.formdata;a("fileAPI :"+k);var A,L=(w||D)&&!k;t.iframe!==!1&&(t.iframe||L)?t.closeKeepAlive?e.get(t.closeKeepAlive,function(){A=s(v)}):A=s(v):A=(w||D)&&k?o(v):e.ajax(t),f.removeData("jqxhr").data("jqxhr",A);for(var E=0;E<h.length;E++)h[E]=null;return this.trigger("form-submit-notify",[this,t]),this},e.fn.ajaxForm=function(n){if(n=n||{},n.delegation=n.delegation&&e.isFunction(e.fn.on),!n.delegation&&0===this.length){var i={s:this.selector,c:this.context};return!e.isReady&&i.s?(a("DOM not ready, queuing ajaxForm"),e(function(){e(i.s,i.c).ajaxForm(n)}),this):(a("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)")),this)}return n.delegation?(e(document).off("submit.form-plugin",this.selector,t).off("click.form-plugin",this.selector,r).on("submit.form-plugin",this.selector,n,t).on("click.form-plugin",this.selector,n,r),this):this.ajaxFormUnbind().bind("submit.form-plugin",n,t).bind("click.form-plugin",n,r)},e.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")},e.fn.formToArray=function(t,r){var a=[];if(0===this.length)return a;var i,o=this[0],s=this.attr("id"),u=t?o.getElementsByTagName("*"):o.elements;if(u&&!/MSIE [678]/.test(navigator.userAgent)&&(u=e(u).get()),s&&(i=e(':input[form="'+s+'"]').get(),i.length&&(u=(u||[]).concat(i))),!u||!u.length)return a;var c,l,f,m,d,p,h;for(c=0,p=u.length;p>c;c++)if(d=u[c],f=d.name,f&&!d.disabled)if(t&&o.clk&&"image"==d.type)o.clk==d&&(a.push({name:f,value:e(d).val(),type:d.type}),a.push({name:f+".x",value:o.clk_x},{name:f+".y",value:o.clk_y}));else if(m=e.fieldValue(d,!0),m&&m.constructor==Array)for(r&&r.push(d),l=0,h=m.length;h>l;l++)a.push({name:f,value:m[l]});else if(n.fileapi&&"file"==d.type){r&&r.push(d);var v=d.files;if(v.length)for(l=0;l<v.length;l++)a.push({name:f,value:v[l],type:d.type});else a.push({name:f,value:"",type:d.type})}else null!==m&&"undefined"!=typeof m&&(r&&r.push(d),a.push({name:f,value:m,type:d.type,required:d.required}));if(!t&&o.clk){var g=e(o.clk),x=g[0];f=x.name,f&&!x.disabled&&"image"==x.type&&(a.push({name:f,value:g.val()}),a.push({name:f+".x",value:o.clk_x},{name:f+".y",value:o.clk_y}))}return a},e.fn.formSerialize=function(t){return e.param(this.formToArray(t))},e.fn.fieldSerialize=function(t){var r=[];return this.each(function(){var a=this.name;if(a){var n=e.fieldValue(this,t);if(n&&n.constructor==Array)for(var i=0,o=n.length;o>i;i++)r.push({name:a,value:n[i]});else null!==n&&"undefined"!=typeof n&&r.push({name:this.name,value:n})}}),e.param(r)},e.fn.fieldValue=function(t){for(var r=[],a=0,n=this.length;n>a;a++){var i=this[a],o=e.fieldValue(i,t);null===o||"undefined"==typeof o||o.constructor==Array&&!o.length||(o.constructor==Array?e.merge(r,o):r.push(o))}return r},e.fieldValue=function(t,r){var a=t.name,n=t.type,i=t.tagName.toLowerCase();if(void 0===r&&(r=!0),r&&(!a||t.disabled||"reset"==n||"button"==n||("checkbox"==n||"radio"==n)&&!t.checked||("submit"==n||"image"==n)&&t.form&&t.form.clk!=t||"select"==i&&-1==t.selectedIndex))return null;if("select"==i){var o=t.selectedIndex;if(0>o)return null;for(var s=[],u=t.options,c="select-one"==n,l=c?o+1:u.length,f=c?o:0;l>f;f++){var m=u[f];if(m.selected){var d=m.value;if(d||(d=m.attributes&&m.attributes.value&&!m.attributes.value.specified?m.text:m.value),c)return d;s.push(d)}}return s}return e(t).val()},e.fn.clearForm=function(t){return this.each(function(){e("input,select,textarea",this).clearFields(t)})},e.fn.clearFields=e.fn.clearInputs=function(t){var r=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var a=this.type,n=this.tagName.toLowerCase();r.test(a)||"textarea"==n?this.value="":"checkbox"==a||"radio"==a?this.checked=!1:"select"==n?this.selectedIndex=-1:"file"==a?/MSIE/.test(navigator.userAgent)?e(this).replaceWith(e(this).clone(!0)):e(this).val(""):t&&(t===!0&&/hidden/.test(a)||"string"==typeof t&&e(this).is(t))&&(this.value="")})},e.fn.resetForm=function(){return this.each(function(){("function"==typeof this.reset||"object"==typeof this.reset&&!this.reset.nodeType)&&this.reset()})},e.fn.enable=function(e){return void 0===e&&(e=!0),this.each(function(){this.disabled=!e})},e.fn.selected=function(t){return void 0===t&&(t=!0),this.each(function(){var r=this.type;if("checkbox"==r||"radio"==r)this.checked=t;else if("option"==this.tagName.toLowerCase()){var a=e(this).parent("select");t&&a[0]&&"select-one"==a[0].type&&a.find("option").selected(!1),this.selected=t}})},e.fn.ajaxSubmit.debug=!1});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment