<%namespace name="comment_tiles" file="/comment/tiles.html"/>

<%def name="history_row(tile, text)">
<li>
    <div class="tile text history">
        <h3 class="title">
            ${diff.page_titles_compare(text, text.valid_parent())|n}
            %if text.page.has_variants:
                (${text.variant_html|n})
            %endif
        </h3>
        <div>
            ${_("by %s, ") % h.user.link(text.user, scope=text.page)|n}
            ${_("created %s") % h.datetime_tag(text.create_time)|n}
            %if h.has_permission('page.delete_history') and (text.valid_child() is not None or text.valid_parent() is not None):
                <span> <a href="${h.page.page_text_url(text.page, text, 'ask_purge_history')}">(${_(u'delete version')})</a></span>
            %endif
        </div>
    </div>

    <div class="headrev">
            %if text.has_text:
                <div class="text" style="width: auto;">
                    ${diff.page_texts_history_compare(text, text.valid_parent())|n}
                </div>
            %else:
                <div class="infobox">
                    ${_("This revision has no text.")}
                </div>
            %endif
    </div>
</li>
</%def>


<%def name="minimal(tile, text, missing_translation)">
    %if text.has_text:
    ${text.render()|n}
    %elif missing_translation:
    <p>${missing_translation}</p>
    %else:
    ${_("This norm has not yet been decided and is thus no "
        "official position of this group.")}
    %endif
</%def>


<%def name="full(tile, text, subpages_pager=None, hide_discussion=True)">
    %if text.has_text:
        <div class="tile">
        ${text.render()|n}
        </div>
    %else:
        <div class="infobox">
            ${_("This norm has not yet been decided and is thus no official position of this group.")}
        </div>
    %endif

    %if subpages_pager is not None and len(subpages_pager._items):
        <div id="pages_table" class="table">
            ${subpages_pager.here()}
        </div>
    %endif

    <br/>

    %if hide_discussion:
        <div class="discuss">
            <a class="discuss_button">
                ${_("discuss (%s comments) &raquo;") % len(text.page.variant_comments(text.variant))|n}
            </a>
            <div class="discuss_details">
    %endif

    ${tiles.comment.list(text.page, variant=text.variant)}

    %if hide_discussion:
            </div>
        </div>
    %endif

</%def>



<%def name="descbox(tile, this, other, options, field)">
    %if options:
        <form action="/page/diff" method="GET" id="diff_left_form">
        <input type="hidden" name="right" value="${other.id}" />
    %endif

    <div class="variant_header">
        <ul class="variant_innerheader">
            %if this.title != other.title:
                <li>${_("Title:")|n} <b><a href="${h.entity_url(this)|n}">${this.title}</a></b></li>
            %endif
            <li>
            %if options:
                ${_("Variant:")|n}
                <select name="left" id="diff_left_select">
                    %for text in options:
                        %if text == this:
                            <option value="${text.id}" selected="selected">${text.variant_name}</option>
                        %elif text == other:
                            <!-- nop -->
                        %else:
                            <option value="${text.id}">${text.variant_name}</option>
                        %endif
                    %endfor
                </select>
                <a href="${h.entity_url(this)|n}">${_("see")}</a>
            %else:
                ${_("Variant:")}
                %if field is not None:
                    <input name="variant" maxlength="75" value="${field}" placeholder="${_('Variant Name')}" />
                %else:
                    <b><a href="${h.entity_url(this)|n}">${this.variant_html|n}</a></b>
                %endif
            %endif

            </li>
            %if field is None:
                <li>
                    ${_("%s by %s") % (h.datetime_tag(this.create_time),
                                                        h.user.link(this.user, scope=this.page))|n}
                    · <b><a href="${h.entity_url(this, member='history')|n}">${_("History")}</a></b>
                </li>
            %endif
        </ul>
        %if options:
            <noscript>
                <input type="submit" value="${_("Compare")}" />
            </noscript>
        %endif
    </div>

    %if options:
        </form>
    %endif
</%def>

