{% load i18n %}
<script type="text/template" id="create-repo-tmpl">
    <form id="repo-create-form" action="" method="post">{% csrf_token %}
        <h3>{% trans "New Library"%}</h3>
        <label>{% trans "Name"%}</label><br/>
        <input type="text" name="repo_name" value="" maxlength="{{max_file_name}}" class="input" /><br />
        <% if (showSharePerm) { %>
        <label>{% trans "Share Permission"%}</label><br />
        <select name="permission" class="perm">
          <option value="rw" selected="selected">{% trans "Read-Write"%}</option>
          <option value="r">{% trans "Read-Only"%}</option>
        </select>
        <% } %>
        <div class="repo-create-encryption">
            <label class="checkbox-label">
                <span class="checkbox"><input type="checkbox" name="encryption" id="encrypt-switch" class="checkbox-orig" /></span>
                <span class="checkbox-option">{% trans "Encrypt"%}</span>
            </label>
            <label>{% trans "Password"%}</label><span class="tip">{% blocktrans %}(at least {{repo_password_min_length}} characters){% endblocktrans %}</span><br />
            <input type="password" name="passwd" disabled="disabled" class="input input-disabled" /><br />
            <label>{% trans "Password again"%}</label><br />
            <input type="password" name="passwd_again" disabled="disabled" class="input input-disabled" />
        </div>
        <p class="error hide"></p>
        <input type="submit" value="{% trans "Submit"%}" class="submit" />
    </form>
</script>
<script type="text/template" id="repo-tmpl">
    <td>
      <% if (encrypted) { %>
      <img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted" %}" alt="" />
      <% } else { %>
      <img src="{{ MEDIA_URL }}img/sync-folder-20.png" title="{% trans "Read-Write" %}" alt="" />
      <% } %>
    </td>
    <td><a href="#my-libs/lib/<%= id %>"><%- name %></a></td>
    <td>
      <div class="op-container">
        <img src="{{ MEDIA_URL }}img/share-orange.png" alt="" class="repo-share-btn op-icon vh" title="{% trans "Share" %}" />
        <img src="{{ MEDIA_URL }}img/delete-orange.png" class="repo-delete-btn op-icon vh" title="{% trans "Delete" %}" />
      </div>
    </td>
    <td><%= size_formatted %></td>
    <td><%= mtime_relative %></td>
</script>
<script type="text/template" id="group-repo-tmpl">
    <td>
        <% if (encrypted) { %>
        <img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted" %}" alt="" />
        <% } else { %>
            <% if (permission == 'rw') { %>
        <img src="{{ MEDIA_URL }}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write" %}" alt="" />
            <% } else { %>
        <img src="{{ MEDIA_URL }}img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only" %}" alt="" />
            <% } %>
        <% } %>
    </td>
    <td><a href="#group/<%= group_id %>/lib/<%= id %>"><%- name %></a></td>
    <td class="alc">
    <% if (is_staff || share_from_me) { %>
    <img src="{{ MEDIA_URL }}img/delete-orange.png" alt="" class="cancel-share op-icon vh" title="{% trans "Unshare" %}" />
    <% } %>
    </td>
    <td><%= size_formatted %></td>
    <td><%= mtime_relative %></td>
    <td><span title="<%- owner %>"><%- owner_nickname %></span></td>
</script>
<script type="text/template" id="organization-repo-tmpl">
    <td>
        <% if (encrypted) { %>
        <img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted" %}" alt="" />
        <% } else { %>
            <% if (permission == 'rw') { %>
        <img src="{{ MEDIA_URL }}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write" %}" alt="" />
            <% } else { %>
        <img src="{{ MEDIA_URL }}img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only" %}" alt="" />
            <% } %>
        <% } %>
    </td>
    <td><a href="#org/lib/<%= id %>"><%- name %></a></td>
    <td class="alc">
    <% if (app.pageOptions.is_staff || owner == app.pageOptions.username) { %>
    <img src="{{ MEDIA_URL }}img/delete-orange.png" alt="" class="cancel-share op-icon vh" title="{% trans "Unshare" %}" />
    <% } %>
    </td>
    <td><%- size_formatted %></td>
    <td><%= mtime_relative %></td>
    <td><span title="<%- owner %>"><%- owner_nickname %></span></td>
</script>
<script type="text/template" id="top-group-nav-tmpl">
    <div id="top-nav-grp-info" class="top-info-popup hide">
        <div class="outer-caret up-outer-caret">
            <div class="inner-caret"></div>
        </div>
        <ul id="top-nav-grp-list">
            <% for (var i = 0, len = groups.length; i < len; i++) { %>
            <li class="item" data-url="#group/<%= groups[i].id %>/" title="<%= groups[i].name %>">
                <%= groups[i].avatar %>
                <span class="name ellipsis vam"><%= groups[i].name %></span>
                <a href="{{SITE_ROOT}}group/<%= groups[i].id %>/discuss/" title="{% trans "Discussion" %}" class="a fright vh">
                    <img src="{{MEDIA_URL}}img/msgs.png" alt="" />
                </a>
            </li>
            <% } %>
        </ul>
        <a href="{{SITE_ROOT}}groups/" class="item all-grp">All Groups</a>
    </div>
