2019-03-23 12:39:52 -04:00
|
|
|
jQuery(document).ready(function(a){function b(b){var c=wp.template("health-check-issue"),d=a("#health-check-issues-"+b.status),e=a(".issue-count",d);SiteHealth.site_status.issues[b.status]++,e.text(SiteHealth.site_status.issues[b.status]),a(".issues","#health-check-issues-"+b.status).append(c(b))}function c(){var b,c,d,e=a("#progressbar"),f=a("#progressbar svg #bar"),g=parseInt(SiteHealth.site_status.issues.good,0)+parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),h=parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),i=100-Math.ceil(h/g*100);return 0===g?void e.addClass("hidden"):(e.removeClass("loading"),b=f.attr("r"),c=Math.PI*(2*b),0>i&&(i=0),100<i&&(i=100),d=(100-i)/100*c,f.css({strokeDashoffset:d}),1>parseInt(SiteHealth.site_status.issues.critical,0)&&a("#health-check-issues-critical").addClass("hidden"),1>parseInt(SiteHealth.site_status.issues.recommended,0)&&a("#health-check-issues-recommended").addClass("hidden"),50<=i&&f.addClass("orange").removeClass("red"),90<=i&&f.addClass("green").removeClass("orange"),100===i&&(a(".site-status-all-clear").removeClass("hide"),a(".site-status-has-issues").addClass("hide")),e.attr("data-pct",i),e.attr("aria-valuenow",i),a.post(ajaxurl,{action:"health-check-site-status-result",_wpnonce:SiteHealth.nonce.site_status_result,counts:SiteHealth.site_status.issues}),void wp.a11y.speak(SiteHealth.string.site_health_complete_screen_reader.replace("%s",i+"%")))}function d(){var e=!0;1<=SiteHealth.site_status.async.length&&a.each(SiteHealth.site_status.async,function(){var c={action:"health-check-"+this.test.replace("_","-"),_wpnonce:SiteHealth.nonce.site_status};return!!this.completed||(e=!1,this.completed=!0,a.post(ajaxurl,c,function(a){b(a.data),d()}),!1)}),e&&c()}var e;a(".health-check-copy-field").click(function(b){var c=a("#system-information-"+a(this).data("copy-field")+"-copy-field"),d=a(this).closest("div");b.preventDefault(),c.select(),document.execCommand("copy")&&(a(".copy-field-success",d).addClass("visible"),a(this).focus(),wp.a11y.speak(SiteHealth.string.site_info_copied))}),a(".health-check-accordion").on("click",".health-check-accordion-trigger",function(){var b="true"===a(this).attr("aria-expanded");b?(a(this).attr("aria-expanded","false"),a("#"+a(this).attr("aria-controls")).attr("hidden",!0)):(a(this).attr("aria-expanded","true"),a("#"+a(this).attr("aria-controls")).attr("hidden",!1))}),a(".health-check-accordion").on("keyup",".health-check-accordion-trigger",function(b){"38"===b.keyCode.toString()?a(".health-check-accordion-trigger",a(this).closest("dt").prevAll("dt")).focus():"40"===b.keyCode.toString()&&a(".health-check-accordion-trigger",a(this).closest("dt").nextAll("dt")).focus()}),a(".site-health-view-passed").on("click",function(){var b=a("#health-check-issues-good");b.toggleClass("hidden"),a(this).attr("aria-expanded",!b.hasClass("hidden"))}),"undefined"!=typeof SiteHealth&&(0===SiteHealth.site_status.direct.length&&0===SiteHealth.site_status.async.length?c():SiteHealth.site_status.issues={good:0,recommended:0,critical:0},0<SiteHealth.site_status.direct.length&&a.each(SiteHealth.site_status.direct,function(){b(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,a.post(ajaxurl,e,function(a){b(a.data),d()})):c())});
|