1/* 2* 2007-2016 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-2016 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 var mytab = []; 50 for (var i = 0; i < data.length; i++) 51 mytab[mytab.length] = { data: data[i], value: data[i].cname + ' > ' + data[i].pname }; 52 return mytab; 53 }, 54 extraParams: { 55 ajaxSearch: 1, 56 id_lang: id_lang 57 } 58 } 59 ) 60 .result(function(event, data, formatted) { 61 $input.val(data.pname); 62 document.location.href = data.product_link; 63 }); 64 } 65 66 if (typeof instantsearch != 'undefined' && instantsearch) { 67 $input.on('keyup', function(){ 68 if($(this).val().length > 4) 69 { 70 stopInstantSearchQueries(); 71 instantSearchQuery = $.ajax({ 72 url: search_url + '?rand=' + new Date().getTime(), 73 data: { 74 instantSearch: 1, 75 id_lang: id_lang, 76 q: $(this).val() 77 }, 78 dataType: 'html', 79 type: 'POST', 80 headers: { "cache-control": "no-cache" }, 81 async: true, 82 cache: false, 83 success: function(data){ 84 if ($input.val().length > 0) { 85 tryToCloseInstantSearch(); 86 $('#center_column').attr('id', 'old_center_column'); 87 $('#old_center_column').after('<div id="center_column" class="' + $('#old_center_column').attr('class') + '">' + data + '</div>').hide(); 88 // Button override 89 ajaxCart.overrideButtonsInThePage(); 90 $("#instant_search_results a.close").on('click', function() { 91 $input.val(''); 92 return tryToCloseInstantSearch(); 93 }); 94 return false; 95 } 96 else 97 tryToCloseInstantSearch(); 98 } 99 }); 100 instantSearchQueries.push(instantSearchQuery); 101 } 102 else 103 tryToCloseInstantSearch(); 104 }); 105 } 106}); 107 108function tryToCloseInstantSearch() 109{ 110 var $oldCenterColumn = $('#old_center_column'); 111 if ($oldCenterColumn.length > 0) 112 { 113 $('#center_column').remove(); 114 $oldCenterColumn.attr('id', 'center_column').show(); 115 return false; 116 } 117} 118 119function stopInstantSearchQueries() 120{ 121 for(var i=0; i<instantSearchQueries.length; i++) 122 instantSearchQueries[i].abort(); 123 instantSearchQueries = []; 124} 125 126document.addEventListener('DOMContentLoaded', function () { 127 document.body.addEventListener('click', function (e) { 128 const trigger = e.target.closest('.search-trigger'); 129 if (!trigger) return; // not a search trigger click 130 const targetId = trigger.getAttribute('data-target'); 131 if (!targetId) return console.warn('No data-target on search trigger'); 132 133 const overlay = document.getElementById(targetId); 134 if (!overlay) return console.warn('No overlay found with id:', targetId); 135 136 // â Open overlay 137 overlay.hidden = false; 138 overlay.classList.add('open'); 139 const input = overlay.querySelector('.search_query'); 140 if (input) input.focus(); 141 142 // Optional: close on click outside or ESC 143 overlay.addEventListener('click', function (e) { 144 if (e.target === overlay) { 145 overlay.hidden = true; 146 overlay.classList.remove('open'); 147 } 148 }); 149 150 document.addEventListener('keydown', function escClose(ev) { 151 if (ev.key === 'Escape' && !overlay.hidden) { 152 overlay.hidden = true; 153 overlay.classList.remove('open'); 154 document.removeEventListener('keydown', escClose); 155 } 156 }); 157 }); 158}); 159 160
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.