1/* 2* 2007-2015 PrestaShop 3* 4* NOTICE OF LICENSE 5* 6* This source file is subject to the Academic Free License (AFL 3.0) 7* that is bundled with this package in the file LICENSE.txt. 8* It is also available through the world-wide-web at this URL: 9* http://opensource.org/licenses/afl-3.0.php 10* If you did not receive a copy of the license and are unable to 11* obtain it through the world-wide-web, please send an email 12* to [email protected] so we can send you a copy immediately. 13* 14* DISCLAIMER 15* 16* Do not edit or add to this file if you wish to upgrade PrestaShop to newer 17* versions in the future. If you wish to customize PrestaShop for your 18* needs please refer to http://www.prestashop.com for more information. 19* 20* @author PrestaShop SA <[email protected]> 21* @copyright 2007-2015 PrestaShop SA 22* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 23* International Registered Trademark & Property of PrestaShop SA 24*/ 25 26var instantSearchQueries = []; 27$(document).ready(function() 28{ 29 if (typeof blocksearch_type == 'undefined') 30 return; 31 32 var $input = $("#search_query_" + blocksearch_type); 33 34 var width_ac_results = $input.parent('form').outerWidth(); 35 if (typeof ajaxsearch != 'undefined' && ajaxsearch) { 36 $input.autocomplete( 37 search_url, 38 { 39 minChars: 3, 40 max: 10, 41 width: (width_ac_results > 0 ? width_ac_results : 500), 42 selectFirst: false, 43 scroll: false, 44 dataType: "json", 45 formatItem: function(data, i, max, value, term) { 46 return value; 47 }, 48 parse: function(data) { 49 /* 50 var mytab = []; 51 for (var i = 0; i < data.length; i++) 52 mytab[mytab.length] = { data: data[i], value: data[i].cname + ' > ' + data[i].pname }; 53 return mytab; 54 */ 55 var mytab = new Array(); 56 if(data.length > 0){ 57 for (var i = 0; i < data.length; i++) { 58 if (data[i]['image_link']) { 59 var image = "<img src='" + data[i]['image_link'] + "' width='60px' height='60px' style='display:block; float:left; margin-right:5px;'/>"; 60 } else { 61 var image = ""; 62 } 63 64 var html = "<div style='border:1px solid #d6d4d4; margin-top:5px; padding: 5px; font-size: 12px;line-height:107%;'>"; 65 html += image; 66 html += "<p style='margin-bottom:3px;'>" + data[i].cname + " > " + data[i].pname + "</p>"; 67 html += "<div class='price product-price' style='font-size:12px; font-weight: bold;'>"+ data[i]['price'] +"</div>"; 68 html += "<div style='clear:both;'></div>"; 69 html += "</div>"; 70 71 mytab[mytab.length] = { 72 data: data[i], 73 value: html 74 }; 75 } 76 } 77 return mytab; 78 }, 79 extraParams: { 80 ajaxSearch: 1, 81 id_lang: id_lang 82 } 83 } 84 ) 85 .result(function(event, data, formatted) { 86 $input.val(data.pname); 87 document.location.href = data.product_link; 88 }); 89 } 90 91 if (typeof instantsearch != 'undefined' && instantsearch) { 92 $input.on('keyup', function(){ 93 if($(this).val().length > 4) 94 { 95 stopInstantSearchQueries(); 96 instantSearchQuery = $.ajax({ 97 url: search_url + '?rand=' + new Date().getTime(), 98 data: { 99 instantSearch: 1, 100 id_lang: id_lang, 101 q: $(this).val() 102 }, 103 dataType: 'html', 104 type: 'POST', 105 headers: { "cache-control": "no-cache" }, 106 async: true, 107 cache: false, 108 success: function(data){ 109 if ($input.val().length > 0) { 110 tryToCloseInstantSearch(); 111 $('#center_column').attr('id', 'old_center_column'); 112 $('#old_center_column').after('<div id="center_column" class="' + $('#old_center_column').attr('class') + '">' + data + '</div>').hide(); 113 // Button override 114 ajaxCart.overrideButtonsInThePage(); 115 $("#instant_search_results a.close").on('click', function() { 116 $input.val(''); 117 return tryToCloseInstantSearch(); 118 }); 119 return false; 120 } 121 else 122 tryToCloseInstantSearch(); 123 } 124 }); 125 instantSearchQueries.push(instantSearchQuery); 126 } 127 else 128 tryToCloseInstantSearch(); 129 }); 130 } 131}); 132 133function tryToCloseInstantSearch() 134{ 135 var $oldCenterColumn = $('#old_center_column'); 136 if ($oldCenterColumn.length > 0) 137 { 138 $('#center_column').remove(); 139 $oldCenterColumn.attr('id', 'center_column').show(); 140 return false;
141 } 142} 143 144function stopInstantSearchQueries() 145{ 146 for(var i=0; i<instantSearchQueries.length; i++) 147 instantSearchQueries[i].abort(); 148 instantSearchQueries = []; 149}
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.