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

2 lines
5.1 KiB
JavaScript

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