diff --git a/media/css/seahub.css b/media/css/seahub.css index 0521d9a938..f67930c871 100644 --- a/media/css/seahub.css +++ b/media/css/seahub.css @@ -2053,6 +2053,11 @@ textarea:-moz-placeholder {/* for FF */ margin:0 0 22px 64px; position:relative; } +#send-msg-form { + padding:0; + background:transparent; + margin:0; +} .msg-form .avatar { position:absolute; left:-64px; @@ -2242,7 +2247,7 @@ textarea:-moz-placeholder {/* for FF */ border:1px solid #5cb25b; } .msg-form .submit:hover { - background:#3eab36; + background:#55ab22; } .msg-form .cancel { margin-left:6px; diff --git a/media/js/base.js b/media/js/base.js index 4354d05bcb..b224eef9a1 100644 --- a/media/js/base.js +++ b/media/js/base.js @@ -461,6 +461,9 @@ FileTree.prototype.renderFileTree = function(container, repo_data, options) { container.jstree('open_node', $(this)); $(this).find('a').removeClass('jstree-clicked'); }) + .bind('select_node.jstree', function(e, data) { + $('.jstree-clicked').removeClass('jstree-clicked'); // do not show selected item + }) .jstree({ 'json_data': { 'data': repo_data, @@ -510,7 +513,8 @@ FileTree.prototype.renderFileTree = function(container, repo_data, options) { }, 'checkbox':{ 'two_state': opts.two_state, // default: false. when 'true', dir can be checked separately with file - 'override_ui':true, // nodes can be checked, or selected to be checked + // make dir can only be selected + //'override_ui':true, // nodes can be checked, or selected to be checked 'real_checkboxes': true, 'real_checkboxes_names': function(node) { // get the path array consisting of nodes starting from the root node diff --git a/seahub/group/templates/group/group_discuss.html b/seahub/group/templates/group/group_discuss.html index e61174d7fb..66e358b615 100644 --- a/seahub/group/templates/group/group_discuss.html +++ b/seahub/group/templates/group/group_discuss.html @@ -203,8 +203,18 @@ $(window).scroll(function() { {% if request.user.is_authenticated %} var msg_form = $('#group-message-form'); +$('#message').focus(function() { + $(this).height(75); + $('.ops', msg_form).removeClass('hide'); +}); +$('.cancel', msg_form).click(function() { + $('.ops', msg_form).addClass('hide'); + $('#selected-files').data('files', '').html(''); + $('#message').val('').height(25); +}); + var repos_get_url = '{% url 'get_group_repos' group.id %}'; -{% include 'snippets/msg_form_js.html' %} +{% include 'snippets/add_file_js.html' %} $('#group-message-form').submit(function() { var form = $(this); diff --git a/seahub/message/templates/message/all_msg_list.html b/seahub/message/templates/message/all_msg_list.html index ab563cc30a..afaf113571 100644 --- a/seahub/message/templates/message/all_msg_list.html +++ b/seahub/message/templates/message/all_msg_list.html @@ -39,19 +39,26 @@
-
{% csrf_token %} + {% csrf_token %}

-
- -
- -

