1jQuery(document).ready(function ($){ 2 3 var acs_action = 'greenmart_autocomplete_search'; 4 5 $("input[name=s]").autocomplete({ 6 source: function(req, response){ 7 $.ajax({ 8 url: greenmart_ajax.ajaxurl+'?callback=?&action='+acs_action, 9 dataType: "json", 10 data: { 11 term : req.term, 12 category : $(".tbay-search-form .dropdown_product_cat").val(), 13 post_type : $(".tbay-search-form .post_type").val() 14 }, 15 success: function(data,event, ui) { 16 response(data); 17 }, 18 }); 19 }, 20 minLength: 2, 21 autoFocus: true, 22 search: function(event, ui) { 23 $(event.currentTarget).parents('.tbay-search-form').addClass('load'); 24 }, 25 select: function(event, ui) { 26 window.location.href = ui.item.link; 27 }, 28 create: function() { 29 30 $(this).data('ui-autocomplete')._renderItem = function( ul, item ) { 31 var string = ''; 32 if ( item.image != '' ) { 33 var string = '<a href="' + item.link + '" title="'+ item.label +'"><img class="pull-left" src="'+ item.image+'" style="margin-right:10px;"></a>'; 34 } 35 string = string + '<div class="name"><a href="' + item.link + '" title="'+ item.label +'">'+ item.label +'</a></div>'; 36 if ( item.price != '' ) { 37 string = string + '<div class="price">'+ item.price +'</div> '; 38 } 39 return $( "<li>" ).append( string ).appendTo( ul ); 40 }; 41 42 }, 43 response: function(event, ui) { 44 // ui.content is the array that's about to be sent to the response callback. 45 if (ui.content.length === 0) { 46 $(".tbay-preloader").text("No results found"); 47 $(".tbay-preloader").addClass('no-results'); 48 } else { 49 $(".tbay-preloader").empty(); 50 $(".tbay-preloader").removeClass('no-results'); 51 } 52 }, 53 open: function(event, ui) { 54 $(event.target).parents('.tbay-search-form').removeClass('load'); 55 $(event.target).parents('.tbay-search-form').addClass('active'); 56 }, 57 close: function() { 58 } 59 }); 60 61 $('.tbay-preloader').on('click', function(){ 62 $(this).parents('.tbay-search-form').removeClass('active'); 63 $(this).parents('.tbay-search-form').find('input[name=s]').val(''); 64 }); 65 66});
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.