1/** 2 * File newsletter-card.js. 3 * 4 * Kit's ck.5.js hides the newsletter <form> for recognized subscribers 5 * (return_visitor action "hide") â but only the form itself, which would 6 * leave the surrounding card copy floating above an empty hole. Mirror 7 * the form's hidden state onto the whole card. 8 */ 9(function () { 10 var CARD_SELECTOR = '.rd-footer__newsletter, .rd-home__hero-opt-in'; 11 var forms = document.querySelectorAll('form.newsletter-pill'); 12 13 forms.forEach(function (form) { 14 var card = form.closest(CARD_SELECTOR); 15 16 if (!card) { 17 return; 18 } 19 20 var sync = function () { 21 // covers both mechanisms: display:none set by ck.5.js, or the 22 // form being removed from the document entirely 23 var hidden = 24 !form.isConnected || getComputedStyle(form).display === 'none'; 25 card.hidden = hidden; 26 }; 27 28 sync(); 29 30 // Kit may decide after an async subscriber check â watch the form's 31 // attributes and re-sync 32 new MutationObserver(sync).observe(form, { 33 attributes: true, 34 attributeFilter: ['style', 'class', 'hidden'], 35 }); 36 37 // Kit escapes HTML in the success_message, so the green highlight 38 // can't ride along in data-options â wrap the phrase once Kit has 39 // swapped the success alert in. 40 var HIGHLIGHT_PHRASE = 'Youâre in.'; 41 var highlightSuccess = function () { 42 var alertEl = form.querySelector('.formkit-alert-success'); 43 44 if (!alertEl || alertEl.dataset.highlighted) { 45 return; 46 } 47 alertEl.dataset.highlighted = 'true'; 48 alertEl.innerHTML = alertEl.textContent.replace( 49 HIGHLIGHT_PHRASE, 50 '<span class="highlight">' + HIGHLIGHT_PHRASE + '</span>' 51 ); 52 }; 53 54 highlightSuccess(); 55 new MutationObserver(highlightSuccess).observe(form, { 56 childList: true, 57 subtree: true, 58 }); 59 }); 60})();
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.