PageSourceSearch

https://www.discmedi.com/modules/stsearchbar/views/js/stsearchbar.js

js discmedi.com collected 2026-10-02 06:08:25 UTC 4,632 bytes, 85 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	quick_search_as_init();
33	$(document).on('click', '.search_more_products', function(e){
34		$(this).closest('.search_widget').find('form').submit();
35	});
36});
37
38var quick_search_as_init = function(){
39	if(quick_search_as)
40		$('.search_widget').each(function(){
41	    	var search_url     = $(this).data('search-controller-url');
42			var search_results = $(this).find('.search_results');
43			var search_more_products = $(this).find('.search_more_products');
44			var search_btn = $(this).find('.search_widget_btn');
45			$(this).find('.search_widget_text').devbridgeAutocomplete({
46				noCache: true,
47				paramName: 's',
48	            params: {resultsPerPage: quick_search_as_size, is_ajax_search: 1},
49	            dataType: 'json',
50				minChars: quick_search_as_min,
51				appendTo: search_results,
52				triggerSelectOnValidInput: false,
53				showNoSuggestionNotice: true,
54	            noSuggestionNotice: $('.search_no_products').html(),
55				serviceUrl: search_url,
56				onSearchStart: function() {
57					search_btn.addClass('active');
58				},
59				onSearchComplete: function() {
60					search_btn.removeClass('active');
61				},
62				transformResult: function(response) {
63					var suggestions = $.map(response.products, function(dataItem) {
64			                return { value: dataItem.name, data: dataItem };
65			            });
66			        return {
67			            suggestions: suggestions
68			        };
69			    },
70			    beforeRender: function (container, suggestions) {
71					if(suggestions.length==quick_search_as_size)
72						$(container).append(search_more_products.clone());
73			    },
74				formatResult: function(suggestion, currentValue) {
75					var result = '<a href="'+suggestion.data.link+'" title="'+suggestion.data.name+'" rel="nofollow" class="search_product_row flex_container">';
76						if (typeof(suggestion.data.cover)!='undefined' && suggestion.data.cover && typeof(suggestion.data.cover.bySize)!='undefined' && typeof(suggestion.data.cover.bySize.small_default)!='undefined' && suggestion.data.cover.bySize.small_default && typeof(suggestion.data.cover.bySize.small_default.url)!='undefined')
77							result += '<picture>'+(typeof(stwebp)!='undefined' && typeof(stwebp.small_default)!='undefined' && stwebp.small_default ? '<source srcset="'+suggestion.data.cover.bySize.small_default.url.replace(/\.jpg$/,'.webp')+'" type="image/webp">' : '')+(typeof(suggestion.data.cover.bySize.small_default.sources)!='undefined' && typeof(suggestion.data.cover.bySize.small_default.sources.webp)!='undefined' ? '<source srcset="'+suggestion.data.cover.bySize.small_default.sources.webp+'" type="image/webp">' : '')+(typeof(suggestion.data.cover.bySize.small_default.sources)!='undefined' && typeof(suggestion.data.cover.bySize.small_default.sources.avif)!='undefined' ? '<source srcset="'+suggestion.data.cover.bySize.small_default.sources.avif+'" type="image/avif">' : '')+'<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>';
78						result += '<div class="search_product_name flex_child search_result_item">' + suggestion.data.name + '</div>';
79						result += '<div class="search_product_price search_result_item price">' + (suggestion.data.has_discount ? suggestion.data.price : suggestion.data.regular_price) + '</div>';
80						result += '</a>';
81					return result;
82				}
83			});
84		});
85};

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.