2012-07-26 09:08:31 +00:00
{% extends base_template %}
2012-10-27 09:23:30 +00:00
{% load seahub_tags avatar_tags i18n %}
2012-08-13 07:58:54 +00:00
{% load url from future %}
2011-08-16 13:05:42 +00:00
2012-06-12 02:13:14 +00:00
{% block info_bar_message %}
{% if request.user.is_authenticated %}
{{ block.super }}
{% else %}
2012-08-18 09:00:44 +00:00
< div id = "sharelink-infobar" >
2012-10-29 13:43:52 +00:00
< p > {% blocktrans %}This page will be invalid shortly, you can join < a href = "http://seafile.com/" target = "_blank" > Seafile< / a > to experience more.{% endblocktrans %}< / p >
2012-06-12 02:13:14 +00:00
< / div >
{% endif %}
{% endblock %}
2012-09-04 08:13:06 +00:00
{% block main_panel %}
2012-09-15 13:01:06 +00:00
< div class = "w100 ovhd" >
< h2 class = "fleft" > {{repo.props.name}}< / h2 >
2012-10-24 09:38:03 +00:00
< div class = "fright" >
2013-01-03 11:28:57 +00:00
{% if path == '/' %}
2013-01-10 06:34:53 +00:00
{% if user_perm %}
2013-02-05 09:50:32 +00:00
< button id = "repo-download-btn" class = "repo-top-op-btn" > {% trans "Download"%}< / button >
2013-01-10 06:34:53 +00:00
{% endif %}
2013-01-10 07:02:25 +00:00
{% if is_repo_owner %}
2013-02-05 09:50:32 +00:00
< button id = "repo-setting-btn" class = "repo-top-op-btn" > {% trans "Settings" %}< / button >
2013-01-10 06:34:53 +00:00
{% endif %}
2013-01-02 06:49:41 +00:00
{% if user_perm == 'rw' %}
2013-02-05 09:50:32 +00:00
< button id = "recycle-btn" data = "{% url 'repo_recycle_view' repo.id %}" class = "repo-top-op-btn" > {% trans "Trash"%}< / button >
2013-01-02 06:49:41 +00:00
{% endif %}
2013-01-10 06:34:53 +00:00
{% else %}
2013-01-10 07:02:25 +00:00
{% if is_repo_owner %}
< input id = "shared-link" class = "hide" type = "text" readonly = "readonly" value = "{{ dir_shared_link }}" / >
< button data = "{% url 'get_shared_link' %}?repo_id={{ repo.id }}&p={{ path|urlencode }}&type=d" id = "get-shared-link" class = "hide" > {% trans "Share link"%}< / button >
< button id = "send-shared-link" class = "hide" > {% trans "Send"%}< / button >
< button data = "{% url 'remove_shared_link' %}?t={{ fileshare.token }}" id = "rm-shared-link" class = "hide" > {% trans "Delete"%}< / button >
{% endif %}
2013-01-03 11:28:57 +00:00
{% endif %}
2012-10-24 09:38:03 +00:00
< / div >
2012-09-15 13:01:06 +00:00
< / div >
2012-10-11 02:55:13 +00:00
{% if user_perm == 'r' %}
2013-01-21 03:34:18 +00:00
< p > {% trans "This library is read-only, you can not modify the contents of this library."%}< / p >
2012-09-21 03:22:46 +00:00
{% endif %}
2012-10-11 02:55:13 +00:00
2012-11-27 08:40:09 +00:00
{% if user_perm and path == '/' %}
2012-09-15 13:01:06 +00:00
< div id = "repo-basic-info" >
< p class = "desc" > {{repo.props.desc}}< / p >
2012-10-31 11:36:29 +00:00
< p class = "size" > {% trans 'Size: ' %}{{ repo_size|filesizeformat }}< / p >
2012-09-15 13:01:06 +00:00
< / div >
2012-10-11 02:55:13 +00:00
2012-09-17 04:57:29 +00:00
< div id = "repo-latest-commit" >
2012-09-15 13:01:06 +00:00
< p class = "commit-msg ovhd" >
< span class = "fleft" >
{{ current_commit.props.desc|translate_commit_desc }}
2013-01-11 08:41:40 +00:00
< a class = "lsch" href = "#" data-url = "{% url 'repo_history_changes' repo.id %}?commit_id={{ current_commit.id }}" data-time = "{{ current_commit.props.ctime|tsstr_sec }}" > {% trans "Details"%}< / a >
2012-09-15 13:01:06 +00:00
< / span >
2013-01-21 03:34:18 +00:00
{% if user_perm %}
2012-10-29 13:43:52 +00:00
< a href = "{% url 'seahub.views.repo_history' repo.id %}" class = "more fright" > {% trans "History"%}< / a >
2012-09-15 13:01:06 +00:00
{% endif %}
< / p >
< p class = "meta-info" >
< span class = "author" >
{% if current_commit.props.creator_name %}
2013-01-04 09:15:37 +00:00
{% if not current_commit.second_parent_id %}
{% avatar current_commit.props.creator_name 20 %}
< a class = "name" href = "{% url 'profile.views.user_profile' current_commit.props.creator_name %}" > {{ current_commit.creator_name|email2nickname }}< / a >
{% else %}
< span class = "name" > {% trans "Generated by system"%}< / span >
{% endif %}
2012-09-15 13:01:06 +00:00
{% else %}
2013-01-04 09:15:37 +00:00
{% trans "Unknown"%}
2012-06-20 13:38:07 +00:00
{% endif %}
2012-09-15 13:01:06 +00:00
< / span >
2012-11-05 09:27:57 +00:00
< span class = "time" > {{ current_commit.props.ctime|translate_seahub_time }}< / span >
2012-09-15 13:01:06 +00:00
< / p >
2012-05-04 13:36:36 +00:00
< / div >
2012-10-11 02:55:13 +00:00
{% endif %}
2012-09-15 13:01:06 +00:00
< div class = "repo-file-list-outer-container" >
< div class = "repo-file-list-inner-container" >
2012-09-17 10:01:51 +00:00
{% if not user_perm %}
2012-09-15 13:01:06 +00:00
< div class = "repo-file-list-not-show" >
2012-10-29 13:43:52 +00:00
< p class = "access-notice" > {% trans "You can't access this library."%}< / p >
2012-09-15 13:01:06 +00:00
< / div >
{% else %}
< div class = "repo-file-list-topbar ovhd" >
< p class = "path fleft" >
2012-10-27 09:23:30 +00:00
{% trans "Current path: "%}
2012-09-15 13:01:06 +00:00
{% for name, link in zipped %}
{% if not forloop.last %}
2012-07-05 11:29:56 +00:00
< a href = "{{ SITE_ROOT }}repo/{{ repo.id }}/?p={{ link|urlencode }}" > {{ name }}< / a > /
2012-09-15 13:01:06 +00:00
{% else %}
{{ name }}
{% endif %}
{% endfor %}
< / p >
< div class = "repo-op fright" >
2013-01-03 11:28:57 +00:00
{% if user_perm and path != '/' %}
2013-01-04 05:43:03 +00:00
< button data = "{% url 'repo_download_dir' repo.id %}?p={{ path|urlencode }}" id = "download-dir" class = "op-btn" > {% trans "ZIP"%}< / button >
2013-01-03 11:28:57 +00:00
{% endif %}
{% if user_perm == 'rw' %}
2012-10-27 09:23:30 +00:00
< button data = "{{ SITE_ROOT }}repo/upload_file/{{repo.id}}/?p={{ path|urlencode }}" id = "upload-file" class = "op-btn" > {% trans "Upload"%}< / button >
2012-10-29 13:43:52 +00:00
< button id = "add-new-dir" class = "op-btn" > {% trans "New Directory"%}< / button >
2012-10-27 09:23:30 +00:00
< button id = "add-new-file" class = "op-btn" > {% trans "New File"%}< / button >
2013-01-03 11:28:57 +00:00
{% endif %}
2012-09-15 13:01:06 +00:00
< / div >
< / div >
< table class = "repo-file-list" >
< tr >
2012-12-21 11:53:09 +00:00
< th width = "3%" > < / th >
2012-09-15 13:01:06 +00:00
< th width = "5%" > < / th >
2013-01-04 09:15:37 +00:00
< th width = "43%" class = "dirent-name" > {% trans "Name"%} < span id = "name-up" class = "tri-bg tri-up-order-bg" > < / span > < span id = "name-down" class = "tri-bg tri-down-order-bg" > < / span > < / th >
2012-10-27 09:23:30 +00:00
< th width = "10%" > {% trans "Size"%}< / th >
2013-01-04 09:15:37 +00:00
< th width = "12%" > {% trans "Last Update" %} < span id = "time-up" class = "tri-bg tri-up-order-bg" > < / span > < span id = "time-down" class = "tri-bg tri-down-order-bg" > < / span > < / th >
< th width = "27%" class = "dirent-op" > {% trans "Operations"%}< / th >
2012-09-15 13:01:06 +00:00
< / tr >
{% for dirent in dir_list %}
2013-01-04 09:15:37 +00:00
< tr class = "dir-item" data-name = "{{dirent.obj_name}}" data-time = "{% if dirent.last_modified %}{{ dirent.last_modified }} {%else %}0{% endif %}" >
2012-12-21 11:53:09 +00:00
< td > < / td >
2012-10-29 13:43:52 +00:00
< td class = "icon-container" > < img src = "{{ MEDIA_URL }}img/folder-icon-24.png" alt = "{% trans " Directory icon " % } " / > < / td >
2012-09-15 13:01:06 +00:00
< td >
< a href = "{{ SITE_ROOT }}repo/{{ repo.id }}/?p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}" > {{ dirent.obj_name }}< / a >
< / td >
< td > < / td >
2012-12-31 09:32:13 +00:00
< td >
{% if dirent.last_modified %}
{{ dirent.last_modified|translate_seahub_time }}
{% else %}
2013-01-04 09:15:37 +00:00
{% trans "Fetch failed" %}
2012-12-31 09:32:13 +00:00
{% endif %}
< / td >
2012-09-15 13:01:06 +00:00
< td >
2012-11-02 07:17:55 +00:00
{% if user_perm %}
2012-09-17 02:32:31 +00:00
< div class = "repo-file-op vh" >
2012-12-05 07:27:15 +00:00
< div class = "displayed-op" >
2013-01-03 11:28:57 +00:00
< a class = "op" href = "{% url 'repo_download_dir' repo.id %}?p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}" > {% trans 'Download' %}< / a >
2013-01-10 07:02:25 +00:00
{% if is_repo_owner %}
2013-01-10 06:56:25 +00:00
< a class = "op file-share" href = "#" data-name = "{{ dirent.obj_name }}" data-link = "{{ dirent.sharelink }}" data-token = "{{ dirent.sharetoken }}" data-type = "d" > {% trans "Share" %}< / a >
{% endif %}
2012-12-05 07:27:15 +00:00
< / div >
2012-12-05 14:07:22 +00:00
{% if user_perm == 'rw' %}
2012-10-29 13:43:52 +00:00
< img src = "{{ MEDIA_URL }}img/dropdown-arrow.png" title = "{% trans 'More operations'%}" alt = "{% trans 'More operations'%}" class = "more-op-icon" data = "no-popup" / >
2012-09-15 13:01:06 +00:00
< ul class = "hidden-op hide" >
2012-10-27 09:23:30 +00:00
< li > < a class = "op" href = "{{ SITE_ROOT }}repo/{{ repo.props.id }}/{{ dirent.props.obj_id }}/?p={{ path|urlencode }}&file_name={{ dirent.props.obj_name|urlencode }}&op=del" > {% trans "Delete"%}< / a > < / li >
< li > < a class = "op dir-rename" href = "#" data = "{{ dirent.obj_name }}" > {% trans "Rename"%}< / a > < / li >
< li > < a class = "op dir-mv" href = "#" data = "{{ dirent.obj_name }}" > {% trans "Move"%}< / a > < / li >
< li > < a class = "op dir-cp" href = "#" data = "{{ dirent.obj_name }}" > {% trans "Copy"%}< / a > < / li >
2012-09-15 13:01:06 +00:00
< / ul >
2012-12-05 14:07:22 +00:00
{% endif %}
2012-09-15 13:01:06 +00:00
< / div >
2012-11-02 07:17:55 +00:00
{% endif %}
2012-09-15 13:01:06 +00:00
< / td >
< / tr >
{% endfor %}
{% for dirent in file_list %}
2013-01-04 09:15:37 +00:00
< tr class = "file-item" data-name = "{{dirent.obj_name}}" data-time = "{% if dirent.last_modified %}{{ dirent.last_modified }} {%else %}0{% endif %}" >
2012-12-21 11:53:09 +00:00
< td class = "icon-container" >
{% if dirent.starred %}
2013-01-08 02:48:11 +00:00
< img src = "{{ MEDIA_URL }}img/gray-star-icon.png" alt = "{% trans 'starred' %}" title = "{% trans 'starred' %}" class = "file-star" data-path = "{{ path }}{{dirent.obj_name}}" data-status = "starred" / >
2012-12-21 11:53:09 +00:00
{% else %}
2013-01-08 02:48:11 +00:00
< img src = "{{ MEDIA_URL }}img/gray-unstar-icon.png" alt = "{% trans 'unstarred' %}" title = "{% trans 'unstarred' %}" class = "file-star" data-path = "{{ path }}{{dirent.obj_name}}" data-status = "unstarred" / >
2012-12-21 11:53:09 +00:00
{% endif %}
< / td >
2012-10-27 09:23:30 +00:00
< td class = "icon-container" > < img src = "{{ MEDIA_URL }}img/file/{{ dirent.obj_name|file_icon_filter }}" alt = "{% trans " File " % } " / > < / td >
2012-09-15 13:01:06 +00:00
< td >
< a class = "op" href = "{{ SITE_ROOT }}repo/{{ repo.props.id }}/files/?p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}" > {{ dirent.props.obj_name }}< / a >
< / td >
< td > {{ dirent.file_size|filesizeformat }}< / td >
2012-12-31 09:32:13 +00:00
< td >
{% if dirent.last_modified %}
{{ dirent.last_modified|translate_seahub_time }}
{% else %}
2013-01-04 09:15:37 +00:00
{% trans "Fetch failed" %}
2012-12-31 09:32:13 +00:00
{% endif %}
< / td >
2012-09-15 13:01:06 +00:00
< td >
2012-09-17 02:32:31 +00:00
< div class = "repo-file-op vh" >
< div class = "displayed-op" >
2012-10-27 09:23:30 +00:00
< a class = "op" href = "{{ SITE_ROOT }}repo/{{ repo.props.id }}/{{ dirent.props.obj_id }}/?file_name={{ dirent.props.obj_name }}&op=download" > {% trans "Download"%}< / a >
2012-10-24 09:38:03 +00:00
{% if user_perm == 'rw' %}
2013-01-10 07:02:25 +00:00
< a class = "op update-file" data-target = "{{ path }}{{dirent.obj_name}}" href = "#" > {% trans "Update"%}< / a >
{% if is_repo_owner %}
< a class = "op file-share" href = "#" data-name = "{{ dirent.obj_name }}" data-link = "{{ dirent.sharelink }}" data-token = "{{ dirent.sharetoken }}" > {% trans "Share" %}< / a >
{% endif %}
2012-10-24 09:38:03 +00:00
{% endif %}
2012-09-15 13:01:06 +00:00
< / div >
2012-10-17 07:37:15 +00:00
{% if user_perm == 'rw' %}
2012-10-27 09:23:30 +00:00
< img src = "{{ MEDIA_URL }}img/dropdown-arrow.png" title = "{% trans " More Operations " % } " alt = "{% trans " More Operations " % } " class = "more-op-icon" data = "no-popup" / >
2012-09-15 13:01:06 +00:00
< ul class = "hidden-op hide" >
2012-10-29 13:43:52 +00:00
< li > < a class = "op" href = "{{ SITE_ROOT }}repo/{{ repo.props.id }}/{{ dirent.props.obj_id }}/?p={{ path|urlencode }}&file_name={{ dirent.props.obj_name|urlencode }}&op=del" > {% trans "Delete" %}< / a > < / li >
< li > < a class = "op file-rename" href = "#" data = "{{ dirent.obj_name }}" > {% trans "Rename" %}< / a > < / li >
< li > < a class = "op file-mv" href = "#" data = "{{ dirent.obj_name }}" > {% trans "Move" %}< / a > < / li >
< li > < a class = "op file-cp" href = "#" data = "{{ dirent.obj_name }}" > {% trans "Copy" %}< / a > < / li >
< li > < a class = "op" href = "{% url 'file_revisions' repo.props.id %}?p={{ path }}{{ dirent.obj_name }}" > {% trans "History" %}< / a > < / li >
2012-09-15 13:01:06 +00:00
< / ul >
2012-10-17 07:37:15 +00:00
{% endif %}
2012-09-15 13:01:06 +00:00
< / div >
< / td >
< / tr >
{% endfor %}
< / table >
{% endif %}
< / div >
2012-05-04 13:36:36 +00:00
< / div >
2012-07-02 02:21:17 +00:00
2013-01-04 09:15:37 +00:00
{% if user_perm %}
2012-11-17 09:31:37 +00:00
< div id = "upload-file-dialog" class = "hide" >
2012-11-27 03:17:14 +00:00
< h3 > {% trans "Upload Files" %}< / h3 >
2012-12-08 12:11:39 +00:00
{% if no_quota %}
2012-12-06 09:44:50 +00:00
< p class = "error" > {% trans "The owner of this library has ran out of space." %}< / p >
2012-12-08 12:11:39 +00:00
{% else %}
2012-11-17 09:31:37 +00:00
< form id = "upload-file-form" enctype = "multipart/form-data" method = "post" action = "{{ upload_url }}" >
2012-12-08 12:11:39 +00:00
< input type = "hidden" name = "parent_dir" id = "parent_dir" value = "{{ parent_dir }}" / >
< div class = "files-add" >
2013-02-05 09:50:32 +00:00
< span class = "op add" > {% trans "Add files" %}< / span >
2012-12-08 12:11:39 +00:00
< span id = "upload-add-tip" > ({% trans "smaller than" %} {{ max_upload_file_size|filesizeformat }})< / span >
< input type = "file" name = "file" id = "file-upload-input" / >
< / div >
< div id = "upload-file-list" > < / div >
< p class = "error" > {{ error_msg }}< / p >
< input type = "submit" value = "{% trans " Upload " % } " class = "submit" / >
2012-11-17 09:31:37 +00:00
< / form >
2012-12-08 12:11:39 +00:00
< div id = "upload-progress-con" class = "upload-progress-con hide" >
< p > {% trans "Uploaded:" %} < span class = "upload-progress-text" > {% trans "Fetching ..." %}< / span > < / p >
< div class = "upload-progress-bar" > < / div >
< button class = "upload-cancel" > {% trans "Cancel" %}< / button >
< iframe class = "hide" > <!-- for chrome --> < / iframe >
2012-11-17 09:31:37 +00:00
< / div >
2012-12-08 12:11:39 +00:00
{% endif %}
2012-11-17 09:31:37 +00:00
< / div >
< div id = "update-file-dialog" class = "hide" >
2013-01-07 06:05:09 +00:00
< h3 > {% trans "Update File" %}< / h3 >
2012-12-08 12:11:39 +00:00
{% if no_quota %}
< p class = "error" > {% trans "The owner of this library has ran out of space." %}< / p >
{% else %}
2012-11-17 09:31:37 +00:00
< form id = "update-file-form" enctype = "multipart/form-data" method = "post" action = "{{ update_url }}?head={{ head_id }}" >
2012-12-08 12:11:39 +00:00
< input type = "hidden" name = "target_file" / >
< input type = "file" name = "file" id = "file-update-input" / >
< p > ({% trans "Smaller than" %} {{ max_upload_file_size|filesizeformat }})< / p >
< p class = "error" > {{ error_msg }}< / p >
< input type = "submit" value = "{% trans " Update " % } " class = "submit" / >
2012-11-17 09:31:37 +00:00
< / form >
2012-12-08 12:11:39 +00:00
< div id = "update-progress-con" class = "upload-progress-con hide" >
< p > {% trans "Uploaded:" %} < span class = "upload-progress-text" > {% trans "Fetching..." %}< / span > < / p >
< div class = "upload-progress-bar" > < / div >
< button class = "upload-cancel" > {% trans "Cancel" %}< / button >
< iframe class = "hide" > <!-- for chrome --> < / iframe >
2012-11-17 09:31:37 +00:00
< / div >
2012-12-08 12:11:39 +00:00
{% endif %}
2012-11-17 09:31:37 +00:00
< / div >
2013-01-02 06:49:41 +00:00
{% if is_repo_owner or request.user.is_staff %}
< form id = "repo-setting-form" action = "" method = "post" class = "simple-input-popup hide" > {% csrf_token %}
< h3 > {% trans "Library Settings" %}< / h3 >
< label > {% trans "History" %}< / label > < br / >
< input type = "hidden" name = "repo_id" value = "{{ repo.id }}" / >
2013-01-16 08:35:32 +00:00
< input type = "radio" name = "history" value = "full_history" { % if history_limit < 0 % } checked = "checked" { % endif % } / > {% trans "Keep full history" %}< br / >
< input type = "radio" name = "history" value = "no_history" { % if history_limit = = 0 % } checked = "checked" { % endif % } / > {% trans "Don't keep history" %}< br / >
< input type = "radio" name = "history" value = "partial_history" { % if history_limit > 0 %}checked="checked"{% endif %} /> {% trans "Only keep a period of history:" %}
< input type = "text" name = "days" size = "4" { % if history_limit < = 0 % } disabled = "disabled" class = "input-disabled" { % else % } value = "{{history_limit}}" { % endif % } / > {% trans "days" %}< br / >
2013-01-02 06:49:41 +00:00
< p class = "error hide" > < / p >
< input type = "submit" value = "{% trans " Submit " % } " class = "submit" / >
< button class = "simplemodal-close" > {% trans "Cancel" %}< / button >
< / form >
{% endif %}
2012-11-10 03:31:05 +00:00
< form id = "add-new-dir-form" action = "" method = "post" class = "simple-input-popup hide" > {% csrf_token %}
< h3 > {% trans "New Directory" %}< / h3 >
2013-01-08 09:43:29 +00:00
< label > {% trans "Directory Name" %}< / label > < br / > <!-- <br/> for ie 7 -->
2012-07-02 02:21:17 +00:00
< input type = "hidden" name = "repo_id" value = "{{ repo.id }}" / >
< input type = "hidden" name = "parent_dir" value = "{{ path }}" / >
2012-12-25 07:05:12 +00:00
< input type = "text" name = "new_dir_name" value = "" class = "long-input" maxlength = "{{max_file_name}}" / > < br / >
2012-09-07 03:01:44 +00:00
< p class = "error hide" > < / p >
2012-10-29 13:43:52 +00:00
< input type = "submit" value = "{% trans " Submit " % } " class = "submit" / >
< button class = "simplemodal-close" > {% trans "Cancel" %}< / button >
2012-07-02 02:21:17 +00:00
< / form >
2012-11-10 03:31:05 +00:00
< form id = "add-new-file-form" action = "" method = "post" class = "simple-input-popup hide" > {% csrf_token %}
< h3 > {% trans "New File" %}< / h3 >
2012-11-20 08:28:33 +00:00
< div id = "featured-filetype" >
< label > {% trans "Featured File Type" %}< / label > < br / >
2013-02-23 07:41:11 +00:00
< button type = "button" data = "seaf" title = "{% trans " Click to choose " % } " > seaf< / button > < span > {% trans "online Rich Text format (experimental)." %}< / span >
{% if LANGUAGE_CODE == 'zh-cn' %}
< a href = "http://www.seafile.com/help/seaf/" target = "_blank" > {% trans 'Details' %}< / a > < br / >
{% else %}
< a href = "http://www.seafile.com/en/help/seaf/" target = "_blank" > {% trans 'Details' %}< / a > < br / >
{% endif %}
< button type = "button" data = "md" title = "{% trans " Click to choose " % } " > markdown< / button > < span > {% trans "simple markup format." %}< / span >
{% if LANGUAGE_CODE == 'zh-cn' %}
< a href = "http://www.seafile.com/help/markdown/" target = "_blank" > {% trans 'Details' %}< / a >
{% else %}
< a href = "http://www.seafile.com/en/help/markdown/" target = "_blank" > {% trans 'Details' %}< / a >
{% endif %}
2012-11-20 08:28:33 +00:00
< / div >
2013-01-08 09:43:29 +00:00
< label > {% trans "File Name" %}< / label > < br / >
2012-08-11 06:07:12 +00:00
< input type = "hidden" name = "repo_id" value = "{{ repo.id }}" / >
< input type = "hidden" name = "parent_dir" value = "{{ path }}" / >
2013-01-08 09:43:29 +00:00
< input type = "text" name = "new_file_name" value = "" class = "long-input" maxlength = "{{max_file_name}}" / > < br / >
2012-09-07 03:01:44 +00:00
< p class = "error hide" > < / p >
2012-10-27 09:23:30 +00:00
< input type = "submit" value = "{% trans " Submit " % } " class = "submit" / >
< button class = "simplemodal-close" > {% trans "Cancel"%}< / button >
2012-08-11 06:07:12 +00:00
< / form >
2012-07-02 02:21:17 +00:00
< form id = "mv-form" action = "{{ SITE_ROOT }}file/move/" method = "post" class = "hide" >
2012-09-06 11:50:04 +00:00
< h3 id = "mv-hd" > < / h3 >
2012-12-06 03:30:23 +00:00
< h4 id = "mv-detail" > < / h4 >
< div id = "mv-dir-list" >
< h5 > < span class = "tri-bg tri-down-bg" > < / span > {% trans "Current Library"%}< / h5 >
2012-09-07 03:19:18 +00:00
< div id = "current-repo-dirs" > < / div >
2012-12-06 03:30:23 +00:00
< h5 > < span class = "tri-bg tri-right-bg" > < / span > {% trans "Other Libraries"%}< / h5 >
2012-09-06 11:50:04 +00:00
< div id = "other-repos-dirs" class = "hide" > < / div >
< / div >
2012-12-06 03:30:23 +00:00
< input type = "hidden" name = "operation" id = "mv-type" value = "" / >
2012-07-02 02:21:17 +00:00
< input type = "hidden" name = "src_repo" value = "{{ repo.id }}" / >
< input type = "hidden" name = "src_path" value = "{{ path }}" / >
< input type = "hidden" name = "obj_name" value = "" / >
< input type = "hidden" name = "obj_type" value = "" / >
< input type = "hidden" name = "dst_repo" value = "" / >
< input type = "hidden" name = "dst_path" value = "" / >
2012-10-29 13:43:52 +00:00
< p class = "error hide" > {% trans "Please click and choose a directory."%}< / p >
2012-10-27 09:23:30 +00:00
< input type = "submit" value = "{% trans " Submit " % } " class = "submit" / >
< button class = "simplemodal-close" > {% trans "Cancel"%}< / button >
2012-07-02 02:21:17 +00:00
< / form >
2012-12-01 07:37:54 +00:00
< form id = "rename-form" action = "{{ SITE_ROOT}}repo/file_rename/" method = "post" class = "simple-input-popup hide" >
2012-12-06 03:30:23 +00:00
< h3 > {% trans 'Rename < span id = "rename-type" > < / span > ' %}< / h3 >
< p > {% trans 'Rename < span id = "rename-obj" class = "op-target" > < / span > as: ' %}< / p >
2012-07-02 02:21:17 +00:00
< input type = "hidden" name = "repo_id" value = "{{ repo.id }}" / >
< input type = "hidden" name = "parent_dir" value = "{{ path }}" / >
< input type = "hidden" name = "oldname" value = "" / >
2012-12-25 07:05:12 +00:00
< input type = "text" name = "newname" value = "" class = "long-input" maxlength = "{{max_file_name}}" / > < br / >
2012-09-07 03:01:44 +00:00
< p class = "error hide" > < / p >
2012-10-27 09:23:30 +00:00
< input type = "submit" value = "{% trans " Submit " % } " class = "submit" / >
< button class = "simplemodal-close" > {% trans "Cancel"%}< / button >
2012-07-02 02:21:17 +00:00
< / form >
2012-10-22 09:15:35 +00:00
2012-12-29 12:46:26 +00:00
< div id = "file-share" class = "hide" >
< h3 > {% trans 'Share' %} < span class = "op-target" > < / span > < / h3 >
2013-01-03 11:28:57 +00:00
< p > {% trans 'Link: ' %}< input type = "text" readonly = "readonly" id = "shared-link-text" / > < / p >
2012-12-29 12:46:26 +00:00
< button id = "send-link" > {% trans 'Send' %}< / button >
2013-01-03 11:28:57 +00:00
< form id = "link-send-form" action = "" method = "post" class = "hide" >
2013-01-04 09:15:37 +00:00
< label > {% trans "Send to:"%}< / label > < br / >
< textarea id = "link-send-input" name = "email" placeholder = "{% trans " Emails , Seperated by ' , ' " % } " > < / textarea > < br / >
< input type = "hidden" name = "file_shared_link" value = "{{ dir_shared_link }}" / >
< input type = "submit" value = "{% trans " Submit " % } " class = "submit" / >
< p class = "error hide" > < / p >
< p id = "sending" class = "hide" > {% trans "Sending..."%}< / p >
2012-12-29 12:46:26 +00:00
< / form >
< / div >
2013-01-04 09:15:37 +00:00
{% endif %}
2012-12-29 12:46:26 +00:00
2012-08-13 07:58:54 +00:00
{% with attach_type='dir' %}
{% include "snippets/group_recommend_form.html" %}
{% endwith %}
2011-08-16 13:05:42 +00:00
{% endblock %}
2011-10-18 07:41:48 +00:00
{% block extra_script %}
2012-07-02 02:21:17 +00:00
< script type = "text/javascript" src = "{{ MEDIA_URL }}jstree_pre1.0_stable/jquery.jstree.js" > < / script >
2012-11-20 09:03:43 +00:00
< script type = "text/javascript" src = "{{ MEDIA_URL }}js/jquery.MultiFile.pack.js" > < / script >
2011-10-18 07:41:48 +00:00
< script type = "text/javascript" >
2013-01-04 09:15:37 +00:00
//download, trash
$('#repo-download-btn').click(function() {
window.open('{{ SITE_ROOT }}seafile_access_check/?repo_id={{repo.props.id}}');
});
$('#recycle-btn').click(function() {
location.href = $(this).attr('data');
});
{% if is_repo_owner or request.user.is_staff %}
$('#repo-setting-btn').click(function () {
$('#repo-setting-form').modal({appendTo:'#main'});
});
$('#repo-setting-form input[name="history"]').change(function() {
var value = $(this).attr('value');
if (value == 'full_history' || value == 'no_history') {
$('#repo-setting-form input[name="days"]').attr('disabled', true).addClass('input-disabled');
} else {
$('#repo-setting-form input[name="days"]').attr('disabled', false).removeClass('input-disabled');
}
});
$('#repo-setting-form').submit(function() {
var days;
var value = $(this).find('input[name="history"]:checked').val();
if (value == 'partial_history') {
days = $(this).find('input[name="days"]').val();
} else if (value == 'full_history') {
days = -1;
} else {
days = 0;
}
var submit_btn = $(this).children('input[type="submit"]');
disable(submit_btn);
$.ajax({
url: '{% url 'views.repo_save_settings' %}',
type: 'POST',
dataType: 'json',
beforeSend: prepareCSRFToken,
data: {
'repo_id': $('#repo-setting-form input[name="repo_id"]').val(),
'days': days
},
success: function(data) {
if (data['success']) {
location.reload(true);
}
},
2013-01-07 13:15:48 +00:00
error: function(jqXHR, textStatus, errorThrown) {
if (jqXHR.responseText) {
apply_form_error('repo-setting-form', $.parseJSON(jqXHR.responseText).error);
} else {
apply_form_error('repo-setting-form', '{% trans "Failed. Please check the network." %}');
}
2013-01-04 09:15:37 +00:00
enable(submit_btn);
}
});
return false;
});
{% endif %}
//upload, new-dir, new-file, download-dir
$('#download-dir').click(function() {
location.href = $(this).attr('data');
});
$('#upload-file').click(function () {
$('#upload-file-dialog').modal({focus:false});
$('#file-upload-input').MultiFile({
list: '#upload-file-list',
STRING: {
file: '< span title = "{% trans " Click to remove " % } " onclick = "$(this).parent().prev().click()" > $file< / span > ',
duplicate: '{% trans "This file has already been selected:\n$file!" %}'
},
afterFileAppend:function() {
$('#upload-file-form .files-add input').css({'right':$('#upload-add-tip').width()});
}
});
$('#simplemodal-container').css({'height':'auto', 'width':'auto'});
$('#upload-file-form .files-add').css({'width':$('#upload-file-form .files-add').width() + 1}); // '+ 1' for ie
$('#file-upload-input').css({'right':$('#upload-add-tip').width()});
});
$('#add-new-dir').click(function () {
$('#add-new-dir-form').modal({appendTo:'#main'});
});
$('#add-new-file').click(function () {
$('#add-new-file-form').modal({appendTo:'#main', focus:false, containerCss:{'padding':'20px 25px'}});
});
$('#upload-file, #add-new-dir, #add-new-file, #repo-download-btn, #repo-setting-btn, #recycle-btn, #download-dir').hover(
function() {
$(this).css({'background-color': '#fff', 'cursor': 'pointer'});
},
function() {
$(this).css('background-color', '#f5f5f5');
}
);
$('#featured-filetype button').click(function() {
var file_name = $('#add-new-file-form input[name="new_file_name"]');
file_name.val('.' + $(this).attr('data'));
setCaretPos(file_name[0], 0);
});
2012-12-10 07:58:37 +00:00
var no_file_op_popup = true;
$("tr:gt(0)").unbind().hover( // remove previously binded hover handler at first
2012-07-02 02:21:17 +00:00
function() {
2012-09-27 08:32:17 +00:00
if (no_file_op_popup) {
$(this).addClass('hl').find('.repo-file-op').removeClass('vh');
}
2012-07-02 02:21:17 +00:00
},
function() {
2012-09-27 08:32:17 +00:00
if (no_file_op_popup) {
$(this).removeClass('hl').find('.repo-file-op').addClass('vh');
}
2012-07-02 02:21:17 +00:00
}
);
2013-01-04 09:15:37 +00:00
var current_repo = [],
other_repos = [];
{% for a_repo in accessible_repos %}
{% if a_repo.props.id == repo.props.id %}
{% if a_repo.props.has_subdir %}
current_repo.push({
'data': '{{ a_repo.props.name }}',
'attr': {'repo_id': '{{ a_repo.props.id }}'},
'state': 'closed'
});
{% else %}
current_repo.push({
'data': '{{ a_repo.props.name }}',
'attr': {'repo_id': '{{ a_repo.props.id }}'}
});
{% endif %}
{% else %}
{% if a_repo.props.has_subdir %}
other_repos.push({
'data': '{{ a_repo.props.name }}',
'attr': {'repo_id': '{{ a_repo.props.id }}'},
'state': 'closed'
});
{% else %}
other_repos.push({
'data': '{{ a_repo.props.name }}',
'attr': {'repo_id': '{{ a_repo.props.id }}'}
});
{% endif %}
{% endif %}
{% endfor %}
function opOnDirent() {
var popup_tr = ''; // the tr which the shown popup belongs to
2012-07-18 02:57:09 +00:00
$('#main-panel').removeClass('ovhd');
2013-01-10 06:34:53 +00:00
$('.more-op-icon').click(function() {
2012-12-10 07:58:37 +00:00
var hidden_op = $(this).next();
2012-09-06 03:39:00 +00:00
if ($(this).attr('data')) { // no popup
2013-01-04 09:15:37 +00:00
if ($(this).position().left + $(this).width() + hidden_op.width() < $(this).parent().width()) {
hidden_op.css({'left': $(this).position().left + $(this).width() + 5});
if ($(this).offset().top + hidden_op.height() < = $('#main').offset().top + $('#main').height()) {
2013-01-10 06:34:53 +00:00
hidden_op.css('top', 6);
2013-01-04 09:15:37 +00:00
} else {
2013-01-10 06:34:53 +00:00
hidden_op.css('bottom', 2);
2013-01-04 09:15:37 +00:00
}
} else {
hidden_op.css({'right':0});
if ($(this).offset().top + hidden_op.height() < = $('#main').offset().top + $('#main').height()) {
hidden_op.css('top', $(this).position().top + $(this).height() + 3);
} else {
hidden_op.css('bottom', $(this).position().top + $(this).height() + 3);
}
2012-07-02 02:21:17 +00:00
}
2012-12-10 07:58:37 +00:00
hidden_op.removeClass('hide');
2012-09-06 03:39:00 +00:00
$(this).attr('data','');
2012-09-27 08:32:17 +00:00
no_file_op_popup = false;
2013-01-10 06:34:53 +00:00
$('.dirent-op').data('popup_tr', $(this).parents('tr'));
2012-09-05 08:37:14 +00:00
} else {
2012-12-10 07:58:37 +00:00
hidden_op.addClass('hide');
2012-09-06 03:39:00 +00:00
$(this).attr('data','no-popup');
2012-09-27 08:32:17 +00:00
no_file_op_popup = true;
2013-01-10 06:34:53 +00:00
$('.dirent-op').data('popup_tr', '');
2012-07-02 02:21:17 +00:00
}
2012-09-05 08:37:14 +00:00
});
$(document).click(function(e) {
var target = e.target || event.srcElement;
2013-01-10 06:34:53 +00:00
var popup_tr = $('.dirent-op').data('popup_tr');
2012-12-10 07:58:37 +00:00
if (!no_file_op_popup & &
!$('.more-op-icon, .hidden-op').is(target) & &
!$('.hidden-op').find('*').is(target)) {
$('.hidden-op').addClass('hide');
$('.more-op-icon').attr('data', 'no-popup');
2012-09-27 09:15:19 +00:00
no_file_op_popup = true;
2012-12-10 07:58:37 +00:00
if (!popup_tr.find('*').is(target)) {
popup_tr.removeClass('hl').find('.repo-file-op').addClass('vh'); // clicked place: the first tr, place out of the table
2013-01-10 06:34:53 +00:00
$('.dirent-op').data('popup_tr', '');
2012-12-10 07:58:37 +00:00
$('tr:gt(0)').each(function() { // when other tr is clicked
if ($(this).find('*').is(target)) {
$(this).addClass('hl').find('.repo-file-op').removeClass('vh');
}
});
}
2012-07-02 02:21:17 +00:00
}
2012-09-05 08:37:14 +00:00
});
2012-12-10 07:58:37 +00:00
2012-09-15 13:01:06 +00:00
$('.hidden-op li').hover(
2012-07-02 02:21:17 +00:00
function() {
$(this).css('background', '#eee');
},
function() {
$(this).css('background', '#fff');
}
);
$('.file-rename, .dir-rename').click(function () {
2012-12-06 03:30:23 +00:00
var type = $(this).hasClass('file-rename') ? '{% trans "File" %}' : '{% trans "Directory" %}';
var name = $(this).attr('data');
$('#rename-type').html(type);
$('#rename-obj').html(name);
$('#rename-form input[name*="name"]').val(name);
2012-12-01 07:37:54 +00:00
$('#rename-form').modal();
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
$(window).resize();// make the popup in the center of the window
2012-07-02 02:21:17 +00:00
return false;
});
2012-07-11 09:47:08 +00:00
2012-07-02 02:21:17 +00:00
$('.file-cp, .file-mv, .dir-cp, .dir-mv').click(function () {
var obj_name = $(this).attr('data'),
mv_type = '',
file_type = '';
if ($(this).hasClass('file-cp') || $(this).hasClass('dir-cp')) {
2012-12-06 03:30:23 +00:00
$('#mv-type').val('cp');
2012-10-29 13:43:52 +00:00
mv_type = '{% trans "Copy " %}';
2012-07-02 02:21:17 +00:00
} else {
2012-12-06 03:30:23 +00:00
$('#mv-type').val('mv');
2012-10-29 13:43:52 +00:00
mv_type = '{% trans "Move " %}';
2012-07-02 02:21:17 +00:00
}
if ($(this).hasClass('file-cp') || $(this).hasClass('file-mv')) {
2012-12-06 03:30:23 +00:00
file_type = '{% trans "File" %}';
2012-07-02 02:21:17 +00:00
$('input[name="obj_type"]').val('file');
} else {
2012-12-06 03:30:23 +00:00
file_type = '{% trans "Directory" %}';
2012-12-01 13:52:50 +00:00
$('input[name="obj_type"]').val('dir');
2012-07-02 02:21:17 +00:00
}
$('input[name="obj_name"]').val(obj_name);
2012-12-06 03:30:23 +00:00
$('#mv-hd').html(mv_type + file_type);
$('#mv-detail').html(mv_type + ' < span class = "op-target" > ' + obj_name + '< / span > {% trans "to:" %}');
$('#mv-form').modal({appendTo:'#main', autoResize:true, focus:false});
2012-09-07 03:19:18 +00:00
renderDirTree($('#current-repo-dirs'), current_repo);
2012-09-06 11:50:04 +00:00
return false;
});
2012-07-02 02:21:17 +00:00
2013-01-04 09:15:37 +00:00
$('a.update-file').click(function() {
var target_file = $(this).data("target");
$('#update-file-form input[name="target_file"]').val(target_file);
$('#update-file-dialog').modal({focus:false});
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
return false;
2012-07-02 02:21:17 +00:00
});
2013-01-04 09:15:37 +00:00
$('.file-star').click(function() {
var it = $(this);
var state = it.data('status');
var path = it.data('path');
2012-09-07 03:01:44 +00:00
$.ajax({
2013-01-04 09:15:37 +00:00
url: '{{ SITE_ROOT }}repo/star_file/{{ repo.props.id }}/',
2012-09-07 03:01:44 +00:00
type: 'POST',
2013-01-04 09:15:37 +00:00
cache: false,
contentType: 'application/json; charset=utf-8',
2012-09-07 03:01:44 +00:00
beforeSend: prepareCSRFToken,
2013-01-04 09:15:37 +00:00
dataType: 'json',
2012-09-07 03:01:44 +00:00
data: {
2013-01-04 09:15:37 +00:00
path: path,
state: state,
org_id: {% if org %} {{ org.org_id }} {% else %} -1 {% endif %}
2012-09-07 03:01:44 +00:00
},
2013-01-04 09:15:37 +00:00
success:function(data) {
2012-09-07 03:01:44 +00:00
if (data['success']) {
2013-01-04 09:15:37 +00:00
if (state == 'starred') {
2013-01-08 02:48:11 +00:00
it.attr('src', '{{ MEDIA_URL }}img/gray-unstar-icon.png').attr('alt','{% trans 'unstarred' %}').attr('title','{% trans 'unstarred' %}').data('status','unstarred');
2013-01-04 09:15:37 +00:00
} else {
2013-01-08 02:48:11 +00:00
it.attr('src', '{{ MEDIA_URL }}img/gray-star-icon.png').attr('alt','{% trans 'starred' %}').attr('title','{% trans 'starred' %}').data('status','starred');
2013-01-04 09:15:37 +00:00
}
2012-09-07 03:01:44 +00:00
}
},
2013-01-07 09:04:02 +00:00
error:function(xhr, textStatus, errorThrown) {
if (xhr.responseText) {
feedback(jQuery.parseJSON(xhr.responseText).error, 'error');
} else {
feedback('{% trans "Failed. Please check the network." %}', 'error');
}
2012-09-07 03:01:44 +00:00
}
2013-01-04 09:15:37 +00:00
});
});
//file share
$('.file-share').click(function() {
var filename = $(this).data('name');
function showPopup(link) {
$('#file-share .op-target').html(trimFilename(filename, 30));
$('#shared-link-text, #link-send-form input[name="file_shared_link"]').val(link);
$('#main').append('< p id = "linkwidth" class = "hide" > ' + link + '< / p > ');
$('#shared-link-text').css({'width':$('#linkwidth').width() + 2});
$('#file-share').modal({'focus':false}); // in ff: if 'focus' is true, 'shared-link-text' gets the focus
$('#linkwidth').remove();
2013-01-09 13:14:11 +00:00
$('#simplemodal-container').css({'height':'auto'});
2013-01-04 09:15:37 +00:00
}
if ($(this).data('link')) {
showPopup($(this).data('link'));
} else {
2013-01-07 07:34:25 +00:00
var aj_url = '{% url 'get_shared_link' %}?repo_id={{ repo.id }}& p={{ path|urlencode }}' + e(filename);
2013-01-04 09:15:37 +00:00
if ($(this).data('type') == 'd') {
2013-01-07 07:34:25 +00:00
aj_url += '&type=d';
}
2013-01-04 09:15:37 +00:00
$.ajax({
url: aj_url,
dataType: 'json',
cache: false,
contentType: 'application/json; charset=utf-8',
success: function(data) {
2013-01-07 07:34:25 +00:00
showPopup(data['shared_link']);
2013-01-04 09:15:37 +00:00
},
2013-01-07 07:34:25 +00:00
error: function(xhr, textStatus, errorThrown) {
if (xhr.responseText) {
feedback(jQuery.parseJSON(xhr.responseText).error, 'error');
} else {
feedback('{% trans "Failed. Please check the network." %}', 'error');
}
2013-01-04 09:15:37 +00:00
}
});
}
2012-09-07 03:01:44 +00:00
return false;
});
2013-01-04 09:15:37 +00:00
} //function 'opOnDirent' ends here
opOnDirent();
//sort
var dir_list = [], file_list = [];
$('.dir-item').each(function() {
dir_list.push({'name':$(this).data('name'), 'time':$(this).data('time'), 'item_html':$(this).html()});
});
$('.file-item').each(function() {
file_list.push({'name':$(this).data('name'), 'time':$(this).data('time'), 'item_html':$(this).html()});
});
function afterSort() {
$('.dir-item').each(function(index, item) {
$(this).data('name', dir_list[index].name).html(dir_list[index].item_html);
});
$('.file-item').each(function(index, item) {
$(this).data('name', file_list[index].name).html(file_list[index].item_html);
});
opOnDirent();
}
$('#name-down').click(function() {
function byNameDown(a,b) {
return a.name.toLowerCase() < b.name.toLowerCase ( ) ? 1 : -1 ;
}
dir_list.sort(byNameDown);
file_list.sort(byNameDown);
afterSort();
$(this).hide();
$('#name-up').css({'display':'inline-block'});
});
$('#name-up').click(function() {
function byNameUp(a,b) {
return a.name.toLowerCase() < b.name.toLowerCase ( ) ? -1 : 1 ;
}
dir_list.sort(byNameUp);
file_list.sort(byNameUp);
afterSort();
$(this).hide();
$('#name-down').removeAttr('style');
});
$('#time-up').click(function() {
function byTimeUp(a, b) {
return a.time < b.time ? -1 : 1 ;
}
dir_list.sort(byTimeUp);
file_list.sort(byTimeUp);
afterSort();
$(this).hide();
$('#time-down').removeAttr('style');
});
$('#time-down').click(function() {
function byTimeDown(a, b) {
return a.time < b.time ? 1 : -1 ;
}
dir_list.sort(byTimeDown);
file_list.sort(byTimeDown);
afterSort();
$(this).hide();
$('#time-up').css({'display':'inline-block'});
});
function trimFilename(name, n) {
var len = name.length;
var ext = '';
var str = '';
if (len > n) {
if (name.lastIndexOf('.') != -1) { // with extension
ext = name.split('.').reverse()[0];
str = name.substr(0, n - ext.length - 3) + '...' + name.substr(name.lastIndexOf('.') - 2);
} else {
str = name.substr(0, n) + '...';
}
} else {
str = name;
}
return str;
}
2012-09-07 03:01:44 +00:00
2013-01-07 13:15:48 +00:00
$('#add-new-file-form, #add-new-dir-form, #rename-form').submit(function() {
var form = $(this);
var form_id = form.attr('id');
var post_url = '';
var post_data = {
'repo_id': form.find('input[name="repo_id"]').val(),
2013-01-08 09:43:29 +00:00
'parent_dir': form.find('input[name="parent_dir"]').val()
2013-01-07 13:15:48 +00:00
};
if (form_id == 'add-new-file-form') {
var new_file =$.trim(form.find('input[name="new_file_name"]').val());
if (!new_file) {
apply_form_error(form_id, "{% trans "It can't be blank." %}");
return false;
}
2013-01-15 07:39:53 +00:00
if (new_file.lastIndexOf('.') != -1 & & new_file.substr(0, new_file.lastIndexOf('.')).length == 0) { // if it has an extension
apply_form_error(form_id, "{% trans "Only an extension there, please input a name." %}");
return false;
}
2013-01-07 13:15:48 +00:00
post_url = '{% url 'views.repo_new_file' %}';
post_data['new_file_name'] = new_file;
} else if (form_id == 'add-new-dir-form') {
var new_dir = $.trim(form.find('input[name="new_dir_name"]').val());
if (!new_dir) {
apply_form_error(form_id, "{% trans "It can't be blank." %}");
return false;
}
post_url = '{% url 'views.repo_new_dir' %}';
post_data['new_dir_name'] = new_dir;
} else {
var new_name = $.trim(form.find('input[name="newname"]').val());
if (!new_name) {
apply_form_error(form_id, "{% trans "It can't be blank." %}");
return false;
}
post_url = '{% url 'views.repo_rename_file' %}';
post_data['oldname'] = form.find('input[name="oldname"]').val();
post_data['newname'] = new_name
2012-11-15 08:51:14 +00:00
}
2013-01-07 13:15:48 +00:00
var submit_btn = form.children('input[type="submit"]');
2012-11-15 03:28:57 +00:00
disable(submit_btn);
2012-09-07 03:01:44 +00:00
$.ajax({
2013-01-07 13:15:48 +00:00
url: post_url,
2012-09-07 03:01:44 +00:00
type: 'POST',
dataType: 'json',
beforeSend: prepareCSRFToken,
2013-01-07 13:15:48 +00:00
data: post_data,
2012-09-07 03:01:44 +00:00
success: function(data) {
if (data['success']) {
location.reload(true);
}
},
2013-01-07 13:15:48 +00:00
error: function(xhr, textStatus, errorThrown) {
var err;
if (xhr.responseText) {
err = $.parseJSON(xhr.responseText).error;
2012-09-07 03:01:44 +00:00
} else {
2013-01-07 13:15:48 +00:00
err = '{% trans "Failed. Please check the network." %}';
2012-09-07 03:01:44 +00:00
}
2013-01-07 13:15:48 +00:00
apply_form_error(form_id, err);
2012-11-15 03:28:57 +00:00
enable(submit_btn);
2012-09-07 03:01:44 +00:00
}
});
return false;
2012-07-02 02:21:17 +00:00
});
2012-09-07 03:01:44 +00:00
2012-07-02 02:21:17 +00:00
$('#mv-form .submit').click(function() {
if (!$.trim($(this).prev().prev().val())) {//if the input is empty
$(this).prev().removeClass('hide');//show error msg
2012-07-19 13:17:50 +00:00
$('#simplemodal-container').css('height', $(this).parent().height());
2012-07-02 02:21:17 +00:00
return false;
}
});
2012-08-08 09:14:04 +00:00
2013-01-04 09:15:37 +00:00
function renderDirTree(container, repo_data) {
container
.delegate('.jstree-closed', 'dblclick', function(e) {
container.jstree('open_node', $(this));
$(this).find('a').removeClass('jstree-clicked');
})
.bind('before.jstree', function(e, data) {
if (data.func === 'select_node') { // ensure only one selected dir display in the popup
$('#mv-form .jstree-clicked').removeClass('jstree-clicked');
}
})
.bind('select_node.jstree', function(e, data) {
var repo_id = data.rslt.obj.attr('repo_id') || data.inst._get_parent(data.rslt.obj).attr('repo_id');
$('input[name="dst_repo"]').attr('value', repo_id);
var path = data.inst.get_path(data.rslt.obj);
var mv_dst_path = '';
if (path.length == 1) {
mv_dst_path = '/';
2012-12-21 11:53:09 +00:00
} else {
2013-01-04 09:15:37 +00:00
path.shift();
mv_dst_path = '/' + path.join('/') + '/';
2012-12-21 11:53:09 +00:00
}
2013-01-04 09:15:37 +00:00
$('input[name="dst_path"]').attr('value', mv_dst_path);
})
.jstree({
'json_data': {
'data': repo_data,
'ajax': {
'url': function(data) {
var path = this.get_path(data);
var repo_id = data.attr('repo_id');
if (path.length == 1) {
path = '/';
} else {
path.shift();
path = '/' + path.join('/') + '/';
}
return '{{ SITE_ROOT }}file/move/get_subdir/?repo_id=' + e(repo_id) + '& path=' + e(path);
}
}
},
'core': {
'animation': 100
},
'plugins': ['themes', 'json_data', 'ui']
});
}
2013-01-02 06:49:41 +00:00
2013-01-04 09:15:37 +00:00
$('#mv-dir-list h5').click(function() {
var span = $(this).children('.tri-bg'),
next = $(this).next();
if (span.hasClass('tri-right-bg')) {
span.attr('class','tri-bg tri-down-bg');
if (next.attr('id') == 'current-repo-dirs') {
renderDirTree(next, current_repo);
} else {
renderDirTree(next, other_repos);
}
next.removeClass('hide');
2013-01-02 06:49:41 +00:00
} else {
2013-01-04 09:15:37 +00:00
span.attr('class','tri-bg tri-right-bg');
next.addClass('hide');
2013-01-02 06:49:41 +00:00
}
});
2013-01-04 09:15:37 +00:00
{% if path == '/' %}
2012-09-15 13:01:06 +00:00
{% include "snippets/list_commit_detail.html" %}
2013-01-04 09:15:37 +00:00
{% endif %}
2013-01-07 07:34:25 +00:00
{% include "snippets/shared_link_js.html" %}
2012-08-08 09:14:04 +00:00
{% include "snippets/bottom_bar.html" %}
2011-10-18 07:41:48 +00:00
< / script >
2012-11-17 09:31:37 +00:00
{% include 'snippets/file_upload_progress_js.html' %}
2011-10-18 07:41:48 +00:00
{% endblock %}