first commit
This commit is contained in:
59
themes/ayon/modules/ps_searchbar/ps_searchbar.js
Normal file
59
themes/ayon/modules/ps_searchbar/ps_searchbar.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/* global $ */
|
||||
$(document).ready(function () {
|
||||
|
||||
// roythemes mod
|
||||
var $searchWidget = $('.header-top .search-widget');
|
||||
var $searchWidgetSide = $('.side_menu .search-widget');
|
||||
var $searchBox = $searchWidget.find('input[type=text]');
|
||||
var $searchBoxSide = $searchWidgetSide.find('input[type=text]');
|
||||
var searchURL = $searchWidget.attr('data-search-controller-url');
|
||||
var searchURLSide = $searchWidgetSide.attr('data-search-controller-url');
|
||||
|
||||
$.widget('prestashop.psBlockSearchAutocomplete', $.ui.autocomplete, {
|
||||
_renderItem: function (ul, product) {
|
||||
var line = $("<li>") // roythemes mod
|
||||
.append($("<a>").addClass("searchLine")
|
||||
.append('<img src="'+product.cover.small.url+'" class="searchImg">')
|
||||
.append($("<div>").addClass("searchDescription")
|
||||
.append($("<span>").html(product.name).addClass("product"))
|
||||
.append($("<span>").html(product.price).addClass("searchPrice"))
|
||||
)
|
||||
).appendTo(ul);
|
||||
return line;
|
||||
}
|
||||
});
|
||||
|
||||
$searchBox.psBlockSearchAutocomplete({
|
||||
source: function (query, response) {
|
||||
$.post(searchURL, {
|
||||
s: query.term,
|
||||
resultsPerPage: 10
|
||||
}, null, 'json')
|
||||
.then(function (resp) {
|
||||
response(resp.products);
|
||||
})
|
||||
.fail(response);
|
||||
},
|
||||
select: function (event, ui) {
|
||||
var url = ui.item.url;
|
||||
window.location.href = url;
|
||||
},
|
||||
});
|
||||
$searchBoxSide.psBlockSearchAutocomplete({
|
||||
source: function (query, response) {
|
||||
$.post(searchURLSide, {
|
||||
s: query.term,
|
||||
resultsPerPage: 6
|
||||
}, null, 'json')
|
||||
.then(function (resp) {
|
||||
response(resp.products);
|
||||
})
|
||||
.fail(response);
|
||||
},
|
||||
appendTo: "#search_results",
|
||||
select: function (event, ui) {
|
||||
var url = ui.item.url;
|
||||
window.location.href = url;
|
||||
},
|
||||
});
|
||||
});
|
||||
12
themes/ayon/modules/ps_searchbar/ps_searchbar.tpl
Normal file
12
themes/ayon/modules/ps_searchbar/ps_searchbar.tpl
Normal file
@@ -0,0 +1,12 @@
|
||||
<!-- Block search module TOP -->
|
||||
<div class="search-widget{if isset($roythemes.search_lay)} search{$roythemes.search_lay}{/if}" data-search-controller-url="{$search_controller_url}">
|
||||
<form method="get" action="{$search_controller_url}">
|
||||
<input type="hidden" name="controller" value="search">
|
||||
<input type="text" name="s" value="{$search_string}" placeholder="{if isset($roythemes.search_lay) && $roythemes.search_lay == "4"}{l s='Search' d='Shop.Theme.Catalog'}{else}{l s='Start typing here...' d='Shop.Theme.Catalog'}{/if}" aria-label="{l s='Search' d='Shop.Theme.Catalog'}">
|
||||
<button type="submit" {if isset($roythemes.search_lay) && $roythemes.search_lay !== "4"}class="search_nogo"{/if}>
|
||||
<i class="rts" data-size="28" data-color="#000000">{if isset($roythemes.nc_i_search)}{$roythemes.nc_i_search}{else}search1{/if}</i>
|
||||
<span class="text hidden-xl-down">{if isset($roythemes.search_lay) && $roythemes.search_lay !== "4"}{l s='Search' d='Shop.Theme.Catalog'}{/if}</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<!-- /Block search module TOP -->
|
||||
Reference in New Issue
Block a user