{% extends "wiki/article.html" %}
{% load wiki_tags i18n %}

{% block pagetitle %}{% trans "Edit" %}: {{ article.current_revision.title }}{% endblock %}

{% block wiki_contents_tab %}

<div class="row-fluid">

  <div class="span8">
    <form method="POST" class="form-horizontal" id="article_edit_form">
      <input type="hidden" name="save" value="1" />
      <input type="hidden" name="preview" value="1" />
    {% with edit_form as form %}
      {% include "wiki/includes/editor.html" %}
    {% endwith %}
    </form>
  </div>

  <div class="span4" id="edit_sidebar">
    {% include "wiki/includes/editor_sidebar.html" %}
  </div>

</div>

<div style="clear: both"></div>

    <div class="form-actions">
        <a class="btn btn-large" onclick="$('#previewModal').modal('show'); document.getElementById('article_edit_form').target='previewWindow'; document.getElementById('article_edit_form').action='{% url 'wiki:preview' path=urlpath.path article_id=article.id %}'; $('#article_edit_form').submit()" href="#">
          <span class="icon-eye-open"></span>
          {% trans "Preview" %}
        </a>
        <a class="btn btn-large btn-primary" onclick="document.getElementById('article_edit_form').target=''; document.getElementById('article_edit_form').action='{% url 'wiki:edit' path=urlpath.path article_id=article.id %}'; $('#article_edit_form').submit();" href="#">
          <span class="icon-ok"></span>
          {% trans "Save changes" %}
        </a>
        
        {% if article|can_delete:user %}
        <a href="{% url 'wiki:delete' path=urlpath.path article_id=article.id %}" class="pull-right btn">
          <span class="icon-trash"></span>
          {% trans "Delete article" %}
        </a>
        {% endif %}
        
    </div>
    <div class="modal hide" id="previewModal" style="width: 80%; min-height: 500px; margin-left: -40%;">
      <div class="modal-body">
        <iframe name="previewWindow" style="width: 100%; min-height: 400px; border: 0;" frameborder="0"></iframe>
      </div>
      <div class="modal-footer">
        <a href="#" class="btn btn-large" data-dismiss="modal">
          <span class="icon-circle-arrow-left"></span>
          {% trans "Back to editor" %}
        </a>
        <a class="btn btn-large btn-primary" onclick="document.getElementById('article_edit_form').target=''; document.getElementById('article_edit_form').action='{% url 'wiki:edit' path=urlpath.path article_id=article.id %}'; document.getElementById('article_edit_form').submit();" href="#">
          <span class="icon-ok"></span>
          {% trans "Save changes" %}
        </a>
      </div>
    </div>

{% endblock %}

