/** * @file * Refreshes Altmetric badges inserted by Drupal AJAX or BigPipe. */ (function (Drupal, once) { 'use strict'; Drupal.behaviors.islandoraAltmetric = { attach(context) { // Altmetric scans the initial document itself. For later fragments, // request another scan only when a previously unseen badge is present. const candidates = Array.from(context.querySelectorAll('.altmetric-embed')); if (context.matches && context.matches('.altmetric-embed')) { candidates.push(context); } const badges = once('islandora-altmetric', candidates); if (context !== document && badges.length && typeof window._altmetric_embed_init === 'function') { window._altmetric_embed_init(); } } }; })(Drupal, once);