{% set title = _('Search') %}
{% extends "basic/layout.html" %}

{% set theme_css_files = [] %}

{% set theme_css_files = theme_css_files + [
    '_static/skuid.css',
    '_static/bootstrap.css'
  ]
%}

{% set css_files = css_files + theme_css_files %}

{% set script_files = script_files + [
    '_static/js/jquery-1.11.0.min.js',
    '_static/js/jquery-fix.js',
    '_static/js/bootstrap.js',
    '_static/js/skuid-sphinx.js'
  ]
%}

{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and sidebars %}

{%- set bs_content_width = render_sidebar and "9" or "12"%}

{%- block doctype -%}
<!DOCTYPE html>
{%- endblock %}

{% macro navBar() %}
{% include "navbar.html" %}
{% endmacro %}

{%- block extrahead %}
<title>Search</title>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="https://use.fontawesome.com/685baec918.js"></script>

<!-- Algolia -->

<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@2.7.4"></script>

{% raw %}
<!-- Algolia template-->
<script type="text/html" id="hit-template">
  <div class="hit">
    <div class="hit-content">
      <h2 class="hit-name"><a href="{{{fixedURL}}}">{{{_highlightResult.hierarchy.lvl1.value}}}</a></h2>
      <p class="hit-text">{{{_highlightResult.content.value}}}</p>
      <p class="hit-url">{{{fixedURL}}}</p>
    </div>
  </div>
</script>


{% endraw %}

<!-- Version warning -->

<script type="text/html" id="version-warning">
  <div class="version-warning-box">
      <div class="version-warning-header"> <i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
 Heads up!</div>
      <div class="version-warning-text">
        <p><b>Warning: As we improve our search functionality, these results currently reflect <i>only</i> the latest version of our documentation. If you are an older version of Skuid, your results may vary.</b></p>
        <p>If you selected this iteration of our documentation, you’re on an older version of Skuid and don’t have access to useful features available in the latest version. <a href="https://www.skuid.com/releases/salesforce/">Time to upgrade!</a></p>
        <p>Using <b>Skuid Platform</b>? <a href="https://docs.skuid.com" title="Go to latest" id="goToLatest">See the latest version of our docs.</a></p>
      </div>
    </div>
  </div>
</script>
{% if theme_analytics_id %}
<!-- Google Analytics -->
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', '{{theme_analytics_id}}', 'auto');
  ga('create', '{{theme_analytics_id_docs}}', 'auto', 'docsTracker');
  ga('require', 'GTM-5BPVR8V');
  ga('send', 'pageview');
  ga('docsTracker.send', 'pageview');
</script>
{% endif %}

{% if theme_marketo_id %}
<script type="text/javascript">
  (function() {
    var didInit = false;
    function initMunchkin() {
      if(didInit === false) {
        didInit = true;
        Munchkin.init('{{ theme_marketo_id }}');
      }
    }
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.async = true;
    s.src = '//munchkin.marketo.net/munchkin.js';
    s.onreadystatechange = function() {
      if (this.readyState == 'complete' || this.readyState == 'loaded') {
        initMunchkin();
      }
    };
    s.onload = initMunchkin;
    document.getElementsByTagName('head')[0].appendChild(s);
  })();
</script>
<!-- Marketo UTM magic -->
<script type="text/javascript" src="https://www.skuid.com/wp-content/mu-plugins/core-plugin/resources/js/utms.js"></script>
{% endif %}

<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,500,500i" rel="stylesheet">

{% endblock %}

