1(function (Drupal, once) { 2 'use strict'; 3 4 Drupal.behaviors.notificationMarquee = { 5 attach: function (context) { 6 once('nm-marquee', '.nm-wrapper', context).forEach(function (wrapper) { 7 var track = wrapper.querySelector('.nm-marquee-track'); 8 var control = wrapper.querySelector('.nm-control'); 9 10 if (!track) { 11 return; 12 } 13 14 // Duplicate items once so the loop (translateX -50%) is seamless. 15 if (!track.dataset.duplicated) { 16 track.innerHTML += track.innerHTML; 17 track.dataset.duplicated = 'true'; 18 } 19 20 if (control) { 21 var isPaused = false; 22 23 control.addEventListener('click', function () { 24 isPaused = !isPaused; 25 track.classList.toggle('nm-paused', isPaused); 26 27 control.innerHTML = isPaused 28 ? '<svg viewBox="0 0 24 24"><path d="M8 5v14l11-7z"/></svg>' // play icon 29 : '<svg viewBox="0 0 24 24"><path d="M6 5h4v14H6zM14 5h4v14h-4z"/></svg>'; // pause icon 30 31 control.setAttribute('aria-label', isPaused ? 'Play notifications' : 'Pause notifications'); 32 }); 33 } 34 35 // Pause on hover for readability, resume on mouse leave (only if not manually paused). 36 wrapper.addEventListener('mouseenter', function () { 37 track.classList.add('nm-paused'); 38 }); 39 wrapper.addEventListener('mouseleave', function () { 40 if (control && control.getAttribute('aria-label') !== 'Play notifications') { 41 track.classList.remove('nm-paused'); 42 } 43 }); 44 }); 45 } 46 }; 47 48 Drupal.behaviors.notificationCategoryFilter = { 49 attach: function (context) { 50 once('nm-category-filter', '.nm-category-nav', context).forEach(function (nav) { 51 // Event delegation on the nav container itself, and fresh queries on 52 // every click, so this keeps working even if the DOM around it 53 // changes (e.g. via AJAX) after this behavior first attaches. 54 nav.addEventListener('click', function (event) { 55 var button = event.target.closest('.nm-category-nav__item'); 56 if (!button || !nav.contains(button)) { 57 return; 58 } 59 60 var filter = button.getAttribute('data-nm-filter'); 61 var buttons = nav.querySelectorAll('.nm-category-nav__item'); 62 var groups = document.querySelectorAll('.nm-category-block[data-nm-category]'); 63 var emptyState = document.querySelector('.nm-empty-state--filtered'); 64 65 buttons.forEach(function (b) { b.classList.remove('is-active'); }); 66 button.classList.add('is-active'); 67 68 var visibleCount = 0; 69 groups.forEach(function (group) { 70 var match = filter === 'all' || group.getAttribute('data-nm-category') === filter; 71 group.style.display = match ? '' : 'none'; 72 if (match) { 73 visibleCount++; 74 } 75 }); 76 77 if (emptyState) { 78 emptyState.hidden = visibleCount !== 0; 79 } 80 }); 81 }); 82 } 83 }; 84 85})(Drupal, once);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.