## MAIN ##

#if( !$context.isAjaxRequest )
<div id="$!context.ns" class="lp-waste-search">
  <form class="lp-waste-search__form" method="post" action="$!context.formAction" data-ajax-url="$!context.ajaxUrl">
    <div class="lp-waste-search__form__search">
      <label class="lp-waste-search__form__search-label" for="$!{context.ns}__search-field">$!context.searchLabel</label>
      <input class="lp-waste-search__form__search-field" id="$!{context.ns}__search-field" autocomplete="off" placeholder="$!context.placeholder" type="text" name="$!context.queryParam" value="$!context.searchQuery">
    </div><!--! .lp-waste-search__form__search -->

    <div class="lp-waste-search__form__wildcard-submit">
      <input class="lp-waste-search__form__wildcard-field" id="$!{context.ns}__wildcard-field" type="checkbox" name="$!context.wildcardParam" value="1" #if( $context.wildcardValue != "" ) checked="checked" #{end}>
      <label class="lp-waste-search__form__wildcard-label" for="$!{context.ns}__wildcard-field">$!context.wildcardLabel</label>

      <button class="lp-waste-search__form__submit-button">Sök</button>
    </div><!--! .lp-waste-search__form__wildcard-submit -->
  </form>

  <div class="lp-waste-search__results">
#end

    #if( $context.hasItems )
      <p class="lp-waste-search__num-hits normal">$!context.numHitsText</p><!--! .lp-waste-search__num-hits -->

      <ul class="lp-waste-search__list">
        #foreach( $item in $context.items )
          <li class="lp-waste-search__list-item">
            <p class="normal">
              <strong class="lp-waste-search__waste-term">$!item.termName</strong><!--! .lp-waste-search__waste-term -->
              #if( $item.sortLinked )
                <a class="lp-waste-search__waste-sort" href="$!item.sortUrl">$!item.sortName</a><!--! .lp-waste-search__waste-sort -->
              #else
                <span class="lp-waste-search__waste-sort">$!item.sortName</span><!--! .lp-waste-search__waste-sort -->
              #end
            </p>

            #if( $item.location.hasLocation )
              <p class="lp-waste-search__waste-location normal">
                #if( $item.location.linked )
                  <a href="$!item.location.url">$!item.location.name</a>
                #else
                  <span>$!item.location.name</span>
                #end
              </p><!--! .lp-waste-search__waste-location -->
            #end
          </li><!--! .lp-waste-search__list-item -->
        #end
      </ul><!--! .lp-waste-search__list -->
    #end

#if( !$context.isAjaxRequest )
  </div><!--! .lp-waste-search__results -->

  <script>
    svDocReady(function () {
      if (lp && "wasteSearch" in lp) {
        var container = document.getElementById('$!context.ns');
        var opts = {};
        lp.wasteSearch.initialize(container, opts);
      }
    });
  </script>
</div><!--! .lp-waste-search -->
#end