<!DOCTYPE html>
<% raise '"provider" layout used but no user is logged in!' unless logged_in? # this is temporary transition raise to make sure we don't use it in wrong context %>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>3scale | API Management</title>
    <%= csrf_meta_tag %>

    <%= render 'provider/analytics' %>
    <%= stylesheet_link_tag 'highlight/styles/github.css' %>
    <%= stylesheet_link_tag 'colorbox/colorbox.css' %>

    <%= render 'provider/theme' %>

    <%= stylesheet_link_tag 'master.css' if current_account.try(:master?) %>

    <%= javascript_include_tag 'vendor/jquery-1.8.2.min.js', 'vendor/rails.js' %>

    <!--[if IE]>
      <%= javascript_include_tag 'vendor/excanvas.compiled.js' %>
      <%= javascript_include_tag 'ie' %>
    <![endif]-->

    <%= javascript_include_tag 'highlight/highlight.pack.js' %>
    <%= javascript_include_tag 'help', 'flash', 'remote', 'switch', 'ajax_events', 'ajax_upload', 'autosubmit', 'extra_fields' %>

    <%= javascript_include_tag "vendor/jquery/extensions/jquery.cookie.js" %>
    <%= javascript_include_tag 'vendor/underscore.min.js' %>
    <%= javascript_include_tag 'provider' %>

    <%= javascript_include_tag 'application' %>

    <%= javascript_include_tag 'vendor/jquery.iframe-post-form.js',
                               'vendor/jquery.sparkline.min.js' %>
    <%= javascript_include_tag 'vendor/colorbox/jquery.colorbox.js' %>
    <%= javascript_include_tag 'vendor/farbtastic' %>

    <%= javascript_include_tag 'settings',
                               'threescale',
                               'vendor/highcharts',
                               'analytics/charts',
                               'analytics/dashboards/sparklines',
                               'analytics/dashboards/dashboard' %>

    <%= javascript_include_tag 'master_application' %>
    <%= javascript_include_tag 'docs' %>

    <%= render 'provider/admin/cms/includes' %>

    <% if Rails.env.production? or Rails.env.preview? %>
      <script src="https://support.3scale.net/api_docs/track.json?callback=$.noop" async="true"></script>
    <% end %>

    <%= yield :javascripts %>

    <%= render '/provider/analytics' %>
  </head>

  <body class="popup">
    <%= render 'shared/provider/flash', :flash => flash %>

    <%= yield %>

    <%= javascript_tag do %>
      $(function(){ $('body.popup').trigger('cms-template:init'); });

      var resizeCodeMirror = function(){
        var height = $(window).innerHeight();
        var tabs = $("#cms-template-editor-tabs");
        var buttons = $(".button-bar");

        $(".CodeMirror-wrap").css('height', height - tabs.outerHeight() - buttons.outerHeight() - 5);
      }

      $(window).load(resizeCodeMirror);
      $(window).on('resize', resizeCodeMirror);
    <% end %>
  </body>
</html>
