{extends_parent}

<script>
   {block "filter-script-ajax-apend"}
      {$counter = 0}
      {foreach $body.dynamic_filter.parameters as $id_parameter => $parameter}
         {$s = $body.dynamic_filter.filter->getParameter($id_parameter, $parameter.value_type)}
         {if $s and $s.values and $parameter.value_type != "float" and $counter < 2}
            {$counter = $counter + 1}
            {$inputId = $parameter.name|strip_accent|replace:'-':'_'}
            var {$inputId} = $('[data-filters] [data-opener-param-{$id_parameter}]').find('input:checked');
            $('.secondary-filter-item [data-opener-param-{$id_parameter}-f]').find('.secondary-check').removeClass('checked');
            $({$inputId}).each(function (){
               $('.secondary-filter-item [data-opener-param-{$id_parameter}-f]').find('.check-' + $(this).val()).addClass('checked');
            });
         {/if}
      {/foreach}

      var filteredProducers = $('[data-filters] .filter-producers').find('input:checked');
      $('.secondary-filter-item [data-opener-producers-f]').find('.secondary-check').removeClass('checked');
      if(filteredProducers.length){
         filteredProducers.each(function (){
            $('.secondary-filter-item [data-opener-producers-f]').find('.check-' + $(this).val()).addClass('checked');
         });
      }
   {/block}
</script>

