lesterchan/wp-sweep

View on GitHub
js/wp-sweep.min.js

Summary

Maintainability
A
0 mins
Test Coverage
(function(b){b(function(){var f=b("body"),g=function(a){var c=a.parents("tr");f.addClass("sweep-active");a.prop("disabled",!0).text(wp_sweep.text_sweeping);return b.get(ajaxurl,{action:a.data("action"),sweep_name:a.data("sweep_name"),sweep_type:a.data("sweep_type"),_wpnonce:a.data("nonce")},function(e){if(e.success){var d=parseInt(e.data.count,10);b(".sweep-count",c).text(d.toLocaleString());b(".sweep-percentage",c).text(e.data.percentage);0===d&&a.parent("td").html(wp_sweep.text_na);b.each(e.data.stats,
    function(a,c){b(".sweep-count-type-"+a).text(parseInt(c,10).toLocaleString())});c.parents(".table-sweep").prev(".sweep-message").html('<div class="updated"><p>'+e.data.sweep+"</p></div>");b(".sweep-details",c).html("").hide();f.removeClass("sweep-active");a.prop("disabled",!1).text(wp_sweep.text_sweep)}})};b(".btn-sweep").click(function(a){a.preventDefault();g(b(this))});b(".btn-sweep-details").click(function(a){a.preventDefault();var c=b(this);b.get(ajaxurl,{action:c.data("action"),sweep_name:c.data("sweep_name"),
    sweep_type:c.data("sweep_type"),_wpnonce:c.data("nonce")},function(a){if(a.success&&0<a.data.length){var d="";b.each(a.data,function(a,b){d+="<li>"+b+"</li>"});b(".sweep-details",c.parents("tr")).html("<ol>"+d+"</ol>").show()}})});b(".btn-sweep-all").click(function(a){a.preventDefault();var c=b(this);a=b(".btn-sweep");c.prop("disabled",!0).text(wp_sweep.text_sweeping);a.toArray().reduce(function(a,c){return a.then(function(){return g(b(c))})},b().promise()).done(function(){f.removeClass("sweep-active");
    c.prop("disabled",!1).text(wp_sweep.text_sweep_all)})});b(window).on("beforeunload",function(a){if(f.hasClass("sweep-active"))return(a||window.event).returnValue=wp_sweep.text_close_warning})})})(jQuery);