WordPress/wp-admin/js/privacy-tools.min.js
Andrea Fercia c4f6669d69 Accessibility: Privacy: Accessibility improvements for the Privacy Policy Guide page.
Improves accessibility of the "Copy this section" button and "Return to Top" link:
- uses `setTimeout()` and `clearTimeout()` to properly handle the "Copied!" text
- simplifies the button text by removing the redundant visually hidden text
- fixes the mismatching visual and DOM order of the Copy button and the "Return to Top" link 
- improves the "Return to Top" links by providing real page fragment identifiers, when possible
- hides the "Return to Top" up arrow from assistive technologies
- minor coding standards

Props afercia, garrett-eclipse.
See #48463, #50322.
Fixes #50335.

Built from https://develop.svn.wordpress.org/trunk@48234


git-svn-id: http://core.svn.wordpress.org/trunk@48003 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-30 13:56:03 +00:00

2 lines
4.1 KiB
JavaScript

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