{% load compress %}
{% load datepicker_locale from horizon %}

{% datepicker_locale as DATEPICKER_LOCALE %}

{% include "horizon/_script_i18n.html" %}

{% comment %} Compress jQuery, Angular, Plugins, Bootstrap, Hogan.js and Horizon-specific JS. {% endcomment %}
{% compress js %}
<script type="text/javascript">
  var STATIC_URL = "{{ STATIC_URL }}";
  var WEBROOT = "{{ WEBROOT }}";
</script>
<script src='{{ STATIC_URL }}horizon/lib/angular/angular-cookies.js'></script>
<script src='{{ STATIC_URL }}horizon/lib/angular/angular-gettext.js'></script>
<script src='{{ STATIC_URL }}horizon/lib/angular/angular-sanitize.js'></script>
<script src="{{ STATIC_URL }}horizon/lib/angular/lrdragndrop.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/angular/smart-table.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/d3.js"></script>
<script src='{{ STATIC_URL }}horizon/lib/jquery/jquery.quicksearch.js'></script>
<script src="{{ STATIC_URL }}horizon/lib/jquery/jquery.tablesorter.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/spin.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/spin.jquery.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/jquery-ui/ui/jquery-ui.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/jquery/jquery.bootstrap.wizard.js"></script>
<script src="{{ STATIC_URL }}bootstrap/js/bootstrap.js"></script>
<script src='{{ STATIC_URL }}horizon/lib/bootstrap_datepicker/bootstrap-datepicker.js'></script>
<script src="{{ STATIC_URL }}horizon/lib/hogan.js"></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.string.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.communication.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.datepickers.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.forms.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.formset_table.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.instances.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.messages.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.modals.js'></script>
<script type="text/javascript">
  horizon.modals.MODAL_BACKDROP = "{% firstof HORIZON_CONFIG.modal_backdrop 'static' %}";
</script>
<script src='{{ STATIC_URL }}horizon/js/horizon.selenium.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.quota.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.tables.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.tables_inline_edit.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.tabs.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.templates.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.users.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.membership.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.metering.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.networktopology.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.d3piechart.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.heattop.js'></script>
<script src='{{ STATIC_URL }}horizon/lib/rickshaw.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.d3linechart.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.d3barchart.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.firewalls.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.volumes.js'></script>
<script src='{{ STATIC_URL }}horizon/lib/jsencrypt/jsencrypt.js'></script>

{% for file in HORIZON_CONFIG.js_files %}
    <script src='{{ STATIC_URL }}{{ file }}'></script>
{% endfor %}

{% block custom_js_files %}{% endblock %}
{% endcompress %}

{% comment %} Client-side Templates (These should *not* be inside the "compress" tag.) {% endcomment %}
{% include "horizon/client_side/templates.html" %}

{% comment %}Locale sensitive js needs to be included outisde the "compress" tag{% endcomment %}
{% if DATEPICKER_LOCALE and DATEPICKER_LOCALE != 'en' %}
<script src='{{ STATIC_URL }}horizon/lib/bootstrap_datepicker/locales/bootstrap-datepicker.{{ DATEPICKER_LOCALE }}.js'></script>
{% endif %}

{% comment %}Go!{% endcomment %}
<script>
  // Call init on DOM ready.
  $(document).ready(horizon.init);
</script>
