{% extends "regulations/chrome.html" %}
{% load macros %}

{% comment %}
The chrome of diff mode is a bit different than the rest of the application;
the "effective date" is now a comparison, the sidebar is empty, and both the
table of contents and the version tab are quite different
{% endcomment %}

{% block title %}
Comparison of {{meta.cfr_title_number}} CFR {{formatted_id}} | eRegulations
{% endblock %}

{% block header-secondary %}
<span class="effective-date diff-dates"><strong>Comparing:</strong>
    {% with older_version=version %}
        {% for version in history %} {% if version.version == older_version %}{{ version.by_date|date:"n/j/Y" }}{% endif %} {% endfor %}
        to
        {% for version in history %} {% if version.version == newer_version %}{{ version.by_date|date:"n/j/Y" }}{% endif %} {% endfor %}
    {% endwith %}
</span>
{% endblock %}

{% block sidebar-history-link %}
<li class="active-tab"><a href="#timeline" id="timeline-link" class="toc-nav-link" title="Regulation Timeline"><span class="icon-text">Regulation Timeline</span><span class="cf-icon cf-icon-history"></span></a></li>
{% endblock %}

{% block drawer-toc %}
<div class="toc-drawer toc-container current hidden diff-toc" id="table-of-contents" data-from-version="{{from_version}}">
    <div class="drawer-header">
        <h2 class="toc-type">Table of Contents</h2>
    </div><!-- /.drawer-header -->
    <nav id="toc" class="toc-nav__base toc-nav__diffs" role="navigation">
        <ol class="drawer-content">
            {% for item in TOC %}
                {% if item.is_section %}
                <li class="{{item.op}}"><a href="{{item.url}}" data-section-id="{{item.section_id}}" class="diff"><span class="toc-section-marker">§&nbsp;{{item.label}}</span> {{item.sub_label|safe}}</a></li>
                {% elif item.is_appendix or item.is_supplement%}
                <li class="{{item.op}}"><a href="{{item.url}}" data-section-id="{{item.section_id}}" class="diff"><span class="toc-section-marker">{{item.label|safe}}</span> {{item.sub_label|safe}}</a></li>
                {% else %}
                <li class="{{item.op}}"><a href="{{item.url}}" data-section-id="{{item.section_id}}" class="diff">{{item.label|safe}}</a></li>
                {% endif %}
            {% endfor %}
        </ol>
    </nav>
</div>
{% endblock %}

{% block drawer-history %}
    <div id="timeline" class="history-drawer toc-container hidden diff-history">
        <div class="drawer-header">
            <h2 class="toc-type">Regulation versions</h2>
        </div><!-- /.drawer-header -->
        <div class="drawer-content">
            <p class="effective-label">Find the regulation effective on this date:</p>
            <div class="form-wrap group">
            <form action="{% url 'redirect_by_date_get' label_id %}"
                  method="GET" class="date-input">
              <input type="text" name="month" class="month-input" maxlength="2" value="{% now "m" %}" title="Effective month" />
              / <input type="text" name="day" class="day-input" maxlength="2" value="{% now "d" %}" title="Effective day"/>
              / <input type="text" name="year" class="year-input" maxlength="4" value="{% now "Y" %}" title="Effective year"/>
              <button type="submit" class="find-button">Find</button>
            </form>
            </div><!--./date-form-->
            <ul class="version-list">
            {% for version in history %}
                <li class="status-list{% if version.version == left_version or version.version == right_version %} current{% endif %}">
                    <!--{% if version.version == left_version %}
                      (Left)
                    {% elif version.version == right_version %}
                      (Right)
                    {% endif %}-->
                    <a href="{% url 'chrome_section_view' label_id version.version %}" class="version-link" data-version="{{ version.version }}">
                        {% if version.timeline.is_present %}
                            <h3>Current Law</h3>
                        {% endif %}
                        <span class="version-date">{{ version.by_date|date:"n/j/Y" }}</span>
                    </a>
                    <div class="timeline-content-wrap">
                    <ul class="rule-list">
                      {% for notice in version.notices %}
                        {% with pub_date=notice.publication_date|date:"n/j/Y" %}
                          {% if notice.fr_url %}
                            <li>{% external_link classes="fr-notice" url=notice.fr_url text="Final Rule –  "|add:pub_date %}</li>
                          {% else %}
                            <li>Final Rule &#8211; {{pub_date}}</li>
                          {% endif %}
                        {% endwith %}
                      {% endfor %}
                    </ul>
                        {% if version.version == left_version %}
                        <a data-first-subterp="{{first_subterp.section_id}}" class="stop-button" data-version="{{ from_version }}"
                            {% if "Interp" in label_id %}
                            href="{{first_subterp.url}}"
                            {% else %}
                            href="{% url 'chrome_section_view' label_id from_version %}"
                            {% endif %}
                        >Stop Comparing</a>
                        {% endif %}
                    </div> <!--./timeline-content-wrap-->
                </li>
            {% endfor %}
            </ul>
        </div>
    </div> <!--/#history-->
{% endblock %}
