1$(document).ready(function () { 2 var $searchWidget = $('#search_widget'); 3 var $searchBox = $('#search_query_top'); 4 var searchURL = $('#searchbox').attr('data-search-controller-url'); 5 $.widget('prestashop.psBlockSearchAutocomplete', $.ui.autocomplete, { 6 delay: 0, 7 _renderItem: function (ul, product) { 8 var url_img=''; 9 if(typeof product.images[0] != 'undefined'){ 10 url_img=product.images[0].bySize.cart_default.url; 11 } 12 return $("<li>") 13 .append($("<a>") 14 .append($("<span class='left-search-ajax'>").html('<img src="'+ url_img +'">')) 15 .append($("<span class='right-search-ajax'>").html('<span class="search-name-ajax">'+product.name+'</span><span class="price-search-ajax">'+(product.regular_price!=product.price ? '<span class="price-regular-ajax">'+product.regular_price+'</span>' : '' )+'<span class="price-ajax">'+product.price+'</span></span>')) 16 ).appendTo(ul) 17 ; 18 } 19 }); 20 $searchBox.psBlockSearchAutocomplete({ 21 delay: 0, 22 source: function (query, response) { 23 $.get(searchURL,{ 24 s: query.term, 25 category_filter:$("#category_filter").val(), 26 resultsPerPage:20 27 }, null, 'json') 28 .then(function (resp) { 29 response(resp.products); 30 }) 31 .fail(response); 32 }, 33 select: function (event, ui) { 34 var url = ui.item.url; 35 window.location.href = url; 36 }, 37 }); 38 39 /* 40Reference: http://jsfiddle.net/BB3JK/47/ 41*/ 42 var $this = $('#category_filter'), numberOfOptions = $('#category_filter').children('option').length; 43 var $styledSelect = $this.next('div.select-styled'); 44 $styledSelect.text($this.children('option').eq(0).text()); 45 var $list = $('<ul />', { 46 'class': 'select-options' 47 }).insertAfter($styledSelect); 48 49 for (var i = 0; i < numberOfOptions; i++) { 50 $('<li />', { 51 text: $this.children('option').eq(i).text(), 52 rel: $this.children('option').eq(i).val() 53 }).appendTo($list); 54 } 55 56 var $listItems = $list.children('li'); 57 58 $styledSelect.click(function(e) { 59 e.stopPropagation(); 60 $('div.select-styled.active').not(this).each(function(){ 61 $(this).removeClass('active').next('ul.select-options').hide(); 62 }); 63 $(this).toggleClass('active').next('ul.select-options').toggle(); 64 }); 65 66 $listItems.click(function(e) { 67 e.stopPropagation(); 68 $styledSelect.text($(this).text()).removeClass('active'); 69 $this.val($(this).attr('rel')); 70 $list.hide(); 71 //console.log($this.val()); 72 }); 73 $('.search_filter .select-options li').each(function(){ 74 if($(this).attr('rel') == $('#category_filter option[selected="selected"]').attr('value')){ 75 $styledSelect.text($(this).text()).removeClass('active'); 76 } 77 }); 78 $(document).click(function() { 79 $styledSelect.removeClass('active'); 80 $list.hide(); 81 }); 82 83});
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.