1var viewall = $('.search-viewall').val(); 2function formatResultData(resultObject){ 3 var results = ''; 4 if (resultObject.AutoSuggestObjectList.length > 0) { 5 results = '<div class="gobal-result-list">'; 6 for (var i = 0; i < 5; i++) { 7 if(resultObject.AutoSuggestObjectList[i] != undefined){ 8 if (resultObject.AutoSuggestObjectList[i].Type == 1) { 9 results += '<a class="videolink" href="#videomodal" tabindex="' + i + '" data-src=' + resultObject.AutoSuggestObjectList[i].Url + ' data-toggle="modal">' + resultObject.AutoSuggestObjectList[i].Title + '</a>' 10 } 11 else if (resultObject.AutoSuggestObjectList[i].Type == 2) { 12 if (resultObject.AutoSuggestObjectList[i].ShowDownloadForm == "False" || resultObject.AutoSuggestObjectList[i].ShowDownloadForm == "false") { 13 results += '<a class="downloadMediaCookie" tabindex="' + i + '" data-form=' + resultObject.AutoSuggestObjectList[i].Url + ' href=' + resultObject.AutoSuggestObjectList[i].Url + '>' + resultObject.AutoSuggestObjectList[i].Title + '</a>'; 14 } 15 else { 16 results += '<a tabindex="' + i + '" data-form=' + resultObject.AutoSuggestObjectList[i].Url + ' href=' + resultObject.AutoSuggestObjectList[i].Url + '>' + resultObject.AutoSuggestObjectList[i].Title + '</a>'; 17 } 18 } 19 else{ 20 results += '<a tabindex="' + i + '" href=' + resultObject.AutoSuggestObjectList[i].Url + '>' + resultObject.AutoSuggestObjectList[i].Title + '</a>'; 21 } 22 } 23 } 24 results += '<a href="javascript:void(0)" tabindex="5" class="view-more"> ' + viewall + ' </a>'; 25 } 26 27 return results; 28} 29 30$(function () { 31 var minlength = 3; 32 var currentRequest = null; 33 var requestInitiated = false; 34 $(".global-search").keyup(function () { 35 var value = $(this).val().replace(/[^\w\s]/gi, ' ').trim(); 36 var resultString = ''; 37 if (value.length >= minlength) { 38 currentRequest = $.ajax({ 39 type: "GET", 40 url: "/api/sitecore/Product/AutoSuggestion?keywords=" + value, 41 dataType: "json", 42 beforeSend: function () { 43 $('.gobal-result-list').remove(); 44 if(requestInitiated){ 45 currentRequest.abort(); 46 } 47 requestInitiated = true; 48 }, 49 success: function (res) { 50 resultString = formatResultData(res); 51 }, 52 complete: function(){ 53 $('#filterglobalsearchinput').parent().append(resultString); 54 requestInitiated = false; 55 } 56 }); 57 } 58 else { 59 if(currentRequest != null){ 60 currentRequest.abort(); 61 } 62 $('.gobal-result-list').remove(); 63 } 64 }); 65 66 $(document).on('keydown', '.global-search', function(e){ 67 if($('.global-search').val().length > 2 && $('.gobal-result-list a').length > 0){ 68 if (e.keyCode == 40) { 69 e.preventDefault(); 70 $('.gobal-result-list').on('focus', 'a', function () { 71 $this = $(this); 72 $this.addClass('active').siblings().removeClass('active'); 73 $this.closest('.gobal-result-list').scrollTop($this.index() * $this.outerHeight()); 74 }).on('keydown', 'a', function (e) { 75 $this = $(this); 76 if (e.keyCode == 40) { 77 $this.next().focus(); 78 return false; 79 } else if (e.keyCode == 38) { 80 $this.prev().focus(); 81 return false; 82 } 83 }).find('a').first().focus(); 84 } 85 } 86 }) 87 88 $(".globalsearchinput").keyup(function () { 89 var value = $(this).val().replace(/[^\w\s]/gi, ' ').trim(); 90 var resultString = ''; 91 if (value.length >= minlength) { 92 currentRequest = $.ajax({ 93 type: "GET", 94 url: "/api/sitecore/Product/AutoSuggestion?keywords=" + value, 95 dataType: "json", 96 beforeSend: function () { 97 $('.gobal-result-list').remove(); 98 if(requestInitiated){ 99 currentRequest.abort(); 100 } 101 requestInitiated = true; 102 }, 103 success: function (res) { 104 resultString = formatResultData(res); 105 }, 106 complete: function(){ 107 $('#Search-form .searchinput').append(resultString); 108 requestInitiated = false; 109 } 110 }); 111 } 112 else { 113 if(currentRequest != null){ 114 currentRequest.abort(); 115 } 116 $('.gobal-result-list').remove(); 117 } 118 }); 119}); 120 121 122$(document).on('keydown', '.globalsearchinput', function(e){
123 if($('.globalsearchinput').val().length > 2 && $('.gobal-result-list a').length > 0){ 124 if (e.keyCode == 40) { 125 e.preventDefault(); 126 $('.gobal-result-list').on('focus', 'a', function () { 127 $this = $(this); 128 $this.addClass('active').siblings().removeClass('active'); 129 $this.closest('.gobal-result-list').scrollTop($this.index() * $this.outerHeight()); 130 }).on('keydown', 'a', function (e) { 131 $this = $(this); 132 if (e.keyCode == 40) { 133 $this.next().focus(); 134 return false; 135 } else if (e.keyCode == 38) { 136 $this.prev().focus(); 137 return false; 138 } 139 }).find('a').first().focus(); 140 } 141 } 142}); 143 144$('.search-result-list').on('focus', 'a', function () { 145 $this = $(this); 146 $this.addClass('active').siblings().removeClass('active'); 147 $this.closest('.search-result-list').scrollTop($this.index() * $this.outerHeight()); 148}).on('keydown', 'a', function (e) { 149 $this = $(this); 150 if (e.keyCode == 40) { 151 $this.next().focus(); 152 return false; 153 } else if (e.keyCode == 38) { 154 $this.prev().focus(); 155 return false; 156 } 157}).find('a').first().focus(); 158 159 160$(document).on('click', function (e) { 161 if ($(e.target).hasClass('global-search')) { 162 $(".gobal-result-list").css('display', 'block'); 163 $('.global-search').addClass('focusin'); 164 e.stopImmediatePropagation(); 165 } 166 else { 167 $(".gobal-result-list").css('display', 'none'); 168 $('.global-search').removeClass('focusin'); 169 } 170}) 171 172$(document).on('click', '.gobal-result-list a', function (e) { 173 if (e.target.className.indexOf('view-more') >= 0) { 174 var text = $('.global-search').val(); 175 window.location.href = window.location.origin + '/search/searchresults?SearchText=' + text 176 } 177 $(".gobal-result-list").css('display', 'none'); 178 $('.global-search').removeClass('focusin'); 179 180}) 181 182$(document).on('click', '.search-result-list a', function (e) { 183 $(".search-result-list").css('display', 'none'); 184 185}) 186 187// costume code added 188$(document).on("click", ".global-search", function () { 189 if ($(window).width() < 1024) { 190 //$(this).css({"position": "fixed", "top": "0px", "left": "0px", "margin": "0px 15px !important"}); 191 $('.global-search').addClass('control'); 192 $('.search-box-wrapper').addClass('remove-margin'); 193 $('.back-icon').show(); 194 $('.global-search').css('background-image', 'none'); 195 } 196}); 197 198 199if ($(window).width() > 1024) { 200 $('.search-box-wrapper').removeClass('remove-margin'); 201} 202$('.back-icon').click(function () { 203 $('.global-search').removeClass('control'); 204 $('.search-box-wrapper').removeClass('remove-margin'); 205 $('.back-icon').hide(); 206 $('.global-search').css('background-image', ''); 207 208}); 209 210// when user click outside of box search result list hide 211 212 213$(document).on('click', function (e) { 214 if (e.target.className == "globalsearchinput" || e.target.className == "search-result-list") { 215 $(".search-result-list").css('display', 'block'); 216 e.stopImmediatePropagation(); 217 } 218 else { 219 $(".search-result-list").css('display', 'none'); 220 } 221})
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.