Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Refactor js

michal44dba5294069
diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.js
index 739d9c1475..a28d98e79c 100644
--- a/saleor/static/js/storefront.js
+++ b/saleor/static/js/storefront.js
@@ -376,16 +376,16 @@ $('.toggle-filter').each(function(){
let icon = $(this).find('.collapse-filters-icon');
let ele = $(this).find('.filter-form-field');
- let filter_arrow_down = '/static/assets/chevron_down.svg';
- let filter_arrow_up = '/static/assets/chevron_up.svg';
+ let filter_arrow_down = $('.product-filters__attributes').data('icon-down');
+ let filter_arrow_up = $('.product-filters__attributes').data('icon-up');
$(this).find('.filter-label').on('click', () => {
- if(ele.css("display") == "block") {
- ele.css("display", "none");
- icon.html('<img src="' + filter_arrow_down + '">');
+ if(ele.css('display') == 'block') {
+ ele.css('display', 'none');
+ icon.find('img').attr('src', filter_arrow_down);
} else {
- ele.css("display", "block");
- icon.html('<img src="' + filter_arrow_up + '">');
+ ele.css('display', 'block');
+ icon.find('img').attr('src', filter_arrow_up);
}
});
})
diff --git a/templates/category/index.html b/templates/category/index.html
index 6b3851c6f5..cbacd7b6bb 100644
--- a/templates/category/index.html
+++ b/templates/category/index.html
@@ -94,7 +94,7 @@
<span class="clear-filters float-right" onClick="">{% trans 'Clear filters' context 'Category page filters' %}</span>
</h2>
<div class="product-filters">
- <div class="product-filters__attributes">
+ <div class="product-filters__attributes" data-icon-up="{% static "assets/chevron_up.svg" %}" data-icon-down="{% static "assets/chevron_down.svg" %}">
<form method="get">
{% for field in filter.form %}
{% if field.label == 'Price' %}