1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-10-22 11:43:33 +00:00

Merge branch 'lj_reply'

This commit is contained in:
llj
2012-09-01 14:44:17 +08:00
3 changed files with 57 additions and 47 deletions

View File

@@ -200,11 +200,10 @@ addConfirmTo($('#quit-group'), '确定要退出?');
addConfirmTo($('.cancel-share'), '确定要取消共享该目录?');
$(function() {
var member_list = [];
var member_list = [], nickname, pinyin;
{% for member in members %}
var nickname = "{{ member.user_name|email2nickname }}";
var pinyin = "{{ member.user_name|email2nickname|char2pinyin }}";
nickname = '{{ member.user_name|email2nickname }}';
pinyin = '{{ member.user_name|email2nickname|char2pinyin }}';
member_list.push({value:nickname + pinyin, label:nickname});
{% endfor %}
addAtAutocomplete('#message', '#group-message-form', member_list, {'border':'1px solid #ddd', 'width':'600px', 'height': '80px', 'word-wrap':'break-word', 'overflow-y':'auto', 'line-height': '1.5em'}); // remember to add unit (px or em) to line-height, as js in ie will take 1.5 as 1.5, not 1.5em

View File

@@ -7,24 +7,23 @@ $('.reply, .replyclose').hover(
}
);
$('.reply').click(function() {
var msg_id = $(this).attr('data'),
var myself = $(this),
msg_id = $(this).attr('data'),
msg_bd = $(this).parent(),
reply_cnt = msg_bd.find('.reply-cnt');
$.ajax({
url: '{{ SITE_ROOT }}group/reply/' + msg_id + '/',
dataType: 'json',
cache: false,
contentType: 'application/json; charset=utf-8',
success: function(data) {
msg_bd.children('.reply-bd').html(data['html']).attr('class', 'reply-bd');
reply_cnt = msg_bd.find('.reply-cnt'),
reply_bd = msg_bd.children('.reply-bd');
function afterBdShow() {
myself.addClass('hide');
myself.next().removeClass('hide'); // show 'replyclose'
var reply_input = msg_bd.find('.reply-input'),
error = msg_bd.find('.error');
function handleReplyInput() {
function replyatHandler() {
reply_input.val('@' + $(this).attr('data') + ' ');
var pos = reply_input.val().length;
setSelectionRange(reply_input[0], pos, pos);
}
msg_bd.find('.reply-at').click(handleReplyInput);
msg_bd.find('.reply-at').click(replyatHandler);
msg_bd.find('.submit').click(function() {
var reply = $.trim(reply_input.val());
if (reply && reply.length <= 150) {
@@ -41,7 +40,7 @@ $('.reply').click(function() {
reply_input.val('');
error.attr('class', 'error hide');
reply_cnt.html((parseInt(reply_cnt.html()) + 1 || 1) + ' ');
msg_bd.find('.reply-at').click(handleReplyInput);
msg_bd.find('.reply-at').click(replyatHandler);
}
});
} else {
@@ -49,9 +48,21 @@ $('.reply').click(function() {
}
});
}
if ($.trim(reply_cnt.html()) == '') {
reply_bd.html('<ul class="reply-list"></ul><textarea name="message" class="reply-input"></textarea> <button class="submit">回复</button><p class="error hide">输入不能为空且应少于150个字符。</p>').attr('class', 'reply-bd');
afterBdShow();
} else {
reply_bd.html('<img src="{{MEDIA_URL}}img/loading-icon.gif" alt="加载中..." />');
$.ajax({
url: '{{ SITE_ROOT }}group/reply/' + msg_id + '/',
dataType: 'json',
success: function(data) {
reply_bd.html(data['html']).attr('class', 'reply-bd');
afterBdShow();
}
});
$(this).addClass('hide');
$(this).next().removeClass('hide'); // show 'replyclose'
}
});
$('.replyclose').click(function() {

BIN
media/img/loading-icon.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB