{% extends "site/layout/base_text.html" %}
{% load com %}
{% load i18n %}
{% load local_perms %}
{% block main %}

{% get_local_text_perm request text can_edit_text as can_edit_text %}

<script type="text/javascript">
<!--
tb_conf['current_tab'] = 'history';
-->
</script>

<script type="text/javascript">
<!--
$(function() {
    $(".arrow").bind("mouseenter", function(e){
        $(this).attr('src','{{ MEDIA_URL }}img/arrow_w_red.png');
    });
    
    $(".arrow").bind("mouseout", function(e){
        $(this).attr('src','{{ MEDIA_URL }}img/arrow_w_blue.png');
    });
    
    $(".ver_span").bind("mouseenter", function(e){
        $(this).removeClass('version_item').addClass('version_item-selected');
    });
        
    $(".ver_span").bind("mouseout", function(e){
        $(this).removeClass('version_item-selected').addClass('version_item');
    });    
});
-->
</script>

<div id="text_history" class="tab-meta">    
<div class="label">{% blocktrans %}Versions:{% endblocktrans %}
{% for author,color in author_colors %}
    <span style="background: {{ color }};">{{ author }}</span>
{% endfor %} 
</div>

<span id="text_history_timeline">
{% for v1, v2, color in paired_versions %}
    <a href="{% url text-history-version text.key v1.version_number %}" title="{% blocktrans with v1.version_number as v1number %}version #{{ v1number }}{% endblocktrans %}{% if v1.name %} {% blocktrans  with v1.name as v1name %}by {{ v1name }}{% endblocktrans %}{% endif %}{% if v1.note %} / {{ v1.note }}{% endif %} ({% blocktrans with v1.created|local_date as v1created %}created {{ v1created }}{% endblocktrans %})">
    <span id={{ v1_id }}
          style="background: {{ color }};" 
          class="ver_span {% choice_string v1_id v1.id version_item-selected or v1.id v2_id version_item-selected version_item %}">{{ forloop.counter }}</span></a>

    {% if v2 %}
    <span class="{% choice_string v2_nid v2.version_number diff_item-selected diff_item %}">
        <!-- <a href="{% url text-history-compare text.key v1.version_number v2.version_number %}" title="diff between {{ forloop.counter }} and following ">&rarr;</a>-->
        <a href="{% url text-history-compare text.key v1.version_number v2.version_number %}" title="{% blocktrans with v1.version_number as v1number and v2.version_number as v2number %}differences between version #{{ v1number }} and #{{ v2number }}{% endblocktrans %}"><span style="vertical-align:middle;" >
            <img class="arrow"
                id="arrow_{{ v1.version_number }}"
                src="{{ MEDIA_URL }}img/arrow_w_blue.png"/></span></a>
    </span>    
    {% endif %}
{% endfor %}
</span>

{% if can_edit_text %}
<br />
<br />
<form action="{% url text-revert text.key v1_nid %}" method="POST" ><input name="revert" type="submit" value="{% blocktrans %}Revert to version #{{ v1_nid }}{% endblocktrans %}"/></form>
{% endif %}

{% if v2_nid %}
    <h2>{% blocktrans with v1_nid as v1_nid and v1_nid as v1_nid %}Differences between version #{{ v1_nid }} and version #{{ v2_nid }}:{% endblocktrans %}</h2>
{% else %}
	<h2>{{ version1.title }}</h2>
    <span class="metadata">{% blocktrans with version1.created|local_date:tz as date and v1_nid as version_number %}Version #{{ version_number }} created on {{ date }}{% endblocktrans %}</span>
    <br /><br />   
{% endif %}
{% autoescape off %}

{% if v2_nid %}
<br />
<table class="diff" width="100%">
    <tr>
        <td class="diff-head" width="45%">
        	{{ version1.title }}
            <br/>
            <span class="metadata">{% blocktrans with version1.created|local_date:tz as date and v1_nid as version_number %}Version #{{ version_number }} created on {{ date }}{% endblocktrans %}</span>
        </td>
        <td width="10%"></td>
        <td class="diff-head" width="45%">
        	{{ version2.title }}
            <br/>
            <span class="metadata">{% blocktrans with version2.created|local_date:tz as date and v2_nid as version_number %}Version #{{ version_number }} created on {{ date }}{% endblocktrans %}</span>            
        </td>
    </tr>
</table>
{% endif %}


{% if is_diff %}
{{ content }}
{% else %}
<center>{% blocktrans %}No differences{% endblocktrans %}</center>
{% endif %}

{% if embed_code %}
<div id="autoexpand_text_view_frame_container">
{{ embed_code }}
{% endif %}
</div>

{% endautoescape %}
</div>
{% endblock %}
