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