mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-14 22:56:19 +01:00
40a294d21e
This backports several build and test tool improvements to the 5.3 branch. Most notably, this includes: - The changes required to allow each workflow to be triggered by the `workflow_dispatch` event so that tests can be run on a schedule [50590]. - The ability to run PHPUnit tests from `src` instead of `build` [50441-50443]. - Splitting single site and multisite tests into parallel jobs [50379]. - Split slow tests into separate, parallel jobs for PHP 5.6 [50444]. - Better branch and path scoping for GitHub Action workflows when running on `pull_request` [50432,50479]. - Several `devDependency` updates. Merges [50267,50299,50379,50387,50413,50416,50432,50435-50436,50441-50444,50446,50473-50474,50476,50479,50485-50487,50545,50579,50590,50598] to the 5.3 branch. See #50401, #51734, #51801, #51802, #52548, #52608, #52612, #52623, #52624, #52625, #52645, #52653, #52658, #52660, #52667. Built from https://develop.svn.wordpress.org/branches/5.3@50605 git-svn-id: http://core.svn.wordpress.org/branches/5.3@50218 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
!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 L,E=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={}),L=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],F=O.extend(!0,{url:r,success:O.ajaxSettings.success,type:L||O.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},F);t={};if(this.trigger("form-pre-serialize",[this,F,t]),t.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;r=F.traditional;void 0===r&&(r=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,r)),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,t]),t.veto)return C("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;t=O.param(a,r);c&&(t=t?t+"&"+c:c),"GET"===F.type.toUpperCase()?(F.url+=(0<=F.url.indexOf("?")?"&":"?")+t,F.data=null):F.data=t;var o,n,i,s=[];F.resetForm&&s.push(function(){E.resetForm()}),F.clearForm&&s.push(function(){E.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||E,E])},F.error&&(n=F.error,F.error=function(e,t,r){var a=F.context||this;n.apply(a,[e,t,r,E])}),F.complete&&(i=F.complete,F.complete=function(e,t){var r=F.context||this;i.apply(r,[e,t,E])});var u,r=0<O("input[type=file]:enabled",this).filter(function(){return""!==O(this).val()}).length,c="multipart/form-data",t=E.attr("enctype")===c||E.attr("encoding")===c,c=v.fileapi&&v.formdata;C("fileAPI :"+c),!1!==F.iframe&&(F.iframe||(r||t)&&!c)?F.closeKeepAlive?O.get(F.closeKeepAlive,function(){u=f(a)}):u=f(a):u=(r||t)&&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].replace(/\+/g," "),r=a[t].split("="),o.push([decodeURIComponent(r[0]),decodeURIComponent(r[1])]);return o}(F.extraData);for(t=0;t<a.length;t++)a[t]&&r.append(a[t][0],a[t][1])}F.data=null;var n=O.extend(!0,{},O.ajaxSettings,F,{contentType:!1,processData:!1,cache:!1,type:L||"POST"});F.uploadProgress&&(n.xhr=function(){var e=O.ajaxSettings.xhr();return e.upload&&e.upload.addEventListener("progress",function(e){var t=0,r=e.loaded||e.position,a=e.total;e.lengthComputable&&(t=Math.ceil(r/a*100)),F.uploadProgress(e,r,a,t)},!1),e});n.data=null;var o=n.beforeSend;return n.beforeSend=function(e,t){F.formData?t.data=F.formData:t.data=r,o&&o.call(this,e,t)},O.ajax(n)}(a):O.ajax(F),E.removeData("jqxhr").data("jqxhr",u);for(var l=0;l<M.length;l++)M[l]=null;return this.trigger("form-submit-notify",[this,F]),this;function f(e){var t,r,c,l,f,d,p,m,h,o=E[0],v=O.Deferred();if(v.abort=function(e){p.abort(e)},e)for(r=0;r<M.length;r++)t=O(M[r]),X?t.prop("disabled",!1):t.removeAttr("disabled");(c=O.extend(!0,{},O.ajaxSettings,F)).context=c.context||c;var i="jqFormIO"+(new Date).getTime(),s=o.ownerDocument,u=E.closest("body");if(c.iframeTarget?(a=(f=O(c.iframeTarget,s)).attr2("name"))?i=a:f.attr2("name",i):(f=O('<iframe name="'+i+'" src="'+c.iframeSrc+'" />',s)).css({position:"absolute",top:"-1000px",left:"-1000px"}),d=f[0],p={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(e){var t="timeout"===e?"timeout":"aborted";C("aborting upload... "+t),this.aborted=1;try{d.contentWindow.document.execCommand&&d.contentWindow.document.execCommand("Stop")}catch(e){}f.attr("src",c.iframeSrc),p.error=t,c.error&&c.error.call(c.context,p,t,e),l&&O.event.trigger("ajaxError",[p,c,t]),c.complete&&c.complete.call(c.context,p,t)}},(l=c.global)&&0==O.active++&&O.event.trigger("ajaxStart"),l&&O.event.trigger("ajaxSend",[p,c]),c.beforeSend&&!1===c.beforeSend.call(c.context,p,c))return c.global&&O.active--,v.reject(),v;if(p.aborted)return v.reject(),v;(e=o.clk)&&(a=e.name)&&!e.disabled&&(c.extraData=c.extraData||{},c.extraData[a]=e.value,"image"===e.type&&(c.extraData[a+".x"]=o.clk_x,c.extraData[a+".y"]=o.clk_y));var g=1,x=2;function y(t){var r=null;try{t.contentWindow&&(r=t.contentWindow.document)}catch(e){C("cannot get iframe.contentWindow document: "+e)}if(r)return r;try{r=t.contentDocument||t.document}catch(e){C("cannot get iframe.contentDocument: "+e),r=t.document}return r}var e=O("meta[name=csrf-token]").attr("content"),a=O("meta[name=csrf-param]").attr("content");function n(){var e=E.attr2("target"),t=E.attr2("action"),r=E.attr("enctype")||E.attr("encoding")||"multipart/form-data";o.setAttribute("target",i),L&&!/post/i.test(L)||o.setAttribute("method","POST"),t!==c.url&&o.setAttribute("action",c.url),c.skipEncodingOverride||L&&!/post/i.test(L)||E.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),c.timeout&&(h=setTimeout(function(){m=!0,S(g)},c.timeout));var a=[];try{if(c.extraData)for(var n in c.extraData)c.extraData.hasOwnProperty(n)&&(O.isPlainObject(c.extraData[n])&&c.extraData[n].hasOwnProperty("name")&&c.extraData[n].hasOwnProperty("value")?a.push(O('<input type="hidden" name="'+c.extraData[n].name+'">',s).val(c.extraData[n].value).appendTo(o)[0]):a.push(O('<input type="hidden" name="'+n+'">',s).val(c.extraData[n]).appendTo(o)[0]));c.iframeTarget||f.appendTo(u),d.attachEvent?d.attachEvent("onload",S):d.addEventListener("load",S,!1),setTimeout(function e(){try{var t=y(d).readyState;C("state = "+t),t&&"uninitialized"===t.toLowerCase()&&setTimeout(e,50)}catch(e){C("Server abort: ",e," (",e.name,")"),S(x),h&&clearTimeout(h),h=void 0}},15);try{o.submit()}catch(e){document.createElement("form").submit.apply(o)}}finally{o.setAttribute("action",t),o.setAttribute("enctype",r),e?o.setAttribute("target",e):E.removeAttr("target"),O(a).remove()}}a&&e&&(c.extraData=c.extraData||{},c.extraData[a]=e),c.forceSync?n():setTimeout(n,10);var b,T,j,w=50;function S(t){if(!p.aborted&&!j){if((T=y(d))||(C("cannot access response document"),t=x),t===g&&p)return p.abort("timeout"),void v.reject(p,"timeout");if(t===x&&p)return p.abort("server abort"),void v.reject(p,"error","server abort");if(T&&T.location.href!==c.iframeSrc||m){d.detachEvent?d.detachEvent("onload",S):d.removeEventListener("load",S,!1);var r,t="success";try{if(m)throw"timeout";var e="xml"===c.dataType||T.XMLDocument||O.isXMLDoc(T);if(C("isXml="+e),!e&&window.opera&&(null===T.body||!T.body.innerHTML)&&--w)return C("requeing onLoad callback, DOM not available"),void setTimeout(S,250);var a=T.body||T.documentElement;p.responseText=a?a.innerHTML:null,p.responseXML=T.XMLDocument||T,e&&(c.dataType="xml"),p.getResponseHeader=function(e){return{"content-type":c.dataType}[e.toLowerCase()]},a&&(p.status=Number(a.getAttribute("status"))||p.status,p.statusText=a.getAttribute("statusText")||p.statusText);var n,o,i,s=(c.dataType||"").toLowerCase(),u=/(json|script|text)/.test(s);u||c.textarea?(n=T.getElementsByTagName("textarea")[0])?(p.responseText=n.value,p.status=Number(n.getAttribute("status"))||p.status,p.statusText=n.getAttribute("statusText")||p.statusText):u&&(o=T.getElementsByTagName("pre")[0],i=T.getElementsByTagName("body")[0],o?p.responseText=o.textContent||o.innerText:i&&(p.responseText=i.textContent||i.innerText)):"xml"===s&&!p.responseXML&&p.responseText&&(p.responseXML=k(p.responseText));try{b=A(p,s,c)}catch(e){t="parsererror",p.error=r=e||t}}catch(e){C("error caught: ",e),t="error",p.error=r=e||t}p.aborted&&(C("upload aborted"),t=null),"success"===(t=p.status?200<=p.status&&p.status<300||304===p.status?"success":"error":t)?(c.success&&c.success.call(c.context,b,"success",p),v.resolve(p.responseText,"success",p),l&&O.event.trigger("ajaxSuccess",[p,c])):t&&(void 0===r&&(r=p.statusText),c.error&&c.error.call(c.context,p,t,r),v.reject(p,"error",r),l&&O.event.trigger("ajaxError",[p,c,r])),l&&O.event.trigger("ajaxComplete",[p,c]),l&&!--O.active&&O.event.trigger("ajaxStop"),c.complete&&c.complete.call(c.context,p,t),j=!0,c.timeout&&clearTimeout(h),setTimeout(function(){c.iframeTarget?f.attr("src",c.iframeSrc):f.remove(),p.responseXML=null},100)}}}var k=O.parseXML||function(e,t){return window.ActiveXObject?((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!==t.documentElement.nodeName?t:null},D=O.parseJSON||function(e){return window.eval("("+e+")")},A=function(e,t,r){var a=e.getResponseHeader("content-type")||"",n=("xml"===t||!t)&&0<=a.indexOf("xml"),e=n?e.responseXML:e.responseText;return n&&"parsererror"===e.documentElement.nodeName&&O.error&&O.error("parsererror"),"string"==typeof(e=r&&r.dataFilter?r.dataFilter(e,t):e)&&(("json"===t||!t)&&0<=a.indexOf("json")?e=D(e):("script"===t||!t)&&0<=a.indexOf("javascript")&&O.globalEval(e)),e};return v}},O.fn.ajaxForm=function(e,t,r,a){if(("string"==typeof e||!1===e&&0<arguments.length)&&(e={url:e,data:t,dataType:r},"function"==typeof a&&(e.success=a)),(e=e||{}).delegation=e.delegation&&O.isFunction(O.fn.on),e.delegation||0!==this.length)return e.delegation?(O(document).off("submit.form-plugin",this.selector,o).off("click.form-plugin",this.selector,i).on("submit.form-plugin",this.selector,e,o).on("click.form-plugin",this.selector,e,i),this):this.ajaxFormUnbind().on("submit.form-plugin",e,o).on("click.form-plugin",e,i);var n={s:this.selector,c:this.context};return!O.isReady&&n.s?(C("DOM not ready, queuing ajaxForm"),O(function(){O(n.s,n.c).ajaxForm(e)})):C("terminating; zero elements found by selector"+(O.isReady?"":" (DOM not ready)")),this},O.fn.ajaxFormUnbind=function(){return this.off("submit.form-plugin click.form-plugin")},O.fn.formToArray=function(e,t,r){var a=[];if(0===this.length)return a;var n,o,i,s,u,c,l,f,d=this[0],p=this.attr("id"),m=(m=e||void 0===d.elements?d.getElementsByTagName("*"):d.elements)&&O.makeArray(m);if(!(m=p&&(e||/(Edge|Trident)\//.test(navigator.userAgent))&&(l=O(':input[form="'+p+'"]').get()).length?(m||[]).concat(l):m)||!m.length)return a;for(n=0,u=(m=O.isFunction(r)?O.map(m,r):m).length;n<u;n++)if((f=(s=m[n]).name)&&!s.disabled)if(e&&d.clk&&"image"===s.type)d.clk===s&&(a.push({name:f,value:O(s).val(),type:s.type}),a.push({name:f+".x",value:d.clk_x},{name:f+".y",value:d.clk_y}));else if((i=O.fieldValue(s,!0))&&i.constructor===Array)for(t&&t.push(s),o=0,c=i.length;o<c;o++)a.push({name:f,value:i[o]});else if(v.fileapi&&"file"===s.type){t&&t.push(s);var h=s.files;if(h.length)for(o=0;o<h.length;o++)a.push({name:f,value:h[o],type:s.type});else a.push({name:f,value:"",type:s.type})}else null!=i&&(t&&t.push(s),a.push({name:f,value:i,type:s.type,required:s.required}));return e||!d.clk||(f=(r=(l=O(d.clk))[0]).name)&&!r.disabled&&"image"===r.type&&(a.push({name:f,value:l.val()}),a.push({name:f+".x",value:d.clk_x},{name:f+".y",value:d.clk_y})),a},O.fn.formSerialize=function(e){return O.param(this.formToArray(e))},O.fn.fieldSerialize=function(n){var o=[];return this.each(function(){var e=this.name;if(e){var t=O.fieldValue(this,n);if(t&&t.constructor===Array)for(var r=0,a=t.length;r<a;r++)o.push({name:e,value:t[r]});else null!=t&&o.push({name:this.name,value:t})}}),O.param(o)},O.fn.fieldValue=function(e){for(var t=[],r=0,a=this.length;r<a;r++){var n=this[r],n=O.fieldValue(n,e);null==n||n.constructor===Array&&!n.length||(n.constructor===Array?O.merge(t,n):t.push(n))}return t},O.fieldValue=function(e,t){var r=e.name,a=e.type,n=e.tagName.toLowerCase();if((t=void 0===t?!0:t)&&(!r||e.disabled||"reset"===a||"button"===a||("checkbox"===a||"radio"===a)&&!e.checked||("submit"===a||"image"===a)&&e.form&&e.form.clk!==e||"select"===n&&-1===e.selectedIndex))return null;if("select"!==n)return O(e).val().replace(d,"\r\n");n=e.selectedIndex;if(n<0)return null;for(var o=[],i=e.options,s="select-one"===a,u=s?n+1:i.length,c=s?n:0;c<u;c++){var l=i[c];if(l.selected&&!l.disabled){var f=(f=l.value)||(l.attributes&&l.attributes.value&&!l.attributes.value.specified?l.text:l.value);if(s)return f;o.push(f)}}return o},O.fn.clearForm=function(e){return this.each(function(){O("input,select,textarea",this).clearFields(e)})},O.fn.clearFields=O.fn.clearInputs=function(r){var a=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var e=this.type,t=this.tagName.toLowerCase();a.test(e)||"textarea"===t?this.value="":"checkbox"===e||"radio"===e?this.checked=!1:"select"===t?this.selectedIndex=-1:"file"===e?/MSIE/.test(navigator.userAgent)?O(this).replaceWith(O(this).clone(!0)):O(this).val(""):r&&(!0===r&&/hidden/.test(e)||"string"==typeof r&&O(this).is(r))&&(this.value="")})},O.fn.resetForm=function(){return this.each(function(){var t=O(this),e=this.tagName.toLowerCase();switch(e){case"input":this.checked=this.defaultChecked;case"textarea":return this.value=this.defaultValue,!0;case"option":case"optgroup":var r=t.parents("select");return r.length&&r[0].multiple?"option"===e?this.selected=this.defaultSelected:t.find("option").resetForm():r.resetForm(),!0;case"select":return t.find("option").each(function(e){if(this.selected=this.defaultSelected,this.defaultSelected&&!t[0].multiple)return t[0].selectedIndex=e,!1}),!0;case"label":var a=O(t.attr("for")),r=t.find("input,select,textarea");return a[0]&&r.unshift(a[0]),r.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}})},O.fn.enable=function(e){return void 0===e&&(e=!0),this.each(function(){this.disabled=!e})},O.fn.selected=function(t){return void 0===t&&(t=!0),this.each(function(){var e=this.type;"checkbox"===e||"radio"===e?this.checked=t:"option"===this.tagName.toLowerCase()&&(e=O(this).parent("select"),t&&e[0]&&"select-one"===e[0].type&&e.find("option").selected(!1),this.selected=t)})},O.fn.ajaxSubmit.debug=!1}); |