1(function ($, Drupal, drupalSettings) { 2// 3 Drupal.behaviors.searchApiAutocomplete = { 4 attach: function (context, settings) { 5 $('input[data-search-api-autocomplete-search]') 6 .each(function () { 7 var uiAutocomplete = $(this).data('ui-autocomplete'); 8 if (!uiAutocomplete) { 9 return; 10 } 11 12 var $element = uiAutocomplete.menu.element; 13 $element.addClass('o-search-results-autocomplete'); 14 15 uiAutocomplete.options.open = function (e) { 16 17 //Move search results down 18 var $input = $(e.target); 19 var $results = $input.autocomplete("widget"); 20 var $top = $results.position().top; 21 var $newTop = $top + 20; 22 $results.css("top", $newTop + "px"); 23 24 var block_html = drupalSettings.search_api_autocomplete.block_html; 25 var searched_term = uiAutocomplete.term; 26 $element.prepend('<h3>Suggestions</h3>'); 27 $element.append('<div class="o-search-results-autocomplete__see-all"><a href="/search?for=' + searched_term + '">See all for: ' + searched_term + '</a></div>'); 28 $element.append('<div class="o-search-results-autocomplete__popular-themes">' + block_html + '</div>'); 29 }; 30 31 uiAutocomplete.options.select = function (event, ui) { 32 // If this is a URL suggestion, instead of autocompleting we 33 // redirect the user to that URL. 34 if (ui.item.url) { 35 location.href = ui.item.url; 36 return false; 37 } 38 39 var ret = oldSelect.apply(this, arguments); 40 41 // If auto-submit is enabled, submit the form. 42 if (elementSettings['auto_submit'] && elementSettings['selector']) { 43 $(elementSettings['selector'], this.form).trigger('click'); 44 } 45 46 return ret; 47 }; 48 49 }) 50 51 } 52 } 53})(jQuery, Drupal, drupalSettings);
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.