</script>
<script type="text/template" id="dir-op-bar-tmpl">
    <% if (user_perm == 'rw') { %>
    <div id="multi-dirents-op" class="hide">
        <button id="mv-dirents" title="{% trans 'Move' %}" class="op-btn"><span class="mv-dirents"></span></button>
        <button id="cp-dirents" title="{% trans 'Copy' %}" class="op-btn"><span class="cp-dirents"></span></button>
        <button id="del-dirents" title="{% trans 'Delete' %}" class="op-btn"><span class="del-dirents"></span></button>
    </div>
    <div id="upload-file" class="op-btn upload-file-btn">
        <span>{% trans "Upload" %}</span>
        <input type="file" name="file" multiple />
    </div>
    <% if (enable_upload_folder) { %>
    <ul id="upload-menu" class="hide">
      <li class="item">
        <span>{% trans "Upload Files" %}</span>
        <input type="file" name="file" multiple />
      </li>
      <li class="item">
        <span>{% trans "Upload Folder" %}</span>
        <input type="file" name="file" multiple directory webkitdirectory />
      </li>
    </ul>
    <% } %>
    <button id="add-new-dir" class="op-btn">{% trans "New Folder" %}</button>
    <button id="add-new-file" class="op-btn">{% trans "New File" %}</button>
    <% } %>
    <% if (!encrypted && can_generate_shared_link) { %>
    <button class="op-btn" id="share-cur-dir">{% trans "Share" %}</button>
    <% } %>
    <% if (path == '/') { %>
    <a class="repo-history-icon fright" href="<%= site_root %>repo/history/<%- repo_id %>/" target="_blank" title="{% trans 'History' %}"></a>
    <% if (user_perm == 'rw') { %>
    <a class="repo-trash-icon fright" href="<%= site_root %>repo/recycle/<%- repo_id %>/" target="_blank" title="{% trans 'Trash' %}"></a>
    <% } %>
    <% if (is_repo_owner && !is_virtual) { %>
    <a class="repo-setting-icon fright" href="<%= site_root %>repo/<%- repo_id %>/settings/" target="_blank" title="{% trans 'Settings' %}"></a>
    <% } %>
    <% } %>
</script>
<script type="text/template" id="dir-path-bar-tmpl">
    <% if (context == 'group') { %>
        <a href="#<%= category %>/" class="path-link normal">{% trans "Libraries" %}</a> /
    <% } else if (context == 'org') { %>
        <a href="#<%= category %>/" class="path-link normal">{% trans "Libraries" %}</a> /
    <% } else if (context == 'common') { %>
        <a href="#my-libs/" class="path-link normal">{% trans "Libraries" %}</a> /
    <% } else { %>
        <a href="#" class="path-link normal">{% trans "Libraries" %}</a> /
        <a href="#<%= category %>/" class="path-link normal"><% if (category == 'my-libs') { %>{% trans "Mine" %}<% } %><% if (category == 'shared-libs') { %>{% trans "Shared" %}<% } %><% if (category == 'my-sub-libs') { %>{% trans "Sub-libraries" %}<% } %></a> /
    <% } %>
    <% if (path == '/') { %>
    <%- repo_name %> /
    <% } else { %>
        <a href="#<%= category %>/lib/<%= repo_id %>/" class="path-link normal"><%- repo_name %></a> /
    <% for (var i = 0,len = path_list.length - 1; i < len; i++) { %>
        <a href="#<%= category %>/lib/<%= repo_id %>/<% print(path_list_encoded.slice(0, i+1).join('/')); %>" class="path-link normal"><%- path_list[i] %></a> /
    <% } %>
    <%- path_list[i] + ' /' %>
    <% } %>
</script>
<script type="text/template" id="dirents-hd-tmpl">
    <tr>
        <th class="select">
            <span class="checkbox"><input type="checkbox" class="checkbox-orig" /></span>
        </th>
        <th class="star"></th>
        <th class="dirent-icon"></th>
        <th class="by-name cspt"><span class="dirent-name">{% trans "Name"%} <span class="sort-icon icon-caret-up"></span></span></th>
        <th class="dirent-op"></th>
        <th class="dirent-size">{% trans "Size"%}</th>
        <th class="dirent-update by-time cspt">{% trans "Last Update" %} <span class="sort-icon icon-caret-down hide"></span></th>
    </tr>
