PageSourceSearch

https://gacel.cl/themes/child_panda/modules/stsearchbar/views/js/stsearchbar.js

js gacel.cl collected 2026-10-08 15:47:54 UTC 4,108 bytes, 82 lines download raw bytes

1/*
2* 2007-2017 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    ST-themes <[email protected]>
21*  @copyright 2007-2017 ST-themes
22*  @license   Use, by you or one client for one Prestashop instance.
23*/
24if(typeof(quick_search_as_size) === 'undefined')
25	var quick_search_as_size = 6;
26if(typeof(quick_search_as_min) === 'undefined')
27	var quick_search_as_min = 3;
28if(typeof(quick_search_as) === 'undefined')
29	var quick_search_as = true;
30
31$(document).ready(function () {
32	if(quick_search_as)
33		$('.search_widget').each(function(){
34	    	var search_url     = $(this).data('search-controller-url');
35			var search_results = $(this).find('.search_results');
36			var search_more_products = $(this).find('.search_more_products');
37			var search_btn = $(this).find('.search_widget_btn');
38			$(this).find('.search_widget_text').devbridgeAutocomplete({
39				noCache: true,
40				paramName: 's',
41	            params: {resultsPerPage: quick_search_as_size, is_ajax_search: 1},
42	            dataType: 'json',
43				minChars: quick_search_as_min,
44				appendTo: search_results,
45				triggerSelectOnValidInput: false,
46				showNoSuggestionNotice: true,
47	            noSuggestionNotice: $('.search_no_products').html(),
48				serviceUrl: search_url,
49				onSearchStart: function() {
50					search_btn.addClass('active');
51				},
52				onSearchComplete: function() {
53					search_btn.removeClass('active');
54				},
55				transformResult: function(response) {
56					var suggestions = $.map(response.products, function(dataItem) {
57			                return { value: dataItem.name, data: dataItem };
58			            });
59			        return {
60			            suggestions: suggestions
61			        };
62			    },
63			    beforeRender: function (container, suggestions) {
64					if(suggestions.length==quick_search_as_size)
65						$(container).append(search_more_products.clone());
66			    },
67				formatResult: function(suggestion, currentValue) {
68					var result = '<a href="'+suggestion.data.link+'" title="'+suggestion.data.name+'" rel="nofollow" class="search_product_row flex_container">';
69						if (typeof(suggestion.data.cover)!='undefined' && suggestion.data.cover && typeof(suggestion.data.cover.bySize)!='undefined' && typeof(suggestion.data.cover.bySize.small_default.url)!='undefined')
70							result += '<picture>'+(typeof(stwebp)!='undefined' && typeof(stwebp.small_default)!='undefined' && stwebp.small_default ? '<!--[if IE 9]><video style="display: none;"><![endif]--><source srcset="'+suggestion.data.cover.bySize.small_default.url.replace(/\.jpg$/,'.webp')+'" type="image/webp"><!--[if IE 9]></video><![endif]-->' : '')+'<img class="search_product_img search_result_item" alt="'+suggestion.data.name+'" src="' + suggestion.data.cover.bySize.small_default.url + '" width="' + suggestion.data.cover.bySize.small_default.width + '" height="' + suggestion.data.cover.bySize.small_default.height + '"/></picture>';
71						result += '<div class="search_product_name flex_child search_result_item">' + suggestion.data.name + '</div>';
72						result += '<div class="search_product_price search_result_item price">' + (suggestion.data.has_discount ? suggestion.data.price : suggestion.data.regular_price) + '</div>';
73						result += '</a>';
74					return result;
75				}
76			});
77		});
78	$(document).on('click', '.search_more_products', function(e){
79		$(this).closest('.search_widget').find('form').submit();
80	});
81	
82});

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.