WordPress/wp-admin/js/privacy-tools.min.js

1 line
3.0 KiB
JavaScript
Raw Normal View History

jQuery(document).ready(function(v){var f=window.privacyToolsL10n||{};function h(e,t){e.children().addClass("hidden"),e.children("."+t).removeClass("hidden")}function g(e){e.removeClass("has-request-results"),e.next().hasClass("request-results")&&e.next().remove()}function x(e,t,a,n){var o="",s="request-results";g(e),n.length&&(v.each(n,function(e,t){o=o+"<li>"+t+"</li>"}),o="<ul>"+o+"</ul>"),e.addClass("has-request-results"),e.hasClass("status-request-confirmed")&&(s+=" status-request-confirmed"),e.hasClass("status-request-failed")&&(s+=" status-request-failed"),e.after(function(){return'<tr class="'+s+'"><th colspan="5"><div class="notice inline notice-alt '+t+'"><p>'+a+"</p>"+o+"</div></td></tr>"})}v(".export-personal-data-handle").click(function(e){var r=v(this),i=r.parents(".export-personal-data"),d=r.parents("tr"),t=i.data("request-id"),a=i.data("nonce"),c=i.data("exporters-count"),l=!!i.data("send-as-email");function u(e){h(i,"export-personal-data-failed"),e&&x(d,"notice-error",f.exportError,[e])}e.preventDefault(),e.stopPropagation(),i.blur(),g(d),h(i,"export-personal-data-processing"),function n(o,s){v.ajax({url:window.ajaxurl,data:{action:"wp-privacy-export-personal-data",exporter:o,id:t,page:s,security:a,sendAsEmail:l},method:"post"}).done(function(e){var t,a=e.data;e.success?a.done?o<c?setTimeout(n(o+1,1)):(t=a.url,a=f.emailSent,h(i,"export-personal-data-success"),x(d,"notice-success",a,[]),r.hide(),void 0!==t?window.location=t:l||u(f.noExportFile)):setTimeout(n(o,s+1)):u(e.data)}).fail(function(e,t,a){u(a)})}(1,1)}),v(".remove-personal-data-handle").click(function(e){var s=v(this),r=s.parents(".remove-personal-data"),i=s.parents("tr"),t=r.data("request-id"),d=r.data("nonce"),c=r.data("erasers-count"),l=!1,u=!1,p=[];function m(){h(r,"remove-personal-data-failed"),x(i,"notice-error",f.removalError,[])}e.stopPropagation(),r.blur(),g(i),h(r,"remove-personal-data-processing"),function a(n,o){v.ajax({url:window.ajaxurl,data:{action:"wp-privacy-erase-personal-data",eraser:n,id:t,page:o,security:d},method:"post"}).done(function(e){var t=e.data;e.success?(t.items_removed&&(l=l||t.items_removed),t.items_retained&&(u=u||t.items_retained),t.messages&&(p=p.concat(t.messages)),t.done?n<c?setTimeout(a(n+1,1)):(e=f.noDataFound,t="notice-success",h(r,"remove-personal-data-success"),!1===l?!1===u?e=f.noDataFound:(e=f.noneRemoved,t="notice-warning"):!1===u?e=f.foundAndRemoved:(e=f.someNotRemoved,t="notice-warning"),x(i,t,e,p),s.hide()):setTimeout(a(n,o+1))):m()}).fail(function(){m()})}(1,1)}),v(document).on("click",function(e){var t,a,e=v(e.target);if(e.is("button.privacy-text-copy")&&(t=!(t=(e=e.parent().parent()).find("div.wp-suggested-text")).length?e.find("div.policy-text"):t).length)try{window.getSelection().removeAllRanges(),a=document.createRange(),t.addClass("hide-privacy-policy-tutorial"),a.selectNodeContents(t[0]),window.getSelection().addRange(a),document.execCommand("copy"),t.removeClass("hide-privacy-policy-tutorial"),window.getSelection().removeAllRanges()}catch(e){}})});