1/** 2 * @file 3 * Readable / Unreadable font toggle for AMRO 26. 4 * 5 * Readable: Headlines in League Mono Bold 6 * Unreadable: Headlines in AMRO26 Fingerprint Mono 7 */ 8(function (Drupal, once) { 9 'use strict'; 10 11 var STORAGE_KEY = 'amro26_readability'; 12 13 function applyMode(mode) { 14 if (mode === 'unreadable') { 15 document.body.classList.add('amro-unreadable'); 16 document.body.classList.remove('amro-readable'); 17 } else { 18 document.body.classList.add('amro-readable'); 19 document.body.classList.remove('amro-unreadable'); 20 } 21 } 22 23 function getStoredMode() { 24 try { 25 return localStorage.getItem(STORAGE_KEY) || 'unreadable'; 26 } catch (e) { 27 return 'readable'; 28 } 29 } 30 31 function storeMode(mode) { 32 try { 33 localStorage.setItem(STORAGE_KEY, mode); 34 } catch (e) { 35 // Storage not available. 36 } 37 } 38 39 // Apply stored mode immediately to avoid flash of wrong font. 40 applyMode(getStoredMode()); 41 42 Drupal.behaviors.amroReadabilityToggle = { 43 attach: function (context) { 44 once('readability-toggle', '[data-readability-toggle]', context).forEach(function (btn) { 45 var currentMode = getStoredMode(); 46 applyMode(currentMode); 47 updateButton(btn, currentMode); 48 49 btn.addEventListener('click', function () { 50 var mode = document.body.classList.contains('amro-unreadable') ? 'readable' : 'unreadable'; 51 applyMode(mode); 52 storeMode(mode); 53 updateButton(btn, mode); 54 }); 55 }); 56 } 57 }; 58 59 function updateButton(btn, mode) { 60 var readableLabel = btn.querySelector('.amro-readability-label--readable'); 61 var unreadableLabel = btn.querySelector('.amro-readability-label--unreadable'); 62 var knob = btn.querySelector('.amro-readability-knob'); 63 64 if (mode === 'unreadable') { 65 btn.classList.add('is-unreadable'); 66 btn.setAttribute('aria-pressed', 'true'); 67 } else { 68 btn.classList.remove('is-unreadable'); 69 btn.setAttribute('aria-pressed', 'false'); 70 } 71 } 72 73})(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.