</script>
<script type="text/template" id="dirent-tmpl">
    <% if (dirent.is_dir) { %>
    <td class="select">
        <% if (dirent.selected) { %>
        <span class="checkbox checkbox-checked"><input type="checkbox" class="checkbox-orig" checked="checked" /></span>
        <% } else { %>
        <span class="checkbox"><input type="checkbox" class="checkbox-orig" /></span>
        <% } %>
    </td>
    <td class="star"></td>
    <% if (dirent.perm == 'r') { %>
        <td class="dirent-icon"><img src="{{ MEDIA_URL }}img/folder-read-only-24.png" alt="{% trans "Directory icon" %}" /></td>
    <% } else { %>
        <td class="dirent-icon"><img src="{{ MEDIA_URL }}img/folder-24.png" alt="{% trans "Directory icon" %}" /></td>
    <% } %>
    <td>
        <% if (category) { %>
        <span class="dirent-name"><a href="#<%= category %>/lib/<%= repo_id %><%- encoded_path %>" class="dir-link normal"><%- dirent.obj_name %></a></span>
        <% } else { %>
        <span class="dirent-name"><a href="#lib/<%= repo_id %><%- encoded_path %>" class="dir-link normal"><%- dirent.obj_name %></a></span>
        <% } %>
    </td>
    <td class="dirent-op">
        <div class="repo-file-op vh">
            <div class="displayed-op">
                <a class="op download" href="{{ SITE_ROOT }}repo/download_dir/<%= repo_id %>/?p=<% print(encodeURIComponent(dirent_path)); %>" title="{% trans "Download" %}"><img src="{{ MEDIA_URL }}img/download-orange.png" alt="" /></a>
                <% if (!repo_encrypted && can_generate_shared_link) { %>
                <a class="op share" href="#" title="{% trans "Share" %}"><img src="{{ MEDIA_URL }}img/share-orange.png" alt="" /></a>
                <% } %>
                <% if (dirent.perm == 'rw') { %>
                <a class="op delete" href="#" title="{% trans "Delete" %}"><img src="{{ MEDIA_URL }}img/delete-orange.png" alt="" /></a>
                <% } %>
            </div>
            <% if (dirent.perm == 'rw') { %>
            <img src="{{ MEDIA_URL }}img/more_op.png" title="{% trans "More operations" %}" alt="{% trans "More operations" %}" class="more-op-icon cspt" />
            <ul class="hidden-op hide">
                <li><a class="op rename" href="#">{% trans "Rename" %}</a></li>
                <li><a class="op mv" href="#">{% trans "Move" %}</a></li>
                <li><a class="op cp" href="#">{% trans "Copy" %}</a></li>
                <% if (app.pageOptions.folder_perm_enabled && is_repo_owner) { %>
                <li><a class="op set-folder-permission" href="#">{% trans "Permission" %}</a></li>
                <% } %>
                <% if (is_pro) { %>
                <li><a class="op open-via-client" href="seafile://openfile?repo_id=<%- repo_id %>&path=<% print(encodeURIComponent(dirent_path + '/')); %>">{% trans "Open via Client" %}</a></li>
                <% } %>
            </ul>
            <% } %>
        </div>
    </td>
    <td class="dirent-size"></td>
    <td class="dirent-update">
        <% if (dirent.last_modified) { %>
        <% print(dirent.last_update); %>
        <% } else { %>
        <% print(""); %>
        <% } %>
    </td>
    <% } else { %>
    <td class="select">
        <% if (dirent.selected) { %>
        <span class="checkbox checkbox-checked"><input type="checkbox" class="checkbox-orig" checked="checked" /></span>
        <% } else { %>
        <span class="checkbox"><input type="checkbox" class="checkbox-orig" /></span>
        <% } %>
    </td>
    <td class="star alc">
        <% if (dirent.starred) { %>
        <span title="{% trans "starred" %}" class="icon-star file-star"></span>
        <% } else { %>
        <span title="{% trans "unstarred" %}" class="icon-star-empty file-star"></span>
        <% } %>
    </td>
    <td class="dirent-icon">
        <div class="pos-rel">
        <% if (dirent.is_img) { %>
            <% if (dirent.encoded_thumbnail_src) { %>
            <img class="thumbnail" src="{{ SITE_ROOT }}<%- dirent.encoded_thumbnail_src %>" alt="" />
            <% } else { %>
            <img src="{{ MEDIA_URL }}img/file/<%= dirent.file_icon %>" alt="" />
            <% } %>
        <% } else { %>
        <img src="{{ MEDIA_URL }}img/file/<%= dirent.file_icon %>" alt="" />
        <% } %>

        <% if (is_pro && dirent.is_locked) { %>
        <img class="file-locked-icon" width="16" src="{{ MEDIA_URL }}img/file-locked-32.png" alt="{% trans "locked" %}" />
        <% } %>
        </div>
    </td>
    <td>
        <span class="dirent-name">
            <% if (dirent.is_img) { %>
            <a class="normal img-name-link" href="{{ SITE_ROOT }}lib/<%= repo_id %>/file<%- encoded_path %>" target="_blank" data-mfp-src="{{ SITE_ROOT }}repo/<%= repo_id %>/raw<%- encoded_path %>"><%- dirent.obj_name %></a>
            <% } else { %>
            <a class="normal" href="{{ SITE_ROOT }}lib/<%= repo_id %>/file<%- encoded_path %>" target="_blank"><%- dirent.obj_name %></a>
            <% } %>
        </span>
    </td>
    <td class="dirent-op">
        <div class="repo-file-op vh">
            <div class="displayed-op">
                <a class="op download" href="{{ SITE_ROOT }}repo/<%= repo_id %>/<%= dirent.obj_id %>/download/?p=<% print(encodeURIComponent(dirent_path)); %>" title="{% trans "Download" %}"><img src="{{ MEDIA_URL }}img/download-orange.png" alt="" /></a>
                <% if (!repo_encrypted && can_generate_shared_link) { %>
                <a class="op share" href="#" title="{% trans "Share" %}"><img src="{{ MEDIA_URL }}img/share-orange.png" alt="" /></a>
                <% } %>
                <% if (dirent.perm == 'rw') { %>
                <a class="op delete" href="#" title="{% trans "Delete" %}"><img src="{{ MEDIA_URL }}img/delete-orange.png" alt="" /></a>
                <% } %>
            </div>
            <% if (dirent.perm == 'rw') { %>
            <img src="{{ MEDIA_URL }}img/more_op.png" title="{% trans "More Operations"%}" alt="{% trans "More Operations"%}" class="more-op-icon cspt" />
            <ul class="hidden-op hide">
                <li><a class="op rename" href="#">{% trans "Rename" %}</a></li>
                <li><a class="op mv" href="#">{% trans "Move" %}</a></li>
                <li><a class="op cp" href="#">{% trans "Copy" %}</a></li>
                <li><a class="op file-history" href="{{ SITE_ROOT }}repo/file_revisions/<%= repo_id %>/?p=<% print(encodeURIComponent(dirent_path)); %>" target="_blank">{% trans "History" %}</a></li>
                <% if (is_pro) { %>
                    <% if (dirent.is_locked) { %>
                        <% if (dirent.locked_by_me) { %>
                        <li><a class="op unlock-file" href="#">{% trans "Unlock" %}</a></li>
                        <% } %>
                    <% } else { %>
                    <li><a class="op lock-file" href="#">{% trans "Lock" %}</a></li>
                    <% } %>
                <li><a class="op open-via-client" href="seafile://openfile?repo_id=<%- repo_id %>&path=<% print(encodeURIComponent(dirent_path)); %>">{% trans "Open via Client" %}</a></li>
                <% } %>
            </ul>
            <% } %>
        </div>
    </td>
    <td class="dirent-size"><%= dirent.file_size %></td>
    <td class="dirent-update">
        <% if (dirent.last_modified) { %>
        <% print(dirent.last_update); %>
        <% } else { %>
        <% print("{% trans "Fetch failed" %}"); %>
        <% } %>
    </td>
    <% } %>
