1(function () { 2 'use strict'; 3 4 function setFlipped(card, flipped) { 5 card.classList.toggle('is-flipped', flipped); 6 card.setAttribute('aria-expanded', flipped ? 'true' : 'false'); 7 8 var back = card.querySelector('.ap-flip-back'); 9 var link = card.querySelector('.ap-flip-button'); 10 if (back) { 11 back.setAttribute('aria-hidden', flipped ? 'false' : 'true'); 12 } 13 if (link) { 14 link.setAttribute('tabindex', flipped ? '0' : '-1'); 15 } 16 } 17 18 function initialiseCard(card) { 19 if (card.getAttribute('data-ap-flip-ready') === 'true') { 20 return; 21 } 22 card.setAttribute('data-ap-flip-ready', 'true'); 23 24 card.addEventListener('click', function (event) { 25 if (event.target.closest && event.target.closest('a')) { 26 return; 27 } 28 // A mouse already gets the CSS hover interaction. Keep clicks for 29 // touch, keyboard-generated clicks and assistive technologies so a 30 // desktop click cannot leave the card stuck on its back face. 31 if (event.detail > 0 && window.matchMedia && window.matchMedia('(hover: hover) and (pointer: fine)').matches) { 32 return; 33 } 34 setFlipped(card, !card.classList.contains('is-flipped')); 35 }); 36 37 card.addEventListener('keydown', function (event) { 38 if (event.target !== card) { 39 return; 40 } 41 if (event.key === 'Enter' || event.key === ' ') { 42 event.preventDefault(); 43 setFlipped(card, !card.classList.contains('is-flipped')); 44 } else if (event.key === 'Escape') { 45 setFlipped(card, false); 46 } 47 }); 48 } 49 50 function initialiseWithin(scope) { 51 if (scope.matches && scope.matches('.ap-flip-card')) { 52 initialiseCard(scope); 53 } 54 if (scope.querySelectorAll) { 55 Array.prototype.forEach.call(scope.querySelectorAll('.ap-flip-card'), initialiseCard); 56 } 57 } 58 59 function boot() { 60 initialiseWithin(document); 61 62 document.addEventListener('click', function (event) { 63 Array.prototype.forEach.call(document.querySelectorAll('.ap-flip-card.is-flipped'), function (card) { 64 if (!card.contains(event.target)) { 65 setFlipped(card, false); 66 } 67 }); 68 }); 69 70 if (window.MutationObserver) { 71 var observer = new MutationObserver(function (mutations) { 72 Array.prototype.forEach.call(mutations, function (mutation) { 73 Array.prototype.forEach.call(mutation.addedNodes, function (node) { 74 if (node.nodeType === 1) { 75 initialiseWithin(node); 76 } 77 }); 78 }); 79 }); 80 observer.observe(document.body, {childList: true, subtree: true}); 81 } 82 } 83 84 if (document.readyState === 'loading') { 85 document.addEventListener('DOMContentLoaded', boot); 86 } else { 87 boot(); 88 } 89}());
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.