diff --git a/group/templates/group/group_info.html b/group/templates/group/group_info.html index 70dc04ce84..2729ad720d 100644 --- a/group/templates/group/group_info.html +++ b/group/templates/group/group_info.html @@ -6,9 +6,11 @@ {% block main_panel %} {% if messages %} + {% endif %}

{{ group.group_name }}

@@ -116,19 +118,9 @@ {% endif %} {{ msg.message|linebreaksbr|seahub_urlize|find_at }}

- {% if msg.reply_cnt == 0 %} - 回复 - {% else %} - {{ msg.reply_cnt }} 回复 - {% endif %} - 收起回复 -
-
- - - -

输入不能为空且应少于150个字符。

-
+ + +
@@ -258,7 +250,14 @@ $('#user-profile').hover( $(this).addClass('hide'); } ); - +$('.reply, .replyclose').hover( + function() { + $(this).css('color', '#f93'); + }, + function() { + $(this).css('color', '#080'); + } +); $('.reply').click(function() { var msg_id = $(this).attr('data'), msg_bd = $(this).parent(); @@ -268,59 +267,46 @@ $('.reply').click(function() { cache: false, contentType: 'application/json; charset=utf-8', success: function(data) { - msg_bd.children('.reply-list').html(data['html']).removeClass('hide'); - } - }); - msg_bd.children('.reply-form').removeClass('hide'); - $(this).addClass('hide'); - msg_bd.children('.replyclose').removeClass('hide'); - return false; -}); - -function reply_at(nickname, msgID) { - var form_selector = '#form'+msgID+' .text-input'; - $(form_selector).focus(); - $(form_selector).val(nickname); - return false; -} - -$('.replyclose').click(function() { - var msg_bd = $(this).parent(); - msg_bd.children('.reply-list').addClass('hide'); - msg_bd.children('.reply-form').addClass('hide'); - $(this).addClass('hide'); - msg_bd.children('.reply').removeClass('hide'); - return false; -}); - -$('.reply-form').each(function(){ - $(this).submit(function(event) { - var form = $(this), - m_id = form.children('input[name="msg_id"]').val(), - m = $.trim(form.children('input[name="message"]').val()), - msg_bd = form.parent(); - if (m && m.length <= 150) { - $.ajax({ - type: "POST", - url: '{{ SITE_ROOT }}group/reply/' + m_id + '/', - dataType: 'json', - cache: false, - contentType: 'application/json; charset=utf-8', - beforeSend: prepareCSRFToken, - data: "message="+m, - success: function(data) { - msg_bd.children('.reply-list').html(data['html']).attr('class', 'reply-list'); - form.children('input[name="message"]').val(''); - form.children('.error').attr('Class' , 'error hide'); - msg_bd.children('.reply').html(data['reply_cnt'] + ' 回复'); + msg_bd.children('.reply-bd').html(data['html']).attr('class', 'reply-bd'); + msg_bd.find('.reply-at').click(function() { + msg_bd.find('.reply-input').val('@' + $(this).attr('data') + ' ').focus(); + }); + msg_bd.find('.submit').click(function() { + var reply = $.trim(msg_bd.find('.reply-input').val()); + if (reply && reply.length <= 150) { + $.ajax({ + type: "POST", + url: '{{ SITE_ROOT }}group/reply/' + msg_id + '/', + dataType: 'json', + cache: false, + contentType: 'application/json; charset=utf-8', + beforeSend: prepareCSRFToken, + data: "message=" + reply, + success: function(data) { + msg_bd.find('.reply-list').append(data['html']); + msg_bd.find('.reply-input').val(''); + msg_bd.find('.error').attr('class', 'error hide'); + var reply_cnt = parseInt(msg_bd.find('.reply-cnt').html()) + 1 || 1; + msg_bd.find('.reply-cnt').html(reply_cnt + ' '); + msg_bd.find('.reply-at').click(function() { + msg_bd.find('.reply-input').val('@' + $(this).attr('data') + ' ').focus(); + }); + } + }); + } else { + msg_bd.find('.error').removeClass('hide'); } }); - } else { - form.children('.error').removeClass('hide'); } - return false; }); + $(this).addClass('hide'); + $(this).next().removeClass('hide'); // show 'replyclose' }); +$('.replyclose').click(function() { + $(this).parent().children('.reply-bd').addClass('hide'); + $(this).addClass('hide'); + $(this).prev().removeClass('hide'); // show 'reply' +}); {% endblock %} diff --git a/group/templates/group/group_reply_list.html b/group/templates/group/group_reply_list.html index 670034f828..415eb46be7 100644 --- a/group/templates/group/group_reply_list.html +++ b/group/templates/group/group_reply_list.html @@ -1,13 +1,30 @@ {% load seahub_tags avatar_tags %} -