{% extends "cosinnus_etherpad/base.html" %}
{% load i18n static cosinnus_tags widget_tweaks %}

{% block page_title %}
{% trans "Pads" %} {{ block.super }}
{% endblock page_title %}

{% block breadcrumb %}
        {{ block.super }}
        {% if object.path != '/' %}
            <li><a href="{% group_url 'cosinnus:etherpad:list' group=group slug=object.container.slug %}">{{ object.container.title }}</a></li>
        {% endif %}
        <li class="active"><a href="{{ object.get_absolute_url }}">{{ object.title }}</a></li>
{% endblock %}

{% block leftnav %}
    {% include "cosinnus/leftnav_hierarchic_itemview.html" %}
{% endblock leftnav %}


{% block content %}
    <!-- a box with semi transparent background -->
    <div class="content-box">
        <div class="btn btn-extra-emphasized w100">
            <ul class="media-list">
                <li class="media">
                    <a class="pull-left" href="#">
                        <i class="fa {% if object.type == 1 %}fa-table{% else %}fa-file-text{% endif %}"></i>
                    </a>
                    <a class="pull-right" href="{{ object.get_absolute_url }}">
                        <i class="fa fa-chain"></i>
                    </a>
                    <div class="media-body">
                    	{% with creator=object.creator %}
	                        <span class="annotation">{% trans "by" %} <a href="{{ creator|profile_url }}" >{{ creator|full_name }}</a></span>
	                    {% endwith %}
                        <a href="{% group_url "cosinnus:etherpad:pad-write" group=group slug=etherpad.slug %}">
                        	{{ object.title }}
                        </a>
                    </div>
                </li>
            </ul>
        </div>
        
        <div>
            {% include 'cosinnus/media_tags_readonly.html' with object=object list_view="noindent" %}
        </div>
        
        {% if object.attached_images %}
            {% include 'cosinnus/common/attached_images_gallery.html' with object=object max_images=3 %}
        {% endif %}
        
        
        <div class="large-space">
		    
		    {% if user|has_read_access:object or object.media_tag.visibility == 2 %}  
		        <button type="button" class="btn btn-emphasized" href="{% group_url "cosinnus:etherpad:pad-write" group=group slug=etherpad.slug %}">
		            <ul class="media-list">
		                <li class="media">
		                    <a class="pull-left" href="#">
		                        <i class="fa fa-pencil"></i>
		                    </a>
		                    <div class="media-body">
		                        {% trans "Edit" %}
		                    </div>
		                </li>
		            </ul>
		        </button> 
		    {% endif %}
		    
		    {% if user|has_write_access:object %}
		    	<button type="button" class="btn btn-emphasized" href="{% group_url "cosinnus:etherpad:pad-edit" group=group slug=etherpad.slug %}">
		            <ul class="media-list">
		                <li class="media">
		                    <a class="pull-left" href="#">
		                        <i class="fa fa-cog"></i>
		                    </a>
		                    <div class="media-body">
		                        {% trans "Settings" %}
		                    </div>
		                </li>
		            </ul>
		        </button> 
		    {% endif %}
		    
		    {% if user|has_write_access:object %}   
			    <button type="button" class="btn btn-emphasized" data-toggle="modal" data-target="#deleteModal">
		            <ul class="media-list">
		                <li class="media">
		                    <a class="pull-left" href="#">
		                        <i class="fa fa-eraser"></i>
		                    </a>
		                    <div class="media-body">
		                        {% trans "Delete" %}
		                    </div>
		                </li>
		            </ul>
		        </button>
			    {% captureas label %}{% blocktrans with pad=object.title %}Do you really want to delete etherpad „{{ pad }}“?{% endblocktrans %}{% endcaptureas %}
			    {% captureas title %}{% trans "Delete Etherpad" %}{% endcaptureas %}
			    {% group_url "cosinnus:etherpad:pad-delete" group=group slug=etherpad.slug as delete_url %}
			    {% include "cosinnus/modal_box.html" with id="deleteModal" label=label title=title form_action=delete_url %}
		    {% endif %}
		    
		    {% include 'cosinnus/feedback/report_button_btn.html' with object=etherpad %}
		    
		    <div class="clearfix"></div>
        </div>
        
        
        <div style="clear: both; margin-top: 10px;">
            <div class="well well-document" {% if object.type == 1 %}style="overflow: scroll; max-height: 600px;"{% endif %}>
                {% with content=etherpad.get_content %}
                	{% if content == None %}
	                	<i>({% trans "The document can not be accessed because the etherpad server could not be reached. Please contact an administrator!" %})</i>
                	{% elif not content %}
                		<i>({% trans "This document is empty" %})</i>
	                {% else %}
	                	{{ content|safe|url_target_blank }}
	                {% endif %}
                {% endwith %}
            </div>
        </div>
        
    </div><!-- content-box -->
    
    
    
{% endblock content %}
