1 2document.addEventListener('DOMContentLoaded', function() { 3 var cartIcon = document.querySelector('.cart-icon'); 4 var cartPanel = document.querySelector('.cart-panel'); 5 var closeIcon = document.querySelector('.panel-close-btn'); 6 var body = document.body; 7 var delay; 8 9 cartIcon.addEventListener('click', function(e) { 10 e.preventDefault(); 11 cartPanel.classList.add('cart-panel-open'); 12 e.stopPropagation(); 13 }); 14 15 closeIcon.addEventListener('click', function(e) { 16 e.preventDefault(); 17 cartPanel.classList.remove('cart-panel-open'); 18 e.stopPropagation(); 19 }); 20 21 body.addEventListener('click', function(e) { 22 clearTimeout(delay); 23 24 delay = setTimeout(function() { 25 if (!cartPanel.contains(e.target) && e.target !== cartIcon) { 26 cartPanel.classList.remove('cart-panel-open'); 27 } 28 }, 10); 29 }); 30 31 // Prevent clicks inside the panel from closing it immediately 32 cartPanel.addEventListener('click', function(e) { 33 e.stopPropagation(); 34 }); 35});
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.