Changeset 12386
- Timestamp:
- 02/03/2023 07:46:05 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-photos/js/attribution.js
r12385 r12386 6 6 7 7 function copyAttribution(event){ 8 document.addEventListener('copy', copyAttributionListener); 9 document.execCommand('copy'); 10 document.removeEventListener('copy', copyAttributionListener); 11 } 12 13 function copyAttributionListener(event) { 8 14 event.preventDefault(); 9 15 const attribution = document.querySelector('.attribution-text .tab.active'); 10 16 const copyButton = document.querySelector('.attribution-copy'); 11 17 12 let txt = attribution.innerHTML ;18 let txt = attribution.innerHTML.trim(); 13 19 14 20 if ( attribution.classList.contains('tab-html') ) { … … 16 22 } 17 23 18 navigator.clipboard.writeText(txt.trim()).then(res=>{ 19 copyButton.textContent = PhotoDir.copied_text; 20 setTimeout(function() { restoreCopyButtonText(); }, 4000); 21 function restoreCopyButtonText(){ copyButton.textContent = PhotoDir.copy_to_clipboard_text; } 22 }) 24 let html = attribution.classList.contains('tab-rich-text') ? txt : ''; 25 26 event.clipboardData.setData('text/html', html); 27 event.clipboardData.setData('text/plain', txt); 28 29 copyButton.textContent = PhotoDir.copied_text; 30 setTimeout(function() { restoreCopyButtonText(); }, 4000); 31 function restoreCopyButtonText(){ copyButton.textContent = PhotoDir.copy_to_clipboard_text; } 23 32 } 24 33
Note: See TracChangeset
for help on using the changeset viewer.