diff --git a/seahub/message/templates/message/user_msg_list.html b/seahub/message/templates/message/user_msg_list.html index 202e463475..61e7716cd5 100644 --- a/seahub/message/templates/message/user_msg_list.html +++ b/seahub/message/templates/message/user_msg_list.html @@ -152,7 +152,7 @@ $('#personal-message-form').submit(function() { var new_msg = $(data['html']); if ($('.msg-list').length == 0) { // the new discussion is the first discussion in this page form.after('
' + "{% trans "You don't have any library at present" %}" + '
'); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + if (!jqXHR.responseText) { + dir_tree_cont.html('' + "{% trans "Failed. Please check the network." %}" + '
'); + } + } + }); +}); +$('.submit', sublib_create_form).click(function() { + var ori_repo_id = $('[name="dst_repo"]', sublib_create_form).val(); + var path = $('[name="dst_path"]', sublib_create_form).val(); + + if (!path || path == '/') { + $('.error', sublib_create_form).html("{% trans "Please choose a directory" %}").removeClass('hide'); + return false; + } + + // path ends with '/', rm it here + path = path.substr(0, path.length - 1); + $.ajax({ + url: '{{SITE_ROOT}}ajax/repo/' + ori_repo_id + '/dir/sub_repo/?p=' + e(path), + dataType: 'json', + success: function(data) { + location.reload(); + }, + error: function(xhr, textStatus, errorThrown) { + var err; + if (xhr.responseText) { + err = jQuery.parseJSON(xhr.responseText).error; + } else { + err = "{% trans "Failed. Please check the network." %}"; + } + $('.error', sublib_create_form).html(err).removeClass('hide'); + } + }); + return false; +}); +{% endif %} {% include "snippets/repo_create_js.html" with post_url=repo_create_url %} {% endblock %} diff --git a/seahub/templates/repo.html b/seahub/templates/repo.html index 27f397b217..3a9fa96909 100644 --- a/seahub/templates/repo.html +++ b/seahub/templates/repo.html @@ -205,16 +205,6 @@ - {% if ENABLE_SUB_LIBRARY and sub_lib_enabled and not repo.is_virtual %} -{% trans "A sub-library will be created from this directory. It will be listed in your desktop client, and you can download it just like downloading a normal library." %}
- - - -{% trans "Sub-library is created." %}
"); - $('.simplemodal-close', popup).removeClass('hide'); - }, - error: function(xhr, textStatus, errorThrown) { - var err; - if (xhr.responseText) { - err = jQuery.parseJSON(xhr.responseText).error; - } else { - err = "{% trans "Failed. Please check the network." %}"; - } - $('.error', popup).html(err).removeClass('hide'); - } - }); - }); - return false; -}); -{% endif %} - } //function 'opOnDirent' ends here $('#add-new-file-form, #add-new-dir-form, #rename-form, #mv-form').submit(function() { @@ -1992,7 +1949,7 @@ function updateCmt() { // check if a sub-lib exists, if not, create one $.ajax({ - url: '{% url 'sub_repo' repo.id %}?p=' + e(form.data('dir-path')) + '&name=' + e(form.attr('data-name')), + url: '{% url 'sub_repo' repo.id %}?p=' + e(form.data('dir-path')), dataType: 'json', success: function(data) { $('[name="repo_id"]', form).val(data['sub_repo_id']); diff --git a/seahub/templates/snippets/msg_form_js.html b/seahub/templates/snippets/msg_form_js.html index 6708a2815b..875936970f 100644 --- a/seahub/templates/snippets/msg_form_js.html +++ b/seahub/templates/snippets/msg_form_js.html @@ -12,22 +12,23 @@ $('.cancel', msg_form).click(function() { $('.add-file').click(function(){ $('#add-file-popup').modal(); + var file_tree_cont = $('#file-tree'); $.ajax({ - 'url': repos_get_url, - 'cache': false, - 'dataType': 'json', - 'success': function(data) { + url: repos_get_url, + cache: false, + dataType: 'json', + success: function(data) { var file_tree = new FileTree(); var repos = file_tree.format_repo_data(data); if (repos.length > 0) { - file_tree.renderFileTree($('#file-tree').data('site_root', '{{SITE_ROOT}}'), repos, {'two_state': true}); + file_tree.renderFileTree(file_tree_cont.data('site_root', '{{SITE_ROOT}}'), repos, {'two_state': true}); } else { - $('#file-tree').html('' + "{% trans "You don't have any library at present" %}" + '
'); + file_tree_cont.html('' + "{% trans "You don't have any library at present" %}" + '
'); } }, - 'error': function(jqXHR, textStatus, errorThrown) { + error: function(jqXHR, textStatus, errorThrown) { if (!jqXHR.responseText) { - $('#file-tree').html('' + "{% trans "Failed. Please check the network." %}" + '
'); + file_tree_cont.html('' + "{% trans "Failed. Please check the network." %}" + '
'); } } }); diff --git a/seahub/templates/snippets/my_owned_repos.html b/seahub/templates/snippets/my_owned_repos.html index c4c62edbcf..fa7fa97bf6 100644 --- a/seahub/templates/snippets/my_owned_repos.html +++ b/seahub/templates/snippets/my_owned_repos.html @@ -3,14 +3,21 @@