1(function ($) { 2 'use strict'; 3 4 const searchPlaceholder = Drupal.t('Search FEMA.gov', {}, {context: 'Javascript'}); 5 const searchAlt = Drupal.t('Search icon', {}, {context: 'Javascript'}); 6 const searchLabel = Drupal.t('Enter Search Term(s):', {}, {context: 'Javascript'}); 7 8 Drupal.behaviors.usaSearchResizeBehavior = { 9 attach: function (context) { 10 11 var mobileBreakpoint = 1023; 12 // Resize timeout event ID. 13 var resizeTimeoutId; 14 // Resize timeout duration in milliseconds. 15 var resizeTimeoutDuration = 100; 16 17 const produceSearch = (searchForm,affiliate,query) => { 18 return '<div class="usasearch-search-block-form usa-form contextual-region block block-usasearch block-usasearch-search-form-block" role="search">' + 19 `<form id="${searchForm}" action="https://search.usa.gov/search" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓"/>` + 20 `<input type="hidden" name="affiliate" id="${affiliate}" value="fema"/>` + 21 `<label for="${query}" class="visually-hidden">${searchLabel}</label>` + 22 `<input class="usa-input" type="search" placeholder="${searchPlaceholder}" name="query" id="${query}" autocomplete="off" class="usagov-search-autocomplete"/>` + 23 '<div>'+ 24 `<input class="usa-button" type="submit" name="commit" value="${searchPlaceholder}" data-disable-with="Search">` + 25 `<img src="/profiles/femad8_gov/themes/fema_uswds/images/icon_search.svg" alt="${searchAlt}">` + 26 '</div>' + 27 '</form>' + 28 '</div>'; 29 }; 30 31 var resizeDebounce = function () { 32 clearTimeout(resizeTimeoutId); 33 resizeTimeoutId = setTimeout(doneResizing, resizeTimeoutDuration); 34 }; 35 36 var doneResizing = function () { 37 var width = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); 38 var mobileSearches = $('.mobile-usa-search'); 39 var desktopSearches = $('.desktop-usa-search'); 40 mobileSearches.each(function(i){ 41 if (width <= mobileBreakpoint) { 42 if ($(this).children().length === 0) { 43 var query = 'mobile_query_' + i; 44 var searchForm = 'mobile_search_form_' + i; 45 var affiliate = 'mobile_affiliate_' + i; 46 var search = produceSearch(searchForm,affiliate,query); 47 $(this).append(search) 48 } 49 }else{ 50 $(this).empty(); 51 } 52 }) 53 desktopSearches.each(function(i){ 54 if (width > mobileBreakpoint) { 55 if ($(this).children().length === 0) { 56 var query = 'desktop_query_' + i; 57 var searchForm = 'desktop_search_form_' + i; 58 var affiliate = 'desktop_affiliate_' + i; 59 var search = produceSearch(searchForm,affiliate,query); 60 $(this).append(search) 61 } 62 }else{ 63 $(this).empty(); 64 } 65 }) 66 }; 67 doneResizing(); 68 $(window).resize(resizeDebounce); 69 70 } 71 }; 72})(jQuery);
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.