WordPress/wp-includes/js/jquery/jquery.form.min.js

1 line
16 KiB
JavaScript
Raw Normal View History

!function(r){"function"==typeof define&&define.amd?define(["jquery"],r):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),r(t),t}:r(jQuery)}(function(O){"use strict";var d=/\r?\n/g,v={};v.fileapi=void 0!==O('<input type="file">').get(0).files,v.formdata=void 0!==window.FormData;var X=!!O.fn.prop;function o(e){var t=e.data;e.isDefaultPrevented()||(e.preventDefault(),O(e.target).closest("form").ajaxSubmit(t))}function i(e){var t=e.target,r=O(t);if(!r.is("[type=submit],[type=image]")){var a=r.closest("[type=submit]");if(0===a.length)return;t=a[0]}var n=t.form;"image"===(n.clk=t).type&&(void 0!==e.offsetX?(n.clk_x=e.offsetX,n.clk_y=e.offsetY):"function"==typeof O.fn.offset?(r=r.offset(),n.clk_x=e.pageX-r.left,n.clk_y=e.pageY-r.top):(n.clk_x=e.pageX-t.offsetLeft,n.clk_y=e.pageY-t.offsetTop)),setTimeout(function(){n.clk=n.clk_x=n.clk_y=null},100)}function C(){var e;O.fn.ajaxSubmit.debug&&(e="[jquery.form] "+Array.prototype.join.call(arguments,""),window.console&&window.console.log?window.console.log(e):window.opera&&window.opera.postError&&window.opera.postError(e))}O.fn.attr2=function(){if(!X)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)},O.fn.ajaxSubmit=function(F,e,t,r){if(!this.length)return C("ajaxSubmit: skipping submit process - no element selected"),this;var E,L=this;"function"==typeof F?F={success:F}:"string"==typeof F||!1===F&&0<arguments.length?(F={url:F,data:e,dataType:t},"function"==typeof r&&(F.success=r)):void 0===F&&(F={}),E=F.method||F.type||this.attr2("method"),r=(r=(r="string"==typeof(t=F.url||this.attr2("action"))?O.trim(t):"")||window.location.href||"")&&(r.match(/^([^#]+)/)||[])[1],t=/(MSIE|Trident)/.test(navigator.userAgent||"")&&/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",F=O.extend(!0,{url:r,success:O.ajaxSettings.success,type:E||O.ajaxSettings.type,iframeSrc:t},F);r={};if(this.trigger("form-pre-serialize",[this,F,r]),r.veto)return C("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(F.beforeSerialize&&!1===F.beforeSerialize(this,F))return C("ajaxSubmit: submit aborted via beforeSerialize callback"),this;t=F.traditional;void 0===t&&(t=O.ajaxSettings.traditional);var M=[],a=this.formToArray(F.semantic,M,F.filtering);if(F.data&&(c=O.isFunction(F.data)?F.data(a):F.data,F.extraData=c,c=O.param(c,t)),F.beforeSubmit&&!1===F.beforeSubmit(a,this,F))return C("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[a,this,F,r]),r.veto)return C("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;r=O.param(a,t);c&&(r=r?r+"&"+c:c),"GET"===F.type.toUpperCase()?(F.url+=(0<=F.url.indexOf("?")?"&":"?")+r,F.data=null):F.data=r;var o,n,i,s=[];F.resetForm&&s.push(function(){L.resetForm()}),F.clearForm&&s.push(function(){L.clearForm(F.includeHidden)}),!F.dataType&&F.target?(o=F.success||function(){},s.push(function(e,t,r){var a=arguments,n=F.replaceTarget?"replaceWith":"html";O(F.target)[n](e).each(function(){o.apply(this,a)})})):F.success&&(O.isArray(F.success)?O.merge(s,F.success):s.push(F.success)),F.success=function(e,t,r){for(var a=F.context||this,n=0,o=s.length;n<o;n++)s[n].apply(a,[e,t,r||L,L])},F.error&&(n=F.error,F.error=function(e,t,r){var a=F.context||this;n.apply(a,[e,t,r,L])}),F.complete&&(i=F.complete,F.complete=function(e,t){var r=F.context||this;i.apply(r,[e,t,L])});var u,t=0<O("input[type=file]:enabled",this).filter(function(){return""!==O(this).val()}).length,c="multipart/form-data",r=L.attr("enctype")===c||L.attr("encoding")===c,c=v.fileapi&&v.formdata;C("fileAPI :"+c),!1!==F.iframe&&(F.iframe||(t||r)&&!c)?F.closeKeepAlive?O.get(F.closeKeepAlive,function(){u=f(a)}):u=f(a):u=(t||r)&&c?function(e){for(var r=new FormData,t=0;t<e.length;t++)r.append(e[t].name,e[t].value);if(F.extraData){var a=function(e){var t,r,a=O.param(e,F.traditional).split("&"),n=a.length,o=[];for(t=0;t<n;t++)a[t]=a[t].repl