1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-12 13:24:52 +00:00

Added at complete in file commet

This commit is contained in:
zhengxie
2012-10-20 19:43:56 +08:00
parent e8ef6b8b1d
commit 56ea2dbd66
4 changed files with 38 additions and 16 deletions

View File

@@ -943,23 +943,35 @@ def attention(request):
if not request.is_ajax():
raise Http404
try:
gid = int(request.GET.get('gid', ''))
except ValueError:
raise Http404
name_str = request.GET.get('name_startsWith')
user = request.user.username
if not is_group_user(gid, user):
raise Http404
name_str = request.GET.get('name_startsWith')
gids = request.GET.get('gids', '')
result = []
# Get all group users
members = get_group_members(gid)
members = []
for gid in gids.split(','):
try:
gid = int(gid)
except ValueError:
continue
if not is_group_user(gid, user):
continue
# Get all group users
members += get_group_members(gid)
member_names = []
for m in members:
if m.user_name == user:
continue
if m.user_name in member_names:
# Remove duplicated member names
continue
else:
member_names.append(m.user_name)
from base.templatetags.seahub_tags import email2nickname, char2pinyin
nickname = email2nickname(m.user_name)
pinyin = char2pinyin(nickname)

View File

@@ -1160,7 +1160,8 @@ ul.with-bg li {
border:none;
}
.msg-bd .recommend,
.msg-bd .at {
.msg-bd .at,
.comment-bd .at {
color:#808;
}
.reply-list {

View File

@@ -81,7 +81,7 @@ function addAutocomplete(ele_id, container_id, data) {
* @param ele_css: {'xx':'xxx'}, styles to be applied to ele_cp
* @param container_id: id of autocomplete's container, often container of element above
*/
function addAtAutocomplete(ele_id, container_id, gid, aj_url, ele_css) {
function addAtAutocomplete(ele_id, container_id, gids, aj_url, ele_css) {
var pos = ''; // cursor position
var cursor_at_end; // Boolean. if cursor at the end or in the middle.
var end_str = ''; // str after '@' when '@' is inserted into the middle of the ele's value
@@ -152,7 +152,7 @@ function addAtAutocomplete(ele_id, container_id, gid, aj_url, ele_css) {
url: aj_url,
dataType: "json",
data: {
gid: gid,
gids: gids,
name_startsWith: request_term
},
success: function(data) {

View File

@@ -160,7 +160,7 @@
<form id="file-comment-form" action="" method="post">
<div class="w100 ovhd">
<a class="pic fleft" href="{% url 'user_profile' request.user.username %}">{% avatar request.user.username 48 %}</a>
<div class="txt fright">
<div id="comment-container" class="txt fright">
<textarea name="message" id="comment-input">评论一下~</textarea><br />
<p class="error hide"></p>
<input type="submit" value="提交" class="submit hide" />
@@ -201,6 +201,15 @@ $('#view-original, #download').click(function() {
window.open($(this).attr('data'));
});
{% if not view_history %}
$(function() {
var gids = '';
{% for g in groups %}
gids = gids + '{{ g.id }}' + ',';
{% endfor %}
addAtAutocomplete('#comment-input', '#comment-container', gids, "{% url 'group_attention' %}", {'width':'315px','max-width':'315px','padding-left':'1px','height':'36px','margin':'0','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
});
$('#edit, #update').click(function() {
location.href = $(this).attr('data');
});