{crmScope extensionKey='dataprocessor'}
{assign var=fieldOp     value=$filterName|cat:"_op"}
{assign var=filterVal   value=$filterName|cat:"_value"}
{assign var=filterMin   value=$filterName|cat:"_min"}
{assign var=filterMax   value=$filterName|cat:"_max"}

<tr>
    <td class="label">{$filter.title}</td>
    <td>
      {if isset($form.$fieldOp.html)}
      <span class="filter-processor-element filter-{$filterName}">{$form.$fieldOp.html}</span>
      <span class="filter-processor-show-close filter-{$filterName}">&nbsp;</span>
      {/if}
    </td>
    <td>
      {if $filter.type == 'Date' || $filter.type == 'Timestamp'}
          {include file="CRM/Dataprocessor/Form/Filter/DateRange.tpl" fieldName=$filterName from='_low' to='_high'}
      {else}
          <span id="{$filterVal}_cell">{$form.$filterVal.label}&nbsp;{$form.$filterVal.html}</span>
          {if isset($form.$filterMin)}<span id="{$filterMin}_max_cell">{$form.$filterMin.label}&nbsp;{$form.$filterMin.html}&nbsp;&nbsp;{$form.$filterMax.label}&nbsp;{$form.$filterMax.html}</span>{/if}
      {/if}
    </td>
</tr>

{/crmScope}

{literal}
<script type="text/javascript">
  CRM.$(function($) {
    cj("#{/literal}{$fieldOp}{literal}").change(function() {
      var val = $(this).val();
      if (val == 'bw' || val == 'nbw') {
        cj("#{/literal}{$filterMin}_max_cell{literal}").removeClass('hiddenElement');
        cj("#{/literal}{$filterVal}_cell{literal}").addClass('hiddenElement');
      } else {
        cj("#{/literal}{$filterMin}_max_cell{literal}").addClass('hiddenElement');
        cj("#{/literal}{$filterVal}_cell{literal}").removeClass('hiddenElement');
      }

      if (val == 'current_user' || val == 'null' || val == 'not null') {
        cj("#{/literal}{$filterVal}{literal}").addClass('hiddenElement');
      } else {
        cj("#{/literal}{$filterVal}{literal}").removeClass('hiddenElement');
      }
    }).change();
  });
</script>
{/literal}
