1/** 2 * @file 3 * Global utilities. 4 * 5 */ 6(function (Drupal) { 7 'use strict'; 8 9 Drupal.behaviors.bootstrap = { 10 attach: function (context, settings) { 11 var position = window.scrollY; 12 window.addEventListener('scroll', function () { 13 if (window.scrollY > 50) { 14 document.querySelector('body').classList.add('scrolled'); 15 } else { 16 document.querySelector('body').classList.remove('scrolled'); 17 } 18 var scroll = window.scrollY; 19 if (scroll > position) { 20 document.querySelector('body').classList.add('scrolldown'); 21 document.querySelector('body').classList.remove('scrollup'); 22 } else { 23 document.querySelector('body').classList.add('scrollup'); 24 document 25 .querySelector('body') 26 .classList.remove('scrolldown'); 27 } 28 position = scroll; 29 }); 30 31 document.addEventListener( 32 'click', 33 function (event) { 34 // If the clicked element doesn't have the right selector, bail 35 if ( 36 !event.target.matches('.dropdown-item a.dropdown-toggle') 37 ) 38 return; 39 40 // Don't follow the link 41 event.preventDefault(); 42 43 toggle(event.target.next('ul')); 44 event.stopPropagation(); 45 }, 46 false 47 ); 48 49 // Toggle element visibility 50 var toggle = function (elem) { 51 // If the element is visible, hide it 52 if (window.getComputedStyle(elem).display === 'block') { 53 hide(elem); 54 return; 55 } 56 57 // Otherwise, show it 58 show(elem); 59 }; 60 61 var show = function (elem) { 62 elem.style.display = 'block'; 63 }; 64 65 var hide = function (elem) { 66 elem.style.display = 'none'; 67 }; 68 }, 69 }; 70})(Drupal);
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.