- - +
+ + + +
    +
    +
    +

    {% trans "Choose a file or files:" %}

    +
    + +
    + + +
    {% endblock %} @@ -115,44 +122,20 @@ $(document).click(function(e) { var target = e.target || event.srcElement, popup = $('#send-msg-popup'), popup_switch = $('#add-msg'); - if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target)) { + var add_file_popup = $('#add-file-popup'); +/* + if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target) && !add_file_popup.is(target) && !add_file_popup.find('*').is(target)) { popup.addClass('hide'); } +*/ }); -$('#msg-file-share-btn').click(function() { - var msg_file_share = $('#msg-file-share'), - btn = $(this); - $.ajax({ - 'url': '{% url 'get_my_unenc_repos' %}', - 'cache': false, - 'dataType': 'json', - 'success': function(data) { - btn.addClass('hide'); - var file_tree = new FileTree(); - var repos = file_tree.format_repo_data(data); - if (repos.length > 0) { - file_tree.renderFileTree($('#msg-file-tree').css({'max-height':$(window).height() - $('#title-panel').offset().top - $('#title-panel').height() - $('#send-msg-popup').outerHeight(), 'overflow':'auto'}).data('site_root', '{{SITE_ROOT}}'), repos, {'two_state': true}); - $('#msg-file-tree').fadeIn(600); - msg_file_share.find('.icon-remove').removeClass('hide'); - } else { - msg_file_share.html('

    ' + "{% trans "You don't have any library at present" %}" + '

    '); - } - }, - 'error': function(jqXHR, textStatus, errorThrown) { - if (!jqXHR.responseText) { - msg_file_share.html('

    ' + "{% trans "Failed. Please check the network." %}" + '

    '); - } - } - }); -}); -$('#msg-file-share .icon-remove').click(function() { - $(this).addClass('hide'); - $('#msg-file-tree').fadeOut(200); - $('#msg-file-share-btn').removeClass('hide'); -}); + +var repos_get_url = '{% url 'get_my_unenc_repos' %}'; +{% include 'snippets/add_file_js.html' %} + $('#send-msg-form .cancel').click(function() { - $('#send-msg-popup').addClass('hide'); - $('#add-msg').removeClass('add-msg-hl'); + $('#send-msg-popup').addClass('hide'); + $('#selected-files').data('files','').html('').addClass('hide'); }); $('#send-msg-form').submit(function() { @@ -160,7 +143,8 @@ $('#send-msg-form').submit(function() { form_id = form.attr('id'), msg_input = $('[name="mass_msg"]', form), msg = $.trim(msg_input.val()), - emails = $('[name="mass_email"]', form).val(); + emails = $('[name="mass_email"]', form).val(), + files_ct = $('#selected-files'); if (!msg) { apply_form_error(form_id, "{% trans "message is required" %}"); @@ -174,23 +158,16 @@ $('#send-msg-form').submit(function() { var sb_btn = $('.submit', form); disable(sb_btn); - var selected = []; - $('[name="selected"][checked="checked"]', form).each(function() { - var val = $(this).val(); - if (val.charAt(val.length - 1) != '/') { // only submit file - selected.push($(this).val()); - } - }); - $.ajax({ url: form.attr('action'), type: 'POST', dataType: 'json', beforeSend: prepareCSRFToken, - data: { 'mass_msg': msg, 'mass_email': emails, 'selected': selected }, + data: { 'mass_msg': msg, 'mass_email': emails, 'selected': files_ct.data('files') || [] }, traditional: true, success: function(data) { msg_input.val(''); + files_ct.data('files','').html('').addClass('hide'); enable(sb_btn); $('#send-msg-popup').addClass('hide'); var new_trs = $(data['html']); diff --git a/seahub/message/templates/message/user_msg_list.html b/seahub/message/templates/message/user_msg_list.html index 61e7716cd5..06e1bbed3d 100644 --- a/seahub/message/templates/message/user_msg_list.html +++ b/seahub/message/templates/message/user_msg_list.html @@ -126,8 +126,18 @@ $(window).scroll(function() { {% endif %} var msg_form = $('#personal-message-form'); +$('#message').focus(function() { + $(this).height(75); + $('.ops', msg_form).removeClass('hide'); +}); +$('.cancel', msg_form).click(function() { + $('.ops', msg_form).addClass('hide'); + $('#selected-files').data('files', '').html(''); + $('#message').val('').height(25); +}); + var repos_get_url = '{% url 'get_my_unenc_repos' %}'; -{% include 'snippets/msg_form_js.html' %} +{% include 'snippets/add_file_js.html' %} $('#personal-message-form').submit(function() { var form = $(this), diff --git a/seahub/templates/snippets/msg_form_js.html b/seahub/templates/snippets/msg_form_js.html deleted file mode 100644 index 875936970f..0000000000 --- a/seahub/templates/snippets/msg_form_js.html +++ /dev/null @@ -1,58 +0,0 @@ -{# for group_discuss & personal_msg #} -{% load i18n %} -$('#message').focus(function() { - $(this).height(75); - $('.ops', msg_form).removeClass('hide'); -}); -$('.cancel', msg_form).click(function() { - $('.ops', msg_form).addClass('hide'); - $('#selected-files').data('files', '').html(''); - $('#message').val('').height(25); -}); - -$('.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) { - var file_tree = new FileTree(); - var repos = file_tree.format_repo_data(data); - if (repos.length > 0) { - file_tree.renderFileTree(file_tree_cont.data('site_root', '{{SITE_ROOT}}'), repos, {'two_state': true}); - } else { - file_tree_cont.html('

    ' + "{% trans "You don't have any library at present" %}" + '

    '); - } - }, - error: function(jqXHR, textStatus, errorThrown) { - if (!jqXHR.responseText) { - file_tree_cont.html('

    ' + "{% trans "Failed. Please check the network." %}" + '

    '); - } - } - }); -}); -$('#add-file-popup .submit').click(function() { - var files_ct = $('#selected-files'); - var selected = files_ct.data('files') || []; - $('[name="selected"][checked="checked"]', $('#file-tree')).each(function() { - var val = $(this).val(); - if (val.charAt(val.length - 1) != '/') { // only submit file - selected.push($(this).val()); - } - }); - $.modal.close(); - var files = ''; - for (var i = 0, len = selected.length; i < len; i++) { - files += '
  • ' + '' + selected[i].substr(selected[i].lastIndexOf('/') + 1) + '
  • '; - } - files_ct.data('files', selected).html(files).removeClass('hide'); - $('.rm', files_ct).click(function() { - var selected_f = files_ct.data('files'); - selected_f.splice($(this).data('index'), 1); - $(this).parent().remove(); - files_ct.data('files', selected_f); - }); -}); -