На фильтре не срабатывает кнопка Reset (Сбросить) Есть решение

Здравствуйте.

У фильтра не срабатывает кнопка сбросить фильтр, переделывал тему гипермаркет, все функции использовал гипермаркета, всё работает, кроме долбанной кнопки сброса фильтра, уже просто устал! Причину найти не могу.

Вот сайт - Ссылка



Код:

{strip}

<div class="catalog-filters" id="s-category-filters">
    {foreach $filters as $_filter}
        {if !empty($_filter.type) && $_filter.type === "range.date"}
            {$_lang = substr($wa->locale(), 0, 2)}
            <link href="{$wa_url}wa-content/css/jquery-ui/base/jquery.ui.all.css?v={$wa->version(true)}" rel="stylesheet" />
            <script src="{$wa_url}wa-content/js/jquery-ui/jquery.ui.core.min.js?v={$wa->version(true)}"></script>
            <script src="{$wa_url}wa-content/js/jquery-ui/jquery.ui.datepicker.min.js?v={$wa->version(true)}"></script>
            {if $_lang !== "en"}
                <script src="{$wa_url}wa-content/js/jquery-ui/i18n/jquery.ui.datepicker-{$wa->locale()}.js"></script>
            {/if}
            {break}
        {/if}
    {/foreach}

    <form method="get" action="{$wa->currentUrl(0,1)}">
        <header class="s-filters-header">
            <h4 class="s-header">[`Filters`]:</h4>
        </header>

        {foreach $filters as $fid => $filter}
            {$_is_selected = false}
            {if $fid == &#039;price&#039;}
                {if $wa->get(&#039;price_min&#039;)}
                    {$_is_selected = true}
                {/if}
                {if $wa->get(&#039;price_max&#039;)}
                    {$_is_selected = true}
                {/if}
            {else}
                {if $filter.type == &#039;boolean&#039;}
                    {if $wa->get($filter.code)}
                        {$_is_selected = true}
                    {/if}
                    {if $wa->get($filter.code) === &#039;0&#039;}
                        {$_is_selected = true}
                    {/if}
                    {*{if $wa->get($filter.code, &#039;&#039;) === &#039;&#039;}*}
                        {*{$_is_selected = true}*}
                    {*{/if}*}
                {elseif isset($filter.min)}
                    {if !empty($_v.min)}
                        {$_is_selected = true}
                    {/if}
                    {if !empty($_v.max)}
                        {$_is_selected = true}
                    {/if}
                {else}
                    {foreach $filter.values as $v_id => $v}
                        {if in_array( $v_id, (array)$wa->get($filter.code, array()) )}
                            {$_is_selected = true}
                        {/if}
                    {/foreach}
                {/if}
            {/if}

            <div class="catalog-filters-block">
                {if $fid == &#039;price&#039;}
                    {$c = $wa->shop->currency(true)}
                        <div class="catalog-filters-block__title">Выберите цену</div>
                        <div class="catalog-filters-block-content">
                            <div class="catalog-filter-price">
                                <div class="catalog-filter-price-fields" data-min="{floor($filter.min)}" data-max="{ceil($filter.max)}">
                                    <div class="catalog-filter-price-fields-input">
                                        <input type="text" class="price-slider__min input min" name="price_min" {if $wa->get(&#039;price_min&#039;)}value="{(int)$wa->get(&#039;price_min&#039;)}"{/if} placeholder="{floor($filter.min)}">
                                    </div>
                                    <div class="catalog-filter-price-fields-divider"><span></span></div>
                                    <div class="catalog-filter-price-fields-input">
                                        <input type="text" class="price-slider__max input max" name="price_max" {if $wa->get(&#039;price_max&#039;)}value="{(int)$wa->get(&#039;price_max&#039;)}"{/if} placeholder="{ceil($filter.max)}">
                                    </div>
                                </div>
                                <div class="catalog-filter-price-slider">
                                    <div class="price-slider"></div>
                                </div>
                            </div>
                        </div>
                {else}
                    <div class="catalog-filters-block__title">{$filter.name|escape}</div>

                    <div class="catalog-filters-block-content">
                        {if $filter.type == "boolean"}
                            <div class="catalog-filters-item">
                                <div class="radio">        
                                    <label>                                        
                                    
                                        <input type="radio" name="{$filter.code}" value="1" {if $wa->get($filter.code)}checked{/if}>
                                        [`Yes`]
                                    </label>
                                </div>
                            </div>
                            <div class="catalog-filters-item">
                                <div class="radio">                                                
                                    <label>                                        
                                    
                                        <input type="radio" name="{$filter.code}" value="0" {if $wa->get($filter.code) === &#039;0&#039;}checked{/if}>
                                        [`No`]
                                    </label>
                                </div>
                            </div>
                            <div class="catalog-filters-item">
                                <div class="radio">                                                
                                    <label>                                        
                                        <input type="radio" name="{$filter.code}" value="" {if $wa->get($filter.code, &#039;&#039;) === &#039;&#039;}checked{/if}>
                                        [`Any`]
                                    </label>
                                </div>
                            </div>
                        
                        {elseif $filter.type == "range.date"}
                            <div class="s-filter-item s-range-date-item" id="js-filter-{$filter.id|escape}" data-min="{$filter.min}" data-max="{$filter.max}">
                                <div class="s-datepicker-wrapper">
                                    <span class="s-label">[`from`]</span>
                                    <div class="s-fields">
                                        <input class="js-datepicker" type="text" value="{if !empty($_v.min)}{$_v.min|wa_date}{/if}" placeholder="{$filter.min|wa_date}">
                                        <input name="{$filter.code}[min]" type="hidden" value="{if !empty($_v.min)}{$_v.min}{/if}">
                                    </div>
                                </div>
                                <div class="s-datepicker-wrapper">
                                    <span class="s-label">[`to`]</span>
                                    <div class="s-fields">
                                        <input class="js-datepicker" type="text" value="{if !empty($_v.max)}{$_v.max|wa_date}{/if}" placeholder="{$filter.max|wa_date}">
                                        <input name="{$filter.code}[max]" type="hidden" value="{if !empty($_v.max)}{$_v.max}{/if}">
                                    </div>
                                </div>

                                <script>
                                    ( function($) {
                                        var $filter = $("#js-filter-{$filter.id|escape}");
                                        $filter.find(".js-datepicker").each( function() { initDatepicker( $(this) ); });

                                        function initDatepicker($datepicker) {
                                            var $altField = $datepicker.parent().find("input[type=&#039;hidden&#039;]");
                                            $datepicker.datepicker({
                                                altField: $altField,
                                                altFormat: "yy-mm-dd",
                                                minDate: formatDate($filter.data("min")),
                                                maxDate: formatDate($filter.data("max")),
                                                changeMonth: true,
                                                changeYear: true
                                            });

                                            $datepicker.on("change", function() {
                                                var value = $datepicker.val();
                                                if (!value) {
                                                    $altField.val("");
                                                }
                                            });

                                            function formatDate(date_string) {
                                                var date_array = date_string.split("-");
                                                var year = date_array[0],
                                                    mount = date_array[1] - 1,
                                                    day = date_array[2];
                                                return new Date(year, mount, day);
                                            }
                                        }
                                    })(jQuery);
                                </script>
                            </div>
                        {elseif isset($filter.min)}
                            <div class="s-filter-item s-range-item" data-min="{$filter.min}" data-max="{$filter.max}">
                                [`from`]
                                <input type="text" class="min" name="{$filter.code}[min]" placeholder="{$filter.min}" {if !empty($_v.min)}value="{$_v.min}"{/if}>
                                [`to`]
                                <input type="text" class="max" name="{$filter.code}[max]" placeholder="{$filter.max}" {if !empty($_v.max)}value="{$_v.max}"{/if}>
                                {if !empty($filter.unit)}
                                    {$filter.unit.title}
                                    {if $filter.unit.value != $filter.base_unit.value}<input type="hidden" name="{$filter.code}[unit]" value="{$filter.unit.value}">{/if}
                                {/if}
                            </div>
                        {else}
                            {foreach $filter.values as $v_id => $v}
                                {if $filter.name === &#039;Цвет&#039;}
                                    <div class="s-filter-item is-checkbox-item catalog-filters-item checkbox">
                                            <label class="checkbox-label checkbox-cvet {if in_array($v_id, (array)$wa->get($filter.code, array()))}checkedLabel{/if}">
                                                <input type="checkbox" class="checkbox-input" name="{$filter.code}[]" id="{$v_id}" {if in_array($v_id, (array)$wa->get($filter.code, array()))}checked{/if} value="{$v_id}">{$v}
                                                <span class="checked-span"></span>
                                            </label> 
                                    </div>

                                {else}
                                    <div class="s-filter-item is-checkbox-item catalog-filters-item checkbox">
                                            <label class="checkbox-label {if in_array($v_id, (array)$wa->get($filter.code, array()))}checkedLabel{/if}">
                                                <input type="checkbox" name="{$filter.code}[]" id="{$v_id}" {if in_array($v_id, (array)$wa->get($filter.code, array()))}checked{/if} value="{$v_id}">{$v}
                                                <span class="checked-span"></span>
                                            </label>
                                    </div>
                                {/if}

                            {/foreach}
                        {/if}
                    </div>
                {/if}
            </div>
        {/foreach}

        <footer class="s-buttons-wrapper">
            <input class="s-button reset" type="reset" value="[`Reset`]">
            <input class="s-button" type="submit" value="[`Filter products`]">
            {if $wa->get(&#039;sort&#039;)}<input type="hidden" name="sort" value="{$wa->get(&#039;sort&#039;)|escape}">{/if}
            {if $wa->get(&#039;order&#039;)}<input type="hidden" name="order" value="{$wa->get(&#039;order&#039;)|escape}">{/if}
        </footer>

    </form>

    <script>
        (function($) {
            new window.waTheme.init.shop.ProductsFilter({
                $wrapper: $("#s-category-filters")
            });
        })(jQuery);
    </script>

    <script>
        var checkboxLabel = document.querySelectorAll(&#039;.checkbox-label&#039;);

        for(let i = 0; i < checkboxLabel.length; i++) {

            checkboxLabel[i].addEventListener(&#039;change&#039;, function() {
            checkboxLabel[i].classList.toggle(&#039;checkedLabel&#039;);

            })

        }
    </script>

</div>

{/strip}

2 ответа

Добавить ответ

Чтобы добавить комментарий, зарегистрируйтесь или войдите