<%#
# @file
# Main application file. Holds scaffolding present on every page.
# Then a certain non-partial view (no _ preceding filename) will be
# displayed within, based on URL
#%>

<%= render :partial => 'layouts/head' %>

<body class="<%= current_user ? 'authenticated' : 'unauthenticated' %>">

    <% if devise_error_messages? %>
      <p id="toast"><%= devise_error_messages! %></p>
    <% elsif notice %>
      <p id="toast"><%= notice %></p>
    <% end %>

    <%= content_tag :div, class: "main" do %>
    
        <% if params[:controller] == 'doorkeeper/applications' || params[:controller] == 'doorkeeper/authorized_applications'
             classes = 'appsPage'
           else
             classes = ''
           end
        %>

        <div class="wrapper <%= classes %>" id="wrapper">

            <%= render :partial => 'layouts/upperelements', :locals => {:appsPage => true } %>

            <%= yield %>

            <div class="showcard mapElement mapElementHidden" id="showcard"></div> <!-- the topic card -->
            <% if current_user %>
                <% # for creating and pulling in topics and synapses %>
                <%= render :partial => 'maps/newtopic' %>
                <%= render :partial => 'maps/newsynapse' %>
                <% # for populating the change metacode list on the topic card %>
                <%= render :partial => 'shared/metacodeoptions' %>
            <% end %>
            <%= render :partial => 'layouts/lowermapelements' %>

            <div id="exploreMapsHeader">
                <div class="exploreMapsBar exploreElement">
                    <div class="exploreMapsMenu">
                        <div class="exploreMapsCenter">
                            <a href="<%= oauth_applications_path %>" class="activeMaps exploreMapsButton <%= params[:controller] == 'doorkeeper/applications' ? 'active' : nil %>">
                                <div class="exploreMapsIcon"></div>Registered Apps
                            </a>
                            <a href="<%= oauth_authorized_applications_path %>" class="activeMaps exploreMapsButton <%= params[:controller] == 'doorkeeper/authorized_applications' ? 'active' : nil %>">
                                <div class="exploreMapsIcon"></div>Authorized Apps
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            <p id="toast" class="toast">
              <% if devise_error_messages? %>
                <%= devise_error_messages! %>
              <% elsif notice %>
                <%= notice %>
              <% end %>
            </p>
            <div id="loading"></div>
        </div>

    <% end %>

<%= render :partial => 'layouts/foot' %>
