## mako
<%page expression_filter="h" args="online_help_token"/>
<%namespace name='static' file='static_content.html'/>
<%namespace file='main.html' import="login_query"/>
<%!
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _

from openedx.core.djangolib.markup import HTML, Text
# App that handles subdomain specific branding
import branding
# app that handles site status messages
from status.status import get_site_status_msg
%>

## Provide a hook for themes to inject branding on top.
<%block name="navigation_top" />

## Add UI Toolkit components if using the Pattern Library
% if uses_pattern_library:
    <%block name="js_extra">
    <%static:require_module module_name="js/header_factory" class_name="HeaderFactory">
    HeaderFactory();
    </%static:require_module>
    </%block>
% endif

<%block>
<%
try:
    course_id = course.id
except:
    # can't figure out a better way to get at a possibly-defined course var
    course_id = None
site_status_msg = get_site_status_msg(course_id)
%>
% if site_status_msg:
<div class="site-status">
  <div class="inner-wrapper">
    <span class="white-error-icon"></span>
    <p>${site_status_msg}</p>
  </div>
</div>
% endif
</%block>

% if uses_bootstrap:
<header class="navigation-container header-global ${"slim" if course and not disable_courseware_header else ""}" aria-label="Main" role="banner">
% elif uses_pattern_library:
<header class="header-global ${"slim" if course and not disable_courseware_header else ""}" aria-label="Main" role="banner">
% else:
<header class="${"header-global slim" if course and not disable_courseware_header else "header-global-new"}" aria-label="Main" role="banner">
% endif

% if uses_bootstrap:
  <nav class="navbar navbar-toggleable-md navbar-light" aria-label="${_('Main')}">
    <button class="navbar-toggler navbar-toggler-right mt-2" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <h1 class="hd logo-header">
      <div class="logo">
        <a class="navbar-brand" href="${marketing_link('ROOT')}" itemprop="url">
          <img src="${static.url("images/logo.png")}" alt="${_("{platform_name} Home Page").format(platform_name=static.get_platform_name())}" itemprop="logo" />
        </a>
      </div>
      % if course and not disable_courseware_header:
        <div class="course-header">
          <span class="provider">${course.display_org_with_default}:</span>
          <span class="course-number">${course.display_number_with_default}</span>
          <span class="course-name">${course.display_name_with_default}</span>
        </div>
      % endif
    </h1>
    % if user.is_authenticated():
      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        % if not course or disable_courseware_header:
          % if not nav_hidden or show_program_listing:
            <ul class="navbar-nav mr-auto">
                % if not nav_hidden:
                  <li class="nav-item mt-2 nav-item-open-collapsed nav-global-01">
                    <a class="nav-link" href="${marketing_link('HOW_IT_WORKS')}">${_("How it Works")}</a>
                  </li>
                  <li class="nav-item mt-2 nav-item-open-collapsed nav-global-02">
                    <a class="nav-link" href="${marketing_link('COURSES')}">${_("Find Courses")}</a>
                  </li>
                  <li class="nav-item mt-2 nav-item-open-collapsed nav-global-03">
                    <a class="nav-link" href="${marketing_link('SCHOOLS')}">${_("Schools & Partners")}</a>
                  </li>
                % endif
                % if show_program_listing:
                  <li class="nav-item mt-2 nav-item-open-collapsed">
                    <a class="${'active' if reverse('dashboard') == request.path else ''} nav-link" href="${reverse('dashboard')}">
                      ${_("Courses")}
                    </a>
                  </li>
                  <li class="nav-item mt-2 nav-item-open-collapsed">
                    <a class="${'active' if reverse('program_listing_view') in request.path else ''} nav-link" href="${reverse('program_listing_view')}">
                      ${_("Programs")}
                    </a>
                  </li>
                  % endif
                </ul>
          % endif
        % endif
        <ul class="navbar-nav navbar-right">
          % if should_display_shopping_cart_func(): # see shoppingcart.context_processor.user_has_cart_context_processor
            <a role="button" class="nav-item-open-collapsed btn-shopping-cart btn btn-secondary mr-3" href="${reverse('shoppingcart.views.show_cart')}">
              <span class="icon fa fa-shopping-cart" aria-hidden="true"></span> ${_("Shopping Cart")}
            </a>
          % endif
          <li class="nav-item mt-2 nav-item-open-collapsed">
            <a href="${get_online_help_info(online_help_token)['doc_url']}"
             target="_blank"
             class="nav-link">${_("Help")}</a>
          </li>
          <%include file="user_dropdown.html"/>
          </ul>
        </div>
    % else:
      <div class="collapse navbar-collapse" id="navbarSupportedContent" aria-label="${_('Account')}" >
        <ul class="navbar-nav mr-auto"></ul>
        <ul class="navbar-nav">
          <li class="nav-item">
            % if not settings.FEATURES['DISABLE_LOGIN_BUTTON'] and not combined_login_and_register:
              % if course and settings.FEATURES.get('RESTRICT_ENROLL_BY_REG_METHOD') and course.enrollment_domain:
                <a class="btn btn-primary mt-2" href="${reverse('course-specific-login', args=[course.id.to_deprecated_string()])}${login_query()}">${_("Sign in")}</a>
              % else:
                <a class="btn btn-primary mt-2" href="/login${login_query()}">${_("Sign in")}</a>
              % endif
            % endif
          </li>
          % if not settings.FEATURES['DISABLE_LOGIN_BUTTON'] and not combined_login_and_register:
            % if course and settings.FEATURES.get('RESTRICT_ENROLL_BY_REG_METHOD') and course.enrollment_domain:
            <li class="nav-item">
              <a class="nav-link mt-2" href="${reverse('course-specific-register', args=[course.id.to_deprecated_string()])}">${_("Register")}</a>
            </li>
            % elif static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')):
            <li>
              <a class="nav-link mt-2" href="/register">${_("Register")}</a>
            </li>
            % endif
          % endif
        </ul>
      </div>
    % endif
  </nav>
