b5baaf27e8
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
12 lines
970 B
JavaScript
12 lines
970 B
JavaScript
// partner kit pages (/partners/<slug>): copy buttons + toast (2026-09-29)
|
|
(function(){
|
|
var toast=document.getElementById('toast'),tm;
|
|
function say(t){toast.textContent=t;toast.classList.add('on');clearTimeout(tm);tm=setTimeout(function(){toast.classList.remove('on')},1400)}
|
|
function copy(text,btn){
|
|
function fallback(){var r=document.createRange();var el=btn.previousElementSibling||btn.parentElement;r.selectNodeContents(el);var s=getSelection();s.removeAllRanges();s.addRange(r);say('Select and copy')}
|
|
try{navigator.clipboard.writeText(text).then(function(){say('Copied')},fallback)}catch(e){fallback()}
|
|
}
|
|
document.querySelectorAll('[data-copy]').forEach(function(b){b.addEventListener('click',function(){copy(b.getAttribute('data-copy'),b)})});
|
|
document.querySelectorAll('[data-copy-el]').forEach(function(b){b.addEventListener('click',function(){var el=document.getElementById(b.getAttribute('data-copy-el'));copy(el.textContent,b)})});
|
|
})();
|