<%#
  This file is a part of RedmineX UX Upgrade plugin
  for Redmine

  Copyright 2020-2022 RedmineX. All Rights Reserved.
  https://www.redmine-x.com

  Licensed under GPL v2 (http://www.gnu.org/licenses/gpl-2.0.html)
  Created by Ondřej Svejkovský
%>

<!DOCTYPE html>
<html lang="<%= current_language %>">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title><%= html_title %></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.13.2', 'tribute-5.1.3', 'application', 'responsive', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>

<%#= Translation of strings and relative path for theme.js and standard_theme.js %>
<% theme_js_scope = { scope: :theme_js } %>
<% standard_theme_js_scope = { scope: :standard_theme_js } %>

<script>
    window.I18nUxUpgradeJs = {
        filtersAndOptions: '<%= l(:filters_and_options, theme_js_scope) %>',
        areYouSure: '<%= l(:text_are_you_sure) %>',
        openAttachmentsBtn: '<%= l(:open_attachments_button, standard_theme_js_scope) %>',
        closeAttachmentsBtn: '<%= l(:close_attachments_button, standard_theme_js_scope) %>',
    };
    window.redmineRelativePath = '<%= Redmine::Utils::relative_url_root %>';
    window.userId = '<%= User.current.id %>';
</script>

<%= javascript_heads %>
<%= heads_for_theme %>
<%= heads_for_auto_complete(@project) %>
<%= call_hook :view_layouts_base_html_head %>
<%#= page specific tags %>
<%= yield :header_tags -%>

<%#= include extension-projectino.css which hides some redmine items in views when
     projectino is delivered as SAAS => if Projectino Extensions plugin is installed %>
<% if Redmine::Plugin.installed?(:projectino_extensions) %>
    <%= stylesheet_link_tag 'extension-projectino.css', plugin: '000_redmine_x_ux_upgrade' %>
<% end %>

<%#= include extension-redminex.css which hides some redmine items in views when
     redmine x is delivered as SAAS => if RedmineX Extensions plugin is installed %>
<% if Redmine::Plugin.installed?(:redmine_x_extensions) %>
    <%= stylesheet_link_tag 'extension-redminex.css', plugin: '000_redmine_x_ux_upgrade' %>
<% end %>

<%#= if user sets other theme than redminex_theme, load following css to fix styling bugs caused by
     removal of styles included in the redminex theme %>
<% unless Setting.ui_theme == 'redminex_theme' %>
    <%= stylesheet_link_tag 'redminex_ux_upgrade_standard_themes.css', plugin: '000_redmine_x_ux_upgrade' %>
<% end %>

<%#= UX Upgrade plugin js and css %>
<%= javascript_include_tag('redmine_x_ux_upgrade.min.js', plugin: '000_redmine_x_ux_upgrade', type: 'module') %>
<%= stylesheet_link_tag 'select2.min.css', plugin: '000_redmine_x_ux_upgrade' %>
<%= javascript_include_tag 'select2.min.js', plugin: '000_redmine_x_ux_upgrade' %>
</head>

<%# Hide top menu and navbar if authenttication required on login screen %>
<% if Setting.login_required == '1' %>
    <body class="<%= body_css_classes %> authentification">
<% else %>
    <body class="<%= body_css_classes %>">
<% end %>
<%= call_hook :view_layouts_base_body_top %>
<div id="wrapper">
    <div class="flyout-menu js-flyout-menu">
        <% if User.current.logged? || !Setting.login_required? %>
            <div class="flyout-menu__search">
                <%#= Search form is replaced with jump to project, jump to project
                    object is moved to mobile menu using theme.js %>
                <%#= form_tag(search_path(id: @project), :method => :get ) do %>
                <%#= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %>
                <%#= label_tag 'flyout-search', '&#9906;'.html_safe, :class => 'search-magnifier search-magnifier--flyout' %>
                <%#= text_field_tag 'q', @question, :id => 'flyout-search', :class => 'small js-search-input', :placeholder => l(:label_search) %>
                <%# end %>
            </div>
        <% end %>

        <% if User.current.logged? %>
            <div class="flyout-menu__avatar <% if !Setting.gravatar_enabled? %>flyout-menu__avatar--no-avatar<% end %>">
                <% if Setting.gravatar_enabled? %>
                    <%= link_to(avatar(User.current, :size => "80"), user_path(User.current)) %>
                <% end %>
                <%= link_to_user(User.current, :format => :username) %>
            </div>
        <% end %>

        <%#= Project menu section removed, because project menu is not moved to
            mobile menu %>
        <%# if display_main_menu?(@project) %>
            <%#= <h3><%#= l(:label_project) %><%#=</h3> %>
            <%#= <span class="js-project-menu"></span> %>
        <%# end %>

        <h3><%= l(:label_general) %></h3>
        <span class="js-general-menu"></span>

        <span class="js-sidebar flyout-menu__sidebar"></span>

        <%#= Label of profile menu removed - profile menu is part of hamburger menu
            which is moved behind js-profile-menu on mobile %>
        <%#= <h3><%#= l(:label_profile) %><%#=</h3> %>
        <span class="js-profile-menu"></span>

    </div>

    <div id="actionbar">
        <%= render_menu(:new_entity_menu)-%>
    </div>
    <div id="top-menu">
        <%= render "layouts/top_menu_hamburger" %>
        <%= render "layouts/logo"%>
        <%= render_menu :projectino_top_menu if User.current.logged? || !Setting.login_required? -%>
    </div>

    <div id="header">

        <a href="#" class="mobile-toggle-button js-flyout-menu-toggle-button"></a>

        <% if User.current.logged? || !Setting.login_required? %>
        <div id="quick-search">
            <%= form_tag(search_path(id: @project), :method => :get ) do %>
                <%= hidden_field_tag 'scope', default_search_project_scope, :id => nil %>
                <%= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %>
                <%#= Only open issues search options should be on by default for projectino users %>
                <% if Redmine::Plugin.installed?(:projectino_extensions) %>
                <%= hidden_field_tag('open_issues', 1) %>
                <% end %>

                <label for='q'>
                    <%= link_to l(:label_search), search_path(id: @project, :scope => default_search_project_scope), :accesskey => accesskey(:search) %>:
                </label>
                <%= text_field_tag 'q', @question, :size => 20, :class => 'small', :accesskey => accesskey(:quick_search),
                                :data => {
                                    :auto_complete => true
                                },
                                :placeholder => l(:label_search)
                %>
            <% end %>
            <%= render_project_jump_box %>
        </div>
        <% end %>

        <a href="/" class="mobile-home-button">
            <img alt="Logo" src="<%= Redmine::Utils::relative_url_root %>/themes/redminex_theme/images/logo-only.svg">
        </a>

        <h1><%= page_header_title %></h1>

        <%#= #main-menu renamed to #main-menu2 to disable moving of the projectmenu to the mobile menu %>
        <% if display_main_menu?(@project) %>
        <div id="main-menu2" class="tabs">
            <%= render_main_menu(@project) %>
            <div class="tabs-buttons" style="display:none;">
                <button class="tab-left" onclick="moveTabLeft(this); return false;"></button>
                <button class="tab-right" onclick="moveTabRight(this); return false;"></button>
            </div>
        </div>
        <% end %>
    </div>

    <div id="main" class="<%= sidebar_content? ? '' : 'nosidebar' %>">
        <div id="sidebar">
            <%= yield :sidebar %>
            <%= view_layouts_base_sidebar_hook_response %>
        </div>

        <div id="content">
            <%= render_flash_messages %>
            <%= yield %>
            <%= call_hook :view_layouts_base_content %>
            <div style="clear:both;"></div>
        </div>
    </div>
    <div id="footer">
        Powered by <%= link_to Redmine::Info.app_name, Redmine::Info.url %> &copy; 2006-2022 Jean-Philippe Lang
    </div>

    <div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div>
    <div id="ajax-modal" style="display:none;"></div>
</div>
<%= call_hook :view_layouts_base_body_bottom %>
</body>
</html>
