1// http://stackoverflow.com/a/9609450 2var decodeEntities = (function () { 3 // this prevents any overhead from creating the object each time 4 var element = document.createElement('div'); 5 6 function decodeHTMLEntities(str) { 7 if (str && typeof str === 'string') { 8 // strip script/html tags 9 str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gim, ''); 10 str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gim, ''); 11 element.innerHTML = str; 12 str = element.textContent; 13 element.textContent = ''; 14 } 15 16 return str; 17 } 18 19 return decodeHTMLEntities; 20})(); 21 22(function ($, Proud) { 23 Proud.behaviors.proud_search = { 24 attach: function (context, settings) { 25 if ( 26 settings.proud_actions_app && 27 settings.proud_actions_app.global.search_granicus_site 28 ) { 29 // settings.proud_actions_app.global.search_granicus_site 30 Proud.behaviors.granicus_search = function (newValue) { 31 console.log(settings); 32 console.log(this); 33 }.bind(settings); 34 } 35 36 var location = 37 window.location.protocol + 38 '//' + 39 window.location.hostname + 40 window.location.pathname; 41 42 var $body = $('body'), 43 searchPage = $body.hasClass('search-site'); // on search page? 44 45 // analytics for search page 46 if (searchPage) { 47 $body.once('proud-search-ga', function () { 48 if (typeof ga === 'undefined') { 49 return; 50 } 51 // Send page view 52 /** 53 * @todo remove this kept around as reference during switch to new GA4 54 * method below. Has no ulitity after we verify this works 55 ga('send', { 56 hitType: 'event', 57 eventCategory: 'SearchCustom', 58 eventLabel: settings.proud_search.global.search_term, 59 eventAction: location, 60 }); 61 */ 62 63 gtag( 'event', 'pcsearch', { 64 'hitType': 'event', 65 'eventCategory': 'SearchCustom', 66 'eventabel': settings.proud_search.global.search_term, 67 'eventAction': location, 68 }); 69 70 // setup results clicks 71 $('.search-title a').click(function (e) { 72 /** 73 * @todo remove this kept around as reference during switch to new GA4 74 * method below. Has no ulitity after we verify this works 75 ga('send', { 76 hitType: 'event', 77 eventCategory: 'SearchCustomClick', 78 eventLabel: e.target.text, 79 eventAction: e.target.href, 80 }); 81 **/ 82 83 gtag( 'event', 'pcsearchtitleclick', { 84 'hitType': 'event', 85 'eventCategory': 'SearchCustomClick', 86 'eventabel': e.target.text, 87 'eventAction': e.target.href, 88 }); 89 }); 90 }); 91 } 92 93 // Init Angular Search module 94 var $searchForm = $('#wrapper-search'); 95 if ($searchForm.length && !$searchForm.hasClass('ng-scope')) { 96 angular.module('proudSearchParent', ['ProudBase', 'ProudSearch']); 97 angular.bootstrap($searchForm, ['proudSearchParent']); 98 } 99 100 /** 101 * Once we're selected, make sure we close once focus is lost 102 * @param {*} e 103 */ 104 function focusCheck(e) { 105 if (!$('#wrapper-search').find(e.relatedTarget || e.target).length) { 106 if ( 107 $body.hasClass('search-active') || 108 $body.hasClass('search-active-lite') 109 ) { 110 Proud.proudNav.triggerOverlay('search', null, null); 111 } 112 113 // clear focusCheck 114 $(document).off('focusout', '#wrapper-search', focusCheck); 115 } 116 } 117 118 // Search box in content (not overlay) 119 // Attach overlay open 120 $('.wrap #wrapper-search').once('proud-search', function () { 121 $('#proud-search-input').on('focus', function () { 122 if ( 123 !$body.hasClass('search-active') && 124 !$body.hasClass('search-active-lite') 125 ) { 126 Proud.proudNav.triggerOverlay('search', null, null); 127 128 // Watch for out of focus 129 $(document).off('focusout', '#wrapper-search', focusCheck); 130 $(document).on('focusout', '#wrapper-search', focusCheck); 131 } 132 }); 133 }); 134 135 $body.on('proudNavClick', function (event) { 136 switch (event['event']) { 137 case 'search': 138 event.callback(true, false, false, false, function () { 139 if ( 140 $body.hasClass('search-active') || 141 $body.hasClass('search-active-lite') 142 ) { 143 var $input = $('#proud-search-input'); 144 $input.focus(); 145 // Put at end 146 setTimeout(function () { 147 $input[0].selectionStart = $input[0].selectionEnd = 10000; 148 }, 0); 149 150 // Watch for out of focus 151 $(document).off('focusout', '#wrapper-search', focusCheck); 152 $(document).on('focusout', '#wrapper-search', focusCheck); 153 } 154 }); 155 break; 156 } 157 }); 158 }, 159 }; 160})(jQuery, Proud);
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.