forked from PrestaShop/hummingbird
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfacets.tpl
More file actions
265 lines (248 loc) · 13.5 KB
/
facets.tpl
File metadata and controls
265 lines (248 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
{**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*}
{$componentName = 'search-filters'}
{if $displayedFacets|count}
<div id="search-filters" class="{$componentName}" role="region" aria-label="{l s='Product filters' d='Shop.Theme.Global'}">
{block name='facets_title'}
<p class="left-block__title d-none d-md-block">
{l s='Filter By' d='Shop.Theme.Actions'}
</p>
{/block}
{block name='facets_clearall_button'}
{if $activeFilters|count}
<div class="{$componentName}__clear">
<button
data-search-url="{$clear_all_link}"
class="btn btn-outline-tertiary js-search-filters-clear-all"
>
<i class="material-icons" aria-hidden="true"></i>
{l s='Clear all' d='Shop.Theme.Actions'}
</button>
</div>
{/if}
{/block}
<div class="accordion accordion-flush accordion--small">
{foreach from=$displayedFacets item="facet" name="facets"}
<section class="accordion-item" data-type="{$facet.type}" data-name="{$facet.label}">
{assign var=_expand_id value=10|mt_rand:100000}
{assign var=_collapse value=true}
{foreach from=$facet.filters item="filter"}
{if $filter.active}{assign var=_collapse value=false}{/if}
{/foreach}
<button
class="accordion-button {if $_collapse} collapsed{/if}"
type="button"
data-bs-target="#facet_{$_expand_id}"
data-bs-toggle="collapse"
aria-expanded="{if !$_collapse}true{else}false{/if}"
>
{$facet.label}
</button>
<div id="facet_{$_expand_id}" class="accordion-collapse collapse{if !$_collapse} show{/if}">
{if in_array($facet.widgetType, ['radio', 'checkbox'])}
{block name='facet_item_other'}
<ul class="accordion-body">
{foreach from=$facet.filters key=filter_key item="filter"}
{assign var="isColorOrTexture" value=(isset($filter.properties.color) || isset($filter.properties.texture))}
{if !$filter.displayed}
{continue}
{/if}
<li>
<div class="{$componentName}__item facet-label{if $filter.active} active {/if}">
{if $facet.multipleSelectionAllowed}
<div class="{$componentName}__form-check{if $isColorOrTexture} {$componentName}__form-check--color{/if} form-check">
<input
class="form-check-input{if $isColorOrTexture} d-none{/if}"
id="facet_input_{$_expand_id}_{$filter_key}"
data-search-url="{$filter.nextEncodedFacetsURL}"
type="checkbox"
{if $filter.active }checked{/if}
>
<label
class="{$componentName}__form-label form-check-label"
for="facet_input_{$_expand_id}_{$filter_key}"
data-ps-ref="color-label"
>
{if isset($filter.properties.color)}
<span
class="color color-sm{if $filter.active } active{/if}"
style="background-color:{$filter.properties.color}"
role="checkbox"
aria-checked="{if $filter.active}true{else}false{/if}"
tabindex="0"
aria-labelledby="facet_label_{$_expand_id}_{$filter_key}"
></span>
<span class="{$componentName}__color-label" id="facet_label_{$_expand_id}_{$filter_key}">
{$filter.label}
{if $filter.magnitude and $show_quantities}
<span class="{$componentName}__magnitude">
({$filter.magnitude}<span class="visually-hidden">{if $filter.magnitude == 1}{l s='result' d='Shop.Theme.Global'}{else}{l s='results' d='Shop.Theme.Global'}{/if}</span>)
</span>
{/if}
</span>
{elseif isset($filter.properties.texture)}
<span
class="color color-sm{if $filter.active } active{/if}"
style="background-image:url({$filter.properties.texture})"
role="checkbox"
aria-checked="{if $filter.active}true{else}false{/if}"
tabindex="0"
aria-labelledby="facet_label_{$_expand_id}_{$filter_key}"
></span>
<span class="{$componentName}__color-label" id="facet_label_{$_expand_id}_{$filter_key}">
{$filter.label}
{if $filter.magnitude and $show_quantities}
<span class="{$componentName}__magnitude">
({$filter.magnitude}<span class="visually-hidden">{if $filter.magnitude == 1}{l s='result' d='Shop.Theme.Global'}{else}{l s='results' d='Shop.Theme.Global'}{/if}</span>)
</span>
{/if}
</span>
{else}
<a
href="{$filter.nextEncodedFacetsURL}"
class="{$componentName}__link search-link js-search-link"
rel="nofollow"
tabindex="-1"
>
{$filter.label}
{if $filter.magnitude and $show_quantities}
<span class="{$componentName}__magnitude">
({$filter.magnitude}<span class="visually-hidden">{if $filter.magnitude == 1}{l s='result' d='Shop.Theme.Global'}{else}{l s='results' d='Shop.Theme.Global'}{/if}</span>)
</span>
{/if}
</a>
{/if}
</label>
</div>
{else}
<div class="{$componentName}__form-check form-check">
<input
class="form-check-input"
id="facet_input_{$_expand_id}_{$filter_key}"
data-search-url="{$filter.nextEncodedFacetsURL}"
type="radio"
name="filter {$facet.label}"
{if $filter.active }checked{/if}
>
<label class="{$componentName}__form-label form-check-label" for="facet_input_{$_expand_id}_{$filter_key}">
<a
href="{$filter.nextEncodedFacetsURL}"
class="{$componentName}__link search-link js-search-link"
rel="nofollow"
tabindex="-1"
>
{$filter.label}
{if $filter.magnitude and $show_quantities}
<span class="{$componentName}__magnitude">
({$filter.magnitude}<span class="visually-hidden">{if $filter.magnitude == 1}{l s='result' d='Shop.Theme.Global'}{else}{l s='results' d='Shop.Theme.Global'}{/if}</span>)
</span>
{/if}
</a>
</label>
</div>
{/if}
</div>
</li>
{/foreach}
</ul>
{/block}
{elseif $facet.widgetType == 'dropdown'}
{block name='facet_item_dropdown'}
<ul class="accordion-body">
<li>
<div class="{$componentName}__item facet-dropdown dropdown">
<button class="{$componentName}__dropdown-toggle btn btn-outline-tertiary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{assign var="active_found" value=false}
{foreach from=$facet.filters item="filter"}
{if $filter.active}
{$filter.label}
{if $filter.magnitude and $show_quantities}
<span class="{$componentName}__magnitude">
({$filter.magnitude}<span class="visually-hidden">{if $filter.magnitude == 1}{l s='result' d='Shop.Theme.Global'}{else}{l s='results' d='Shop.Theme.Global'}{/if}</span>)
</span>
{/if}
{$active_found = true}
{/if}
{/foreach}
{if !$active_found}
{l s='(No option selected)' d='Shop.Theme.Global'}
{/if}
</button>
<div class="{$componentName}__dropdown-menu dropdown-menu dropdown-menu-start">
{foreach from=$facet.filters item="filter"}
{if !$filter.active}
<a
rel="nofollow"
href="{$filter.nextEncodedFacetsURL}"
class="dropdown-item select-list js-search-link"
>
{$filter.label}
{if $filter.magnitude and $show_quantities}
<span class="{$componentName}__magnitude">
({$filter.magnitude}<span class="visually-hidden">{if $filter.magnitude == 1}{l s='result' d='Shop.Theme.Global'}{else}{l s='results' d='Shop.Theme.Global'}{/if}</span>)
</span>
{/if}
</a>
{/if}
{/foreach}
</div>
</div>
</li>
</ul>
{/block}
{elseif $facet.widgetType == 'slider'}
{block name='facet_item_slider'}
{foreach from=$facet.filters item="filter"}
<div class="{$componentName}__slider-container accordion-body js-faceted-filter-slider">
<div
class="{$componentName}__slider js-faceted-slider-container"
data-slider-min="{$facet.properties.min}"
data-slider-max="{$facet.properties.max}"
data-slider-id="{$_expand_id}"
data-slider-values="{$filter.value|@json_encode}"
data-slider-unit="{$facet.properties.unit}"
{if isset($facet.properties.specifications.currencyCode) && $facet.properties.specifications.currencyCode != ''}
data-slider-currency="{$facet.properties.specifications.currencyCode}"
{/if}
data-slider-label="{$facet.label}"
data-slider-specifications="{$facet.properties.specifications|@json_encode}"
data-slider-encoded-url="{$filter.nextEncodedFacetsURL}"
data-slider-direction="{$language.is_rtl}"
></div>
<div class="{$componentName}__slider-values js-faceted-values"></div>
<input
type="hidden"
class="form-range-start js-faceted-slider js-faceted-slider-start"
id="slider-range_{$_expand_id}-start"
>
<input
type="hidden"
class="form-range-start js-faceted-slider js-faceted-slider-end"
id="slider-range_{$_expand_id}-end"
>
</div>
{/foreach}
{/block}
{/if}
</div>
</section>
{/foreach}
</div>
</div>
{/if}