</script>
<script type="text/template" id="group-change-item-tmpl">
    <td>
    <span class="icon-plus"></span>
    </td>
    <td><a href="#"><%= repo.name %></a></td>
    <td>
        <%= desc_human %>
        <a class="lsch" >{% trans 'Details' %}</a>
    </td>
    <td><%= ctime_human %></td>
    <td>
        <%- creator_nickname %>
    </td>
</script>
<script type="text/template" id="share-popup-tmpl">
    <h3 class="hd"><%= title %></h3>
    <div id="share-tabs" class="left-right-tabs ovhd">
        <ul class="left-right-tabs-nav fleft"> {# TODO: better var name? #}
            <% if (!repo_encrypted) { %>
            <li class="tab"><a href="#download-link-share" class="a">{% trans "Download Link" %}</a></li>
            <% } %>
            <% if (is_dir) { %>
                <% if (user_perm == 'rw' && !repo_encrypted) { %>
            <li class="tab"><a href="#dir-upload-link-share" class="a">{% trans "Upload Link" %}</a></li>
                <% } %>
            <% if (!is_virtual && is_repo_owner) { %> {# dir private share #}
            <li class="tab"><a href="#dir-user-share" class="a">{% trans "Share to user" %}</a></li>
            <li class="tab"><a href="#dir-group-share" class="a">{% trans "Share to group" %}</a></li>
                <% } %>
            <% } %>
        </ul>

        <div class="fright">
            <img class="loading-tip" width="32" src="{{MEDIA_URL}}img/loading-new.gif" alt="{% trans 'Loading...' %}" />
            <% if (!repo_encrypted) { %>
            <div id="download-link-share" class="tabs-panel">
                <form id="generate-download-link-form" action="" class="hide">
                    <label class="checkbox-label">
                        <span class="checkbox"><input type="checkbox" name="use_passwd" class="checkbox-orig" /></span>
                        <span class="checkbox-option">{% trans "Add password protection"%}</span>
                    </label>
                    <div class="hide">
                        <label>{% trans "Password" %}</label><span class="tip">{% blocktrans %}(at least {{share_link_password_min_length}} characters){% endblocktrans %}</span>
                        <div class="passwd-wrapper">
                            <input type="password" name="password" class="passwd input" />
                            <span title="{% trans "Show" %}" class="icon-eye show-or-hide-password cspt"></span>
                            <span title="{% trans "Generate a random password" %}" class="icon-magic generate-random-password cspt"></span>
                        </div>
                        <label>{% trans "Password again" %}</label><br />
                        <input type="password" name="password_again" class="input" />
                    </div>
                    <label class="checkbox-label">
                        <span class="checkbox"><input type="checkbox" name="set_expiration" class="checkbox-orig" /></span>
                        <span class="checkbox-option">{% trans "Add auto expiration"%}</span>
                    </label>
                    <div class="hide">
                        <label>{% trans "Days" %}</label><br />
                        <input type="text" name="expire_days" class="input" />
                    </div>
                    <p class="error hide"></p>
                    <input type="submit" value="{% trans 'Generate'%}" />
                </form>
                <div id="download-link-operations" class="hide">
                    <dl>
                        <dt>{% trans "Link: " %}</dt>
                        <dd id="download-link"></dd>
                        <% if (!is_dir) { %>
                        <dt>{% trans "Direct Download Link: " %}</dt>
                        <dd id="direct-dl-link"></dd>
                        <% } %>
                    </dl>
                    <button id="send-download-link">{% trans 'Send' %}</button>
                    <button id="delete-download-link">{% trans 'Delete' %}</button>
                    <form id="send-download-link-form" action="" class="hide">
                        <label>{% trans "Send to:"%}</label><br />
                        <input type="text" class="input" name="email" placeholder="{% trans "Emails, Seperated by ','"%}" /><br />
                        <label>{% trans "Message (optional):"%}</label><br />
                        <textarea class="textarea" name="extra_msg"></textarea><br />
                        <p class="error hide"></p>
                        <input type="submit" value="{% trans "Submit" %}" class="submit" />
                        <input type="button" value="{% trans "Cancel"%}" class="cancel" id="cancel-share-download-link" />
                        <p class="sending-tip hide">{% trans "Sending..."%}</p>
                    </form>
                </div>
            </div>
            <% } %>

            <% if (is_dir) { %>
                <% if (user_perm == 'rw' && !repo_encrypted) { %>
            <div id="dir-upload-link-share" class="tabs-panel hide">
                <p class="tip">{% trans "You can share the generated link to others and then they can upload files to this directory via the link." %}</p>
                <form id="generate-upload-link-form" action="" class="hide">
                    <label class="checkbox-label">
                        <span class="checkbox"><input type="checkbox" name="use_passwd" class="checkbox-orig" /></span>
                        <span class="checkbox-option">{% trans "Add password protection"%}</span>
                    </label>
                    <div class="hide">
                        <label>{% trans "Password" %}</label><span class="tip">{% blocktrans %}(at least {{share_link_password_min_length}} characters){% endblocktrans %}</span>
                        <div class="passwd-wrapper">
                            <input type="password" name="password" class="passwd input" />
                            <span title="{% trans "Show" %}" class="icon-eye show-or-hide-password cspt"></span>
                            <span title="{% trans "Generate a random password" %}" class="icon-magic generate-random-password cspt"></span>
                        </div>
                        <label>{% trans "Password again"%}</label><br />
                        <input type="password" name="password_again" class="input" />
                    </div>
                    <p class="error hide"></p>
                    <input type="submit" value="{% trans 'Generate'%}" />
                </form>
                <div id="upload-link-operations" class="hide">
                    <p><span class="vam">{% trans 'Upload Link: ' %}</span><span id="upload-link"></span><!--input type="text" readonly="readonly" id="shared-link-text" class="vam" /--></p>
                    <button id="send-upload-link">{% trans 'Send' %}</button>
                    <button id="delete-upload-link">{% trans 'Delete' %}</button>
                    <form id="send-upload-link-form" action="" class="hide">
                        <label>{% trans "Send to:"%}</label><br />
                        <input type="text" class="input" name="email" placeholder="{% trans "Emails, Seperated by ','"%}" /><br />
                        <label>{% trans "Message (optional):"%}</label><br />
                        <textarea class="textarea" name="extra_msg"></textarea><br />
                        <p class="error hide"></p>
                        <input type="submit" value="{% trans "Submit" %}" class="submit" />
                        <input type="button" value="{% trans "Cancel"%}" class="cancel" id="cancel-share-upload-link" />
                        <p class="sending-tip hide">{% trans "Sending..."%}</p>
                    </form>
                </div>
            </div>
                <% } %>

                <% if (!is_virtual && is_repo_owner) { %>
                    <% if (!repo_encrypted) { %>
            <div id="dir-user-share" class="tabs-panel hide">
                    <% } else { %>
            <div id="dir-user-share" class="tabs-panel">
                    <% } %>
                <table>
                    <tr>
                        <th width="55%">{% trans "User" %}</th>
                        <th width="30%">{% trans "Permission" %}</th>
                        <th width="15%"></th>
                    </tr>
                    <tr id="add-dir-user-share-item">
                        <td>
                            <input type="hidden" name="emails" class="w100" />
                        </td>
                        <td>
                            <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>
                        </td>
                        <td><input type="submit" value="{% trans "Submit" %}" class="submit" /></td>
                    </tr>
                </table>
                <p class="error hide"></p>
            </div>

            <div id="dir-group-share" class="tabs-panel hide">
                <table>
                    <tr>
                        <th width="55%">{% trans "Group" %}</th>
                        <th width="30%">{% trans "Permission" %}</th>
                        <th width="15%"></th>
                    </tr>
                    <tr id="add-dir-group-share-item">
                        <td>
                            <select name="groups" class="w100" multiple="multiple"></select>
                        </td>
                        <td>
                            <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>
                        </td>
                        <td><input type="submit" value="{% trans "Submit" %}" class="submit" /></td>
                    </tr>
                </table>
                <p class="error hide"></p>
            </div>
                <% } %> {# if (!is_virtual && is_repo_owner) #}
            <% } %> {# if is_dir #}

        </div>
    </div>
</script>
<script type="text/template" id="shared-repo-tmpl">
    <td>
        <% if (encrypted) { %>
            <img src="{{MEDIA_URL}}img/sync-folder-encrypt-20.png" title="{% trans "Read-Write" %}" alt="{% trans "directory icon" %}" />
        <% } else { %>
            <% if (permission == 'rw') { %>
            <img src="{{MEDIA_URL}}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write" %}" alt="{% trans "directory icon" %}" />
            <% } else { %>
            <img src="{{MEDIA_URL}}img/folder-no-write-20.png?t=1387267140" title="{% trans "Read-Only" %}" alt="{% trans "directory icon" %}" />
            <% } %>
        <% } %>
    </td>
    <td><a href="#shared-libs/lib/<%= id %>"><%- name %></a></td>
    <td class="alc">
        <img src="{{MEDIA_URL}}img/delete-orange.png" class="unshare-btn op-icon vh" title="{% trans "Leave Share" %}" />
    </td>
    <td><%= size_formatted %></td>
    <td><%= mtime_relative %></td>
    <td><span title="<%- owner %>"><%- owner_nickname %></span></td>
</script>
<script type="text/template" id="sub-lib-tmpl">
    <td>
        <% if (encrypted) { %>
        <img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Read-Write" %}" alt="" />
        <% } else { %>
        <img src="{{ MEDIA_URL }}img/sync-folder-20.png" title="{% trans "Read-Write" %}" alt="" />
        <% } %>
    </td>
    <td><a href="#my-sub-libs/lib/<%= id %>"><%- name %></a></td>
    <td>
        <div class="op-container">
            <img src="{{MEDIA_URL}}img/delete-orange.png" class="repo-delete-btn op-icon vh" title="{% trans "Delete" %}" />
        </div>
    </td>
    <td><a href="#my-libs/lib/<%= origin_repo_id %><%- origin_path %>"><%- abbrev_origin_path %></a></td>
    <td><%= mtime_relative %></td>
</script>
<script type="text/template" id="myhome-side-nav-tmpl">
    <div class="hd w100 ovhd">
        <h3 class="fleft">{% trans "Personal" %}</h3>
        <% if (can_add_repo) { %>
        <img id="myhome-enable-mods" class="fright" title="{% trans "Enable Modules" %}" src="{{MEDIA_URL}}img/setting.png" alt="" />
        <% } %>
    </div>
    <ul class="side-tabnav-tabs">
        <li class="tab<% if (cur_tab == 'libs') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#" class="lib">{% trans "Libraries" %}</a></li>
        <li class="tab<% if (cur_tab == 'starred') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#starred/" class="star">{% trans "Starred" %}</a></li>

        <% if (events_enabled) { %>
        <li class="tab<% if (cur_tab == 'activities') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#activities/" class="activity">{% trans "Activities" %}</a></li>
        <% } %>

        <% for (var i = 0, len = mods_enabled.length; i < len; i++) { %>
            <% if (mods_enabled[i] == 'personal wiki') { %>
        <li class="tab"><a href="{{ SITE_ROOT }}home/wiki/" class="wiki">{% trans "Personal Wiki" %}</a></li>
            <% } %>
        <% } %>

        <li class="tab"><a href="{{ SITE_ROOT }}devices/" class="clients">{% trans "Devices" %}</a></li>
    </ul>

    <h3 class="hd">{% trans "Share Admin" %}</h3>
    <ul class="side-tabnav-tabs">
        <% if (can_add_repo) { %>
        <li class="tab"><a href="{{ SITE_ROOT }}share/" class="lib">{% trans "Libraries" %}</a></li>
        <li class="tab"><a href="{{ SITE_ROOT }}share/folders/" class="folders">{% trans "Folders" %}</a></li>
        <% } %>
        <li class="tab"><a href="{{ SITE_ROOT }}share/links/" class="links">{% trans "Links" %}</a></li>
    </ul>
</script>
<script type="text/template" id="myhome-mods-enable-form-tmpl">
<form id="myhome-mods-enable-form" method="post" action="" class="hide">{% csrf_token%}
    <h3>{% trans "Enable Modules"%}</h3>
    <ul>
        <% for (var i = 0, len = mods_available.length; i < len; i++) { %>
            <% if (mods_available[i] == 'personal wiki') { %>
            <li>
            <label class="checkbox-label">
                <% if (mods_enabled.indexOf(mods_available[i]) != -1) { %>
                <span class="checkbox checkbox-checked"><input type="checkbox" name="personal_wiki" class="checkbox-orig" checked="checked" /></span>
                <% } else { %>
                <span class="checkbox"><input type="checkbox" name="personal_wiki" class="checkbox-orig" /></span>
                <% } %>
                <span class="checkbox-option">{% trans "Personal Wiki" %}</span>
            </label>
            </li>
            <% } %>
        <% } %>
    </ul>
    <input type="submit" value="{% trans "Submit"%}" class="submit" />
</form>
</script>
<script type="text/template" id="group-side-nav-tmpl">
    <div class="hd w100 ovhd">
        <h3 class="fleft">
            <%= avatar %> <span title="<%- name %>" class="grp-name ellipsis vam"><%- name %></span>
        </h3>
        <% if (is_staff) { %>
            <img id="enable-mods" class="fright" title="{% trans "Enable Modules" %}" src="{{MEDIA_URL}}img/setting.png" alt="" style="margin:8px 0 0 5px;" />
        <% } %>
        <% if (is_pub) { %>
            <img src="{{MEDIA_URL}}img/grp_public.png" alt="" title="{% trans "This group is public." %}" class="fright" style="margin:8px 0 0 5px;" />
        <% } %>
    </div>
    <ul class="side-tabnav-tabs">
        <li class="tab tab-cur"><a href="#group/<%= id %>/" class="lib">{% trans "Libraries" %}</a></li>

        <% if (!is_pub) { %>
        <li class="tab"><a href="{{ SITE_ROOT }}group/<%= id %>/discuss/" class="msgs">{% trans "Discussion" %}</a></li>
        <% } %>

        <% for (var i = 0, len = mods_enabled.length; i < len; i++) { %>
            <% if (mods_enabled[i] == 'group wiki') { %>
        <li class="tab"><a href="{{ SITE_ROOT }}group/<%= id %>/wiki/" class="wiki">{% trans "Wiki" %}</a></li>
            <% } %>
        <% } %>

        <li class="tab"><a href="{{ SITE_ROOT }}group/<%= id %>/members/" class="members">{% trans "Members" %}</a></li>

        <% if (is_staff) { %>
        <li class="tab"><a href="{{ SITE_ROOT }}group/<%= id %>/manage/" class="admin">{% trans "Admin" %}</a></li>
        <% } %>
    </ul>
</script>
<script type="text/template" id="group-mods-enable-form-tmpl">
<form id="mods-enable-form" method="post" action="" class="hide">{% csrf_token%}
    <h3>{% trans "Enable Modules"%}</h3>
    <ul>
        <% for (var i = 0, len = mods_available.length; i < len; i++) { %>
            <% if (mods_available[i] == 'group wiki') { %>
            <li>
            <label class="checkbox-label">
                <% if (mods_enabled.indexOf(mods_available[i]) != -1) { %>
                <span class="checkbox checkbox-checked"><input type="checkbox" name="group_wiki" class="checkbox-orig" checked="checked" /></span>
                <% } else { %>
                <span class="checkbox"><input type="checkbox" name="group_wiki" class="checkbox-orig" /></span>
                <% } %>
                <span class="checkbox-option">{% trans "Wiki" %}</span>
            </label>
            </li>
            <% } %>
        <% } %>
    </ul>
    <input type="submit" value="{% trans "Submit"%}" class="submit" />
</form>
</script>
<script type="text/template" id="folder-perm-item-tmpl">
    <% if (for_user) { %>
    <td>
        <a href="{{ SITE_ROOT }}profile/<% print(encodeURIComponent(user)); %>/" target="_blank"><%- user_name %></a>
    </td>
    <% } else { %>
    <td>
        <a href="#group/<%= group_id %>/" target="_blank"><%- group_name %></a>
    </td>
    <% } %>
    <td>
        <div class="perm">
            <span>
            <% if (perm == 'rw') { %>
                {% trans "Read-Write" %}
            <% } else { %>
                {% trans "Read-Only" %}
            <% } %>
            </span>
            <img src="{{ MEDIA_URL }}img/edit_12.png" alt="{% trans "Edit" %}" title="{% trans "Edit" %}" class="perm-edit-icon op-icon vh" />
        </div>
        <select class="perm-toggle-select hide w100">
            <% if (perm == 'rw') { %>
                <option value="rw" selected="selected" >{% trans "Read-Write" %}</option>
                <option value="r" >{% trans "Read-Only" %}</option>
            <% } else { %>
                <option value="rw" >{% trans "Read-Write" %}</option>
                <option value="r" selected="selected" >{% trans "Read-Only" %}</option>
            <% } %>
        </select>
    </td>
    <td>
        <img src="{{ MEDIA_URL }}img/rm.png" class="delete-icon op-icon vh" alt="" title="{% trans "Delete" %}" />
    </td>
</script>
<script type="text/template" id="folder-perm-popup-tmpl">
    <h3 class="hd"><%= title %></h3>
    <div id="folder-perm-tabs" class="left-right-tabs ovhd">
        <ul class="left-right-tabs-nav fleft">
            <li class="tab"><a href="#user-folder-perm" class="a">{% trans "User Permission" %}</a></li>
            <li class="tab"><a href="#group-folder-perm" class="a">{% trans "Group Permission" %}</a></li>
        </ul>
        <div class="fright">
            <div id="user-folder-perm" class="tabs-panel">
                <table>
                    <tr>
                        <th width="55%">{% trans "User" %}</th>
                        <th width="30%">{% trans "Permission" %}</th>
                        <th width="15%"></th>
                    </tr>
                    <tr id="add-user-folder-perm">
                        <td>
                            <input type="hidden" name="email" class="w100" />
                        </td>
                        <td>
                            <select name="permission" class="perm-select w100">
                                <option value="rw" selected="selected">{% trans "Read-Write" %}</option>
                                <option value="r">{% trans "Read-Only" %}</option>
                            </select>
                        </td>
                        <td><input type="submit" value="{% trans "Submit" %}" class="submit" /></td>
                    </tr>
                </table>
                <p class="error hide"></p>
            </div>
            <div id="group-folder-perm" class="tabs-panel">
                <table>
                    <tr>
                        <th width="55%">{% trans "Group" %}</th>
                        <th width="30%">{% trans "Permission" %}</th>
                        <th width="15%"></th>
                    </tr>
                    <tr id="add-group-folder-perm">
                        <td>
                            <select name="group" class="w100" multiple="multiple"></select>
                        </td>
                        <td>
                            <select name="permission" class="perm-select w100">
                                <option value="rw" selected="selected">{% trans "Read-Write" %}</option>
                                <option value="r">{% trans "Read-Only" %}</option>
                            </select>
                        </td>
                        <td><input type="submit" value="{% trans "Submit" %}" class="submit" /></td>
                    </tr>
                </table>
                <p class="error hide"></p>
            </div>
        </div>
    </div>
</script>
<script type="text/template" id="starred-file-item-tmpl">
    <td class="alc"><img src="{{ MEDIA_URL }}img/file/<%= icon_path %>" alt="{% trans "icon" %}" /></td>
    <td>
        <% if (is_img) { %>
            <a class="img-name-link" href="{{ SITE_ROOT }}lib/<%= repo_id %>/file<%- encoded_path %>" target="_blank" data-mfp-src="{{ SITE_ROOT }}repo/<%= repo_id %>/raw<%- encoded_path %>"><%- file_name %></a>
        <% } else { %>
            <a href="{{ SITE_ROOT }}lib/<%= repo_id %>/file<%- encoded_path %>" target="_blank"><%- file_name %></a>
        <% } %>
    </td>
    <td><%- repo_name %></td>
    <td><%= mtime_relative %></td>
    <td>
        <img src="{{MEDIA_URL}}img/rm.png" alt="" class="unstar op-icon vh" title="{% trans "Unstar" %}" />
    </td>
</script>
<script type="text/template" id="my-repos-hd-tmpl">
   <tr>
       <th width="4%"><!--icon--></th>
       <th width="46%" class="by-name cspt">{% trans "Name" %} <span class="sort-icon icon-caret-down hide"></span></th>
       <th width="10%"><!--op--></th>
       <th width="20%">{% trans "Size" %}</th>
       <th width="20%" class="by-time cspt">{% trans "Last Update" %} <span class="sort-icon icon-caret-up"></span></th>
   </tr>
</script>
<script type="text/template" id="shared-repos-hd-tmpl">
    <tr>
        <th width="4%"><!--icon--></th>
        <th width="40%" class="by-name cspt">{% trans "Name" %} <span class="sort-icon icon-caret-down hide"></span></th>
        <th width="8%"><!--op--></th>
        <th width="14%">{% trans "Size" %}</th>
        <th width="18%" class="by-time cspt">{% trans "Last Update" %} <span class="sort-icon icon-caret-up"></span></th>
        <th width="16%">{% trans "Shared By" %}</th>
    </tr>
</script>
<script type="text/template" id="add-pubrepo-popup-tmpl">
    <h3 class="hd">{% trans "Select libraries to share" %}</h3>
    <img class="loading-tip" width="32" src="{{MEDIA_URL}}img/loading-new.gif" alt="{% trans 'Loading...' %}" />
    <table class="hide">
        <tr>
            <th width="3%"><!--select--></th>
            <th width="6%"><!--icon--></th>
            <th width="35%">{% trans "Name" %}</th>
            <th width="25%">{% trans "Last Update" %}</th>
            <th width="31%">{% trans "Permission" %}</th>
        </tr>
    </table>
    <input type="submit" value="{% trans "Submit"%}" class="submit" />
</script>
<script type="text/template" id="add-pubrepo-item-tmpl">
    <td class="select">
        <span class="checkbox"><input type="checkbox" class="checkbox-orig" /></span>
    </td>
    <td>
      <% if (encrypted) { %>
      <img src="{{ MEDIA_URL }}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted" %}" alt="" />
      <% } else { %>
      <img src="{{ MEDIA_URL }}img/sync-folder-20.png" title="{% trans "Read-Write" %}" alt="" />
      <% } %>
    </td>
    <td><a href="#my-libs/lib/<%= id %>" target="_blank"><%- name %></a></td>
    <td><%= mtime_relative %></td>
    <td>
        <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>
    </td>
</script>
<script type="text/template" id="activity-group-hd-tmpl">
    <h4 class="activity-group-hd"><%= date %></h4>
</script>
<script type="text/template" id="activity-group-bd-tmpl">
    <ol class="activity-group-bd"></ol>
</script>
<script type="text/template" id="activity-item-tmpl">
    <%= activity.avatar %>
    <div class="txt">
        <% if (activity.etype == "repo-update") { %>
        <p class="w100 ovhd">
        <a href="#common/lib/<%= activity.repo_id %>/" class="updated-repo normal fright"><%- activity.repo_name %></a>
        <span class="cmt-desc">
            <%= activity.converted_cmmt_desc %>
            <% if (activity.more_files) { %>
                <% if (!activity.repo_encrypted) { %>
                    <a class="lsch cspt">{% trans 'Details' %}</a>
                <% } %>
            <% } %>
        </span>
        </p>
        <% } %>

        <% if (activity.etype == "repo-create") { %>
        <p>{% trans "Created library" %} <a href="#common/lib/<%= activity.repo_id %>/" class="normal"><%- activity.repo_name %></a></p>
        <% } %>

        <% if (activity.etype == "repo-delete") { %>
        <p>{% trans "Deleted library" %} <%- activity.repo_name %></p>
        <% } %>

        <p><a class="normal" href="{{ SITE_ROOT }}profile/<% print(encodeURIComponent(activity.author)); %>/"><%- activity.name %></a> <span class="time"><%= activity.time_relative %></span></p>
    </div>
</script>
<script type="text/template" id="details-popup-tmpl">
    <h3>{% trans "Modification Details"%}</h3>
    <p class="commit-time"></p>
    <img class="loading-tip" width="32" src="{{MEDIA_URL}}img/loading-new.gif" alt="{% trans 'Loading...' %}" />
</script>
<script type="text/template" id="detail-item-tmpl">
    <h4><%= details_title %></h4>
    <ul>
    <% for (var i = 0, len = details.length; i < len; i++) { %>
        <li><%= details[i] %></li>
    <% } %>
    </ul>
</script>
