WordPress/wp-admin/js/site-health.min.js

2 lines
5.6 KiB
JavaScript

/*! This file is auto-generated */
jQuery(document).ready(function(h){var a,t,s,c=wp.i18n.__,n=wp.i18n._n,o=wp.i18n.sprintf,i=new ClipboardJS(".site-health-copy-buttons .copy-button"),d=h(".health-check-body.health-check-debug-tab").length,l=h("#health-check-accordion-block-wp-paths-sizes");function r(e){var t,s,a=wp.template("health-check-issue"),i=h("#health-check-issues-"+e.status);SiteHealth.site_status.issues[e.status]++,s=SiteHealth.site_status.issues[e.status],void 0===e.test&&(e.test=e.status+s),"critical"===e.status?t=o(n("%s critical issue","%s critical issues",s),'<span class="issue-count">'+s+"</span>"):"recommended"===e.status?t=o(n("%s recommended improvement","%s recommended improvements",s),'<span class="issue-count">'+s+"</span>"):"good"===e.status&&(t=o(n("%s item with no issues detected","%s items with no issues detected",s),'<span class="issue-count">'+s+"</span>")),t&&h(".site-health-issue-count-title",i).html(t),h(".issues","#health-check-issues-"+e.status).append(a(e))}function u(){var e,t,s=h(".site-health-progress"),a=s.closest(".site-health-progress-wrapper"),i=h(".site-health-progress-label",a),n=h(".site-health-progress svg #bar"),o=parseInt(SiteHealth.site_status.issues.good,0)+parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),l=.5*parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),r=100-Math.ceil(l/o*100);0!==o?(a.removeClass("loading"),e=n.attr("r"),r<0&&(r=0),100<r&&(r=100),t=(100-r)/100*(Math.PI*(2*e)),n.css({strokeDashoffset:t}),parseInt(SiteHealth.site_status.issues.critical,0)<1&&h("#health-check-issues-critical").addClass("hidden"),parseInt(SiteHealth.site_status.issues.recommended,0)<1&&h("#health-check-issues-recommended").addClass("hidden"),80<=r&&0===parseInt(SiteHealth.site_status.issues.critical,0)?(a.addClass("green").removeClass("orange"),i.text(c("Good")),wp.a11y.speak(c("All site health tests have finished running. Your site is looking good, and the results are now available on the page."))):(a.addClass("orange").removeClass("green"),i.text(c("Should be improved")),wp.a11y.speak(c("All site health tests have finished running. There are items that should be addressed, and the results are now available on the page."))),d||(h.post(ajaxurl,{action:"health-check-site-status-result",_wpnonce:SiteHealth.nonce.site_status_result,counts:SiteHealth.site_status.issues}),100===r&&(h(".site-status-all-clear").removeClass("hide"),h(".site-status-has-issues").addClass("hide")))):s.addClass("hidden")}function p(e,t){var s;s={status:"recommended",label:c("A test is unavailable"),badge:{color:"red",label:c("Unavailable")},description:"<p>"+e+"</p><p>"+t+"</p>",actions:""},r(wp.hooks.applyFilters("site_status_test_result",s))}i.on("success",function(e){var t=h(e.trigger),s=h(".success",t.closest("div"));e.clearSelection(),t.focus(),clearTimeout(a),s.removeClass("hidden"),a=setTimeout(function(){s.addClass("hidden"),i.clipboardAction.fakeElem&&i.clipboardAction.removeFake&&i.clipboardAction.removeFake()},3e3),wp.a11y.speak(c("Site information has been copied to your clipboard."))}),h(".health-check-accordion").on("click",".health-check-accordion-trigger",function(){"true"===h(this).attr("aria-expanded")?(h(this).attr("aria-expanded","false"),h("#"+h(this).attr("aria-controls")).attr("hidden",!0)):(h(this).attr("aria-expanded","true"),h("#"+h(this).attr("aria-controls")).attr("hidden",!1))}),h(".site-health-view-passed").on("click",function(){var e=h("#health-check-issues-good");e.toggleClass("hidden"),h(this).attr("aria-expanded",!e.hasClass("hidden"))}),"undefined"==typeof SiteHealth||d||(0===SiteHealth.site_status.direct.length&&0===SiteHealth.site_status.async.length?u():SiteHealth.site_status.issues={good:0,recommended:0,critical:0},0<SiteHealth.site_status.direct.length&&h.each(SiteHealth.site_status.direct,function(){r(this)}),0<SiteHealth.site_status.async.length?function t(){var s=!0;1<=SiteHealth.site_status.async.length&&h.each(SiteHealth.site_status.async,function(){var e={action:"health-check-"+this.test.replace("_","-"),_wpnonce:SiteHealth.nonce.site_status};return!!this.completed||(s=!1,this.completed=!0,void 0!==this.has_rest&&this.has_rest?wp.apiRequest({url:this.test,headers:this.headers}).done(function(e){r(wp.hooks.applyFilters("site_status_test_result",e))}).fail(function(e){var t;t=void 0!==e.responseJSON&&void 0!==e.responseJSON.message?e.responseJSON.message:c("No details available"),p(this.url,t)}).always(function(){t()}):h.post(ajaxurl,e).done(function(e){r(wp.hooks.applyFilters("site_status_test_result",e.data))}).fail(function(e){var t;t=void 0!==e.responseJSON&&void 0!==e.responseJSON.message?e.responseJSON.message:c("No details available"),p(this.url,t)}).always(function(){t()}),!1)}),s&&u()}():u()),d&&(l.length?(t=(new Date).getTime(),s=window.setTimeout(function(){wp.a11y.speak(c("Please wait..."))},3e3),wp.apiRequest({path:"/wp-site-health/v1/directory-sizes"}).done(function(e){!function(i){var e=h("button.button.copy-button"),a=e.attr("data-clipboard-text");h.each(i,function(e,t){var s=t.debug||t.size;void 0!==s&&(a=a.replace(e+": loading...",e+": "+s))}),e.attr("data-clipboard-text",a),l.find("td[class]").each(function(e,t){var s=h(t),a=s.attr("class");i.hasOwnProperty(a)&&i[a].size&&s.text(i[a].size)})}(e||{})}).always(function(){var e=(new Date).getTime()-t;h(".health-check-wp-paths-sizes.spinner").css("visibility","hidden"),u(),3e3<e?(e=6e3<e?0:6500-e,window.setTimeout(function(){wp.a11y.speak(c("All site health tests have finished running."))},e)):window.clearTimeout(s),h(document).trigger("site-health-info-dirsizes-done")})):u())});