1/* global $ */ 2$(document).ready(function () { 3 var $searchWidget = $('#search_widget'); 4 var $searchBox = $searchWidget.find('input[type=text]'); 5 var searchURL = location.protocol + '//' + $searchWidget.attr('data-search-controller-url') 6 7 $.widget('prestashop.psBlockSearchAutocomplete', $.ui.autocomplete, { 8 _renderItem: function (ul, product) { 9 return $("<li>") 10 .append($("<a>") 11 .append($("<span>").html(product.category_name).addClass("category")) 12 .append($("<span>").html(' > ').addClass("separator")) 13 .append($("<span>").html(product.name).addClass("product")) 14 ).appendTo(ul) 15 ; 16 } 17 }); 18 19 $searchBox.psBlockSearchAutocomplete({ 20 source: function (query, response) { 21 if ((typeof query.term === 'string' || query.term instanceof String) && query.term.length > 3) { 22 $.post( 23 searchURL, 24 { 25 s: query.term, 26 resultsPerPage: 10, 27 }, 28 null, 29 'json' 30 ) 31 .then(function (resp) { 32 response(resp.products) 33 }) 34 .fail(response) 35 } 36 return false; 37 }, 38 select: function (event, ui) { 39 var url = ui.item.url; 40 window.location.href = url; 41 }, 42 }); 43});
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.