view kallithea/templates/files/files_browser.html @ 6357:9447a8b26da0

style: consistently use label markup wrapping around input elements The 'for="..."' markup is error prone.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 04 Dec 2016 22:53:37 +0100
parents c40e567e4b82
children 1ce4e23c2207
line wrap: on
line source

<%def name="file_class(node)">
    %if node.is_file():
        <%return "browser-file" %>
    %elif node.is_submodule():
        <%return "submodule-dir"%>
    %else:
        <%return "browser-dir"%>
    %endif
</%def>
<%def name="file_url(node, c)">
    %if node.is_submodule():
        <%return node.url or '#'%>
    %else:
        <%return h.url('files_home', repo_name=c.repo_name, revision=c.changeset.raw_id, f_path=h.safe_unicode(node.path))%>
    %endif
</%def>
<%def name="file_name(node)">
    <%
        c = "icon-folder-open"
        if node.is_file():
            c = "icon-doc"
        elif node.is_submodule():
            c = "icon-file-submodule"
    %>
    <%return h.literal('<i class="%s"></i><span>%s</span>' % (c, h.escape(node.name)))%>
</%def>
<div id="body" class="browserblock">
    <div class="browser-header">
        <div class="browser-nav">
            ${h.form(h.url.current())}
            <div class="info_box">
              <div class="info_box_elem rev">${_('Revision')}</div>
              <div class="info_box_elem"><a class="btn btn-default btn-xs ypjax-link" href="${c.url_prev}" title="${_('Previous revision')}"><i class="icon-left-open"></i></a></div>
              <div class="info_box_elem">${h.text('at_rev',value=c.changeset.revision,size=5)}</div>
              <div class="info_box_elem"><a class="btn btn-default btn-xs ypjax-link" href="${c.url_next}" title="${_('Next revision')}"><i class="icon-right-open"></i></a></div>
            </div>
            ${h.end_form()}
        </div>
        <div class="browser-branch">
            <label>
                ${h.checkbox('stay_at_branch',c.changeset.branch,c.changeset.branch==c.branch)}
                ${_('Follow current branch')}
            </label>
        </div>
        <div id="search_activate_id" class="search_activate">
            <a class="btn btn-default btn-xs" id="filter_activate" href="#">${_('Search File List')}</a>
        </div>
        <div class="browser-search">
            <div>
                <div id="node_filter_box_loading" style="display:none">${_('Loading file list...')}</div>
                <div id="node_filter_box" style="display:none">
                ${h.files_breadcrumbs(c.repo_name,c.changeset.raw_id,c.file.path)}/<input class="init" type="text" value="type to search..." name="filter" size="25" id="node_filter">
                </div>
            </div>
        </div>
    </div>

    <div class="browser-body">
        <table class="code-browser">
            <thead>
                <tr>
                    <th>${_('Name')}</th>
                    <th>${_('Size')}</th>
                    <th>${_('Last Revision')}</th>
                    <th>${_('Last Modified')}</th>
                    <th>${_('Last Committer')}</th>
                </tr>
            </thead>

            <tbody id="tbody">
                %if c.file.parent:
                <tr class="parity0">
                    <td>
                        ${h.link_to(h.literal('<i class="icon-folder-open"></i><span>..</span>'),h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.file.parent.path),class_="browser-dir ypjax-link")}
                    </td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                %endif

            %for cnt,node in enumerate(c.file):
                <tr class="parity${cnt%2}">
                     <td>
                         ${h.link_to(file_name(node),file_url(node,c),class_=file_class(node)+" ypjax-link")}
                     </td>
                     <td>
                     %if node.is_file():
                         ${h.format_byte_size(node.size,binary=True)}
                     %endif
                     </td>
                     <td>
                         %if node.is_file():
                             <a data-toggle="tooltip" title="${node.last_changeset.message}" href="${h.url('changeset_home',repo_name=c.repo_name,revision=node.last_changeset.raw_id)}" class="revision-link">${h.show_id(node.last_changeset)}</a>
                         %endif
                     </td>
                     <td>
                         %if node.is_file():
                             <span data-toggle="tooltip" title="${h.fmt_date(node.last_changeset.date)}">
                            ${h.age(node.last_changeset.date)}</span>
                         %endif
                     </td>
                     <td>
                         %if node.is_file():
                             <span title="${node.last_changeset.author}">
                            ${h.person(node.last_changeset.author)}
                            </span>
                         %endif
                     </td>
                </tr>
            %endfor
            </tbody>
            <tbody id="tbody_filtered" style="display:none">
            </tbody>
        </table>
    </div>
</div>

<script>
    $(document).ready(function(){
        // init node filter if we pass GET param ?search=1
        var search_GET = "${request.GET.get('search','')}";
        if(search_GET == "1"){
            $("#filter_activate").click();
        }
    });
</script>