{# Silence the sidebar's, relbar's #}
{% block header %}{% endblock %}
{% block relbar1 %}{% endblock %}
{% block relbar2 %}{% endblock %}
{% block sidebarsourcelink %}{% endblock %}

{%- block content %}
<div id="app">
{{ navBar() }}
  <div class="container">
    <div id="main" class="search-body" style="max-width:initial">
      {% block body %}
      <div id="search-page-body">
      <div class="input-group">
            <input type="text" id="navbar-search" name="q" class="form-control" placeholder="Search the docs">
            <span class="input-group-btn">
              <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
            </span>
          </div>
      </form>
      <div id="stats"></div>
      <div id="hits"> </div>
      <div id="pagination"></div>
      <script type="text/javascript">
        var instantsearchOptions = {
          appId: '61R1U0YAQZ',
          apiKey: '66f6a5ab961e9853c48afa683d800f92',
          indexName: 'latest',
          routing: {
            stateMapping: {
              stateToRoute(uiState) {
                return {
                  query: uiState.q,
                  page: uiState.page
                };
              },
              routeToState(routeState) {
                return {
                  query: routeState.q,
                  page: routeState.page
                };
              }
            }
          },
          searchParameters: {
            hitsPerPage:10
          }
        }
        const search = instantsearch(instantsearchOptions);
        // initialize SearchBox
          search.addWidget(
            instantsearch.widgets.searchBox({
              container: '#navbar-search',
              placeholder: 'Search Skuid docs'

            })
          );
          // init stats widget
          {% raw %}
          search.addWidget(
            instantsearch.widgets.stats({
              container: '#stats',
              templates: {
                body: '{{nbHits}} results'
              }
            })
          )
          {% endraw %}
          // initialize hits widget
          search.addWidget(
            instantsearch.widgets.hits({
              container: '#hits',
              templates: {
                item: document.getElementById('hit-template').innerHTML,
                empty: "We didn't find any results."
              },
              transformData: {
                item: function(data) {
                      if (isLatest == true){
                        data.fixedURL = data.url.replace(/docs.skuid.com\/.*?\//,"docs.skuid.com/latest/");
                      }
                      if (isLatest == false) {
                        data.fixedURL = data.url.replace(/docs.skuid.com\/.*?\//,"docs.skuid.com/v{{ theme_version }}/");
                      }
                  return data
                }
              }
            })
          );
          // Pagination
          search.addWidget(
            instantsearch.widgets.pagination({
              container: '#pagination',
              showFirstLast: false,
              labels: {
                previous: '<i class="fa fa-angle-left" aria-hidden="true"></i>',
                next: '<i class="fa fa-angle-right" aria-hidden="true"></i>',
              },
              placeholder: 'Search Skuid docs'
            })
          );

        var waitForVer = function() {
          if (typeof isLatest !== "undefined") {
            search.start();
          } else {
            setTimeout(waitForVer, 250)
          }
        }
        waitForVer()
      </script>

      {% endblock %}
    </div>
  </div>
  </div>


{%- endblock %}

{%- block footer %}
  <footer>
    <div class="footer-page">
      <p class="back-to-top"><a href="#">Back to top</a></p>
        {%- if last_updated %}
      <p>{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}</p>
        {%- endif %}
    </div>
    <div class="footer-site">
      <div class="footer-content">
        <h3>About Skuid</h3>
        <p>Bespoke UX at blazing speed.™ It means giving you tailored solutions at the speed of your business. It's what Skuid believes in. It's what we enjoy doing. We create the tools. You invent the solutions. No code. No kidding.™</p>
        <p>Chattanooga | San Francisco | London | Zürich</p>
        <p>Have feedback? Contact us at <a href="mailto:documentation@skuid.com" style="color: #ee8b21;">documentation@skuid.com</a>.</p>
        {% if show_copyright %}
        <p class="copyright"> &copy; Copyright Skuid, Inc. 2015-{{ theme_copyright_year }} | All rights reserved. <a href="https://docs.skuid.com/latest/{{ theme_lang }}/skuid/skuid_terms_conditions.html">Legal terms and conditions.</a></p>
        {% endif %}
      </div>
        {% if theme_visit_link and theme_visit_link_text %}
      <a href="{{ theme_visit_link }}" class="btn-visit">{{ theme_visit_link_text }}</a>
        {% endif %}
    </div>
</footer>
</div>
{%- endblock %}