% else:
  <div class="${"rwd" if responsive else ""} wrapper-header nav-container">
    <h1 class="hd logo-header">
      <div class="logo">
        <a href="${marketing_link('ROOT')}" itemprop="url">
          <%block name="navigation_logo">
            <img src="${static.url("images/logo.png")}" alt="${_("{platform_name} Home Page").format(platform_name=static.get_platform_name())}" itemprop="logo" />
          </%block>
        </a>
      </div>

      % if course and not disable_courseware_header:
      <div class="course-header">
        <span class="provider">${course.display_org_with_default}:</span>
        <span class="course-number">${course.display_number_with_default}</span>
        <span class="course-name">${course.display_name_with_default}</span>
      </div>
      % endif
    </h1>

    % if user.is_authenticated():
      % if not course or disable_courseware_header:
        % if not nav_hidden or show_program_listing:
          <nav aria-label="${_('Main')}" class="nav-main">
            <ul class="left list-inline nav-global authenticated">
              % if not nav_hidden:
                <%block name="navigation_global_links_authenticated">
                  <li class="item nav-global-01">
                    <a href="${marketing_link('HOW_IT_WORKS')}">${_("How it Works")}</a>
                  </li>
                  <li class="item nav-global-02">
                    <a href="${marketing_link('COURSES')}">${_("Find Courses")}</a>
                  </li>
                  <li class="item nav-global-03">
                    <a href="${marketing_link('SCHOOLS')}">${_("Schools & Partners")}</a>
                  </li>
                </%block>
              % endif
              % if show_program_listing:
                <li class="tab-nav-item">
                  <a class="${'active ' if reverse('dashboard') == request.path else ''}tab-nav-link" href="${reverse('dashboard')}">
                    ${_("Courses")}
                  </a>
                </li>
                <li class="tab-nav-item">
                  <a class="${'active ' if reverse('program_listing_view') in request.path else ''}tab-nav-link" href="${reverse('program_listing_view')}">
                    ${_("Programs")}
                  </a>
                </li>
              % endif
            </ul>
          </nav>
        % endif
      % endif

      <%include file="user_dropdown.html"/>

      <a href="${get_online_help_info(online_help_token)['doc_url']}"
         target="_blank"
         class="doc-link">${_("Help")}</a>

      % if should_display_shopping_cart_func(): # see shoppingcart.context_processor.user_has_cart_context_processor
        <ul class="user">
          <li class="primary">
            <a class="shopping-cart" href="${reverse('shoppingcart.views.show_cart')}">
              <span class="icon fa fa-shopping-cart" aria-hidden="true"></span> ${_("Shopping Cart")}
            </a>
          </li>
        </ul>
      % endif
    % else:
      <nav aria-label="${_('Account')}" class="nav-account-management">
        <div class="right nav-courseware list-inline">
          <div class="item nav-courseware-01">
            % if not settings.FEATURES['DISABLE_LOGIN_BUTTON'] and not combined_login_and_register:
              % if course and settings.FEATURES.get('RESTRICT_ENROLL_BY_REG_METHOD') and course.enrollment_domain:
                <a class="btn btn-login" href="${reverse('course-specific-login', args=[course.id.to_deprecated_string()])}${login_query()}">${_("Sign in")}</a>
              % else:
                <a class="btn btn-login" href="/login${login_query()}">${_("Sign in")}</a>
              % endif
            % endif
          </div>
          % if not settings.FEATURES['DISABLE_LOGIN_BUTTON'] and not combined_login_and_register:
            % if course and settings.FEATURES.get('RESTRICT_ENROLL_BY_REG_METHOD') and course.enrollment_domain:
              <div class="item nav-courseware-02">
                <a class="btn btn-neutral btn-register" href="${reverse('course-specific-register', args=[course.id.to_deprecated_string()])}">${_("Register")}</a>
              </div>
            % elif static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')):
              <div class="item nav-courseware-02">
                <a class="btn btn-neutral btn-register" href="/register">${_("Register")}</a>
              </div>
            % endif
          % endif
        </div>
      </nav>
    % endif
  </div>
% endif
</header>
% if course:
<!--[if lte IE 9]>
<div class="ie-banner" aria-hidden="true">${Text(_('{begin_strong}Warning:{end_strong} Your browser is not fully supported. We strongly recommend using {chrome_link} or {ff_link}.')).format(
    begin_strong=HTML('<strong>'),
    end_strong=HTML('</strong>'),
    chrome_link=HTML('<a href="https://www.google.com/chrome" target="_blank">Chrome</a>'),
    ff_link=HTML('<a href="http://www.mozilla.org/firefox" target="_blank">Firefox</a>'),
)}</div>
<![endif]-->
% endif

<%include file="help_modal.html"/>
