{% load i18n avatar_tags group_avatar_tags %}
<form id="repo-share-form" action="{{ post_url }}" method="post" name="repo-share-form" class="tab-popup hide">{% csrf_token %}
    <h3 class="hd">{% trans "Share %(lib_name)s" %}</h3>
    <div id="repo-share-tabs" class="tab-popup-tabs">
        <ul class="tab-popup-tabs-nav">
            <li id="share-enter-tab" class="tab"><a href="#share-enter" class="a">{% trans 'Enter' %}</a></li>
            <li class="tab"><a href="#share-grp-options" class="a">{% trans 'Groups' %}</a></li>
            <li class="tab"><a href="#share-contact-options" class="a">{% trans 'Contacts' %}</a></li>
        </ul>
        <div id="share-enter">
            <textarea id="email_or_group" name="email_or_group" placeholder="{% trans "Emails or Groups, Seperated by ','"%}"></textarea>
            {% if cloud_mode %}
            {% if org %}
            <p class="tip">{% trans 'Tip: must be organization members or organization groups, enter "all" to share to public library.' %}</p>
            {% endif %}
            {% else %}
            <p class="tip">{% trans 'Tip: enter "all" to share to public library.' %}</p>
            {% endif %}
        </div>
        <div id="share-grp-options" class="hide">
            <ul class="option-list">
                {% for group in groups %}
                <li>
                <label class="checkbox-label">
                    <span class="checkbox"><input type="checkbox" name="grp" value="{{ group.group_name }}" class="checkbox-orig"/></span>
                    {% grp_avatar group.id 20 %} <span class="checkbox-option">{{ group.group_name }}</span>
                </label>
                </li>
                {% endfor %}
            </ul>
        </div>
        <div id="share-contact-options" class="hide">
            <ul class="option-list">
            {% for contact in contacts %}
            <li>
            <label class="checkbox-label">
                <span class="checkbox"><input type="checkbox" name="contact" value="{{ contact.contact_email }}" class="checkbox-orig" /></span>
                {% avatar contact.contact_email 20 %} <span class="checkbox-option">{{ contact.contact_email }}</span>
            </label>
            </li>
            {% endfor %}
            </ul>
        </div>
    </div>
    <div class="bot">
        <select name="permission" class="share-permission-select w100">
            <option value="rw" selected="selected">{% trans "Read-Write"%}</option>
            <option value="r">{% trans "Read-Only"%}</option>
        </select>
        <input type="hidden" name="repo_id" value="" />
        <p class="error hide"></p>
        <input type="submit" value="{% trans "Submit"%}" id="share-submit-btn" />
    </div>
</form>
