Files
chrnx-dev-wp/assets/js/track-share.js
T
chrnx 76917decd0 feat(editorial): widen sections and add local track pages
Unify the editorial canvas across section pages, keep release tracks out of Journal, and give each song a listening surface with audio, metadata, platform links, sharing, and optional featured art. Document and seed the local The No Names fixture without changing production data.
2026-08-27 20:24:39 -05:00

33 lines
937 B
JavaScript

( function () {
'use strict';
document.addEventListener( 'click', function ( event ) {
const button = event.target.closest( '[data-chrnx-share]' );
if ( ! button ) {
return;
}
const title = button.dataset.shareTitle || document.title;
const url = button.dataset.shareUrl || window.location.href;
const done = function () {
const original = button.dataset.originalLabel || button.textContent;
button.dataset.originalLabel = original;
button.textContent = 'Enlace copiado';
window.setTimeout( function () {
button.textContent = original;
}, 1800 );
};
if ( navigator.share ) {
navigator.share( { title, url } ).catch( function () {} );
return;
}
if ( navigator.clipboard && navigator.clipboard.writeText ) {
navigator.clipboard
.writeText( url )
.then( done )
.catch( function () {} );
}
} );
} )();