mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-23912 core_comment: update count after deletion
This commit is contained in:
parent
27bfd2c4d1
commit
71688853e0
@ -64,7 +64,7 @@ M.core_comment = {
|
||||
var ta = Y.one('#dlg-content-'+this.client_id);
|
||||
var scope = this;
|
||||
var value = ta.get('value');
|
||||
if (value && value != M.str.moodle.addcomment) {
|
||||
if (value && value != M.util.get_string('addcomment', 'moodle')) {
|
||||
var params = {'content': value};
|
||||
this.request({
|
||||
action: 'add',
|
||||
@ -81,9 +81,9 @@ M.core_comment = {
|
||||
var newcomment = Y.Node.create(result.html);
|
||||
container.appendChild(newcomment);
|
||||
var ids = result.ids;
|
||||
var linktext = Y.one('#comment-link-text-'+cid);
|
||||
if (linktext) {
|
||||
linktext.set('innerHTML', M.str.moodle.comments + ' ('+obj.count+')');
|
||||
var linkText = Y.one('#comment-link-text-' + cid);
|
||||
if (linkText) {
|
||||
linkText.set('innerHTML', M.util.get_string('commentscount', 'moodle', obj.count));
|
||||
}
|
||||
for(var i in ids) {
|
||||
var attributes = {
|
||||
@ -178,7 +178,7 @@ M.core_comment = {
|
||||
val = val.replace('___name___', list[i].fullname);
|
||||
}
|
||||
if (list[i]['delete']||newcmt) {
|
||||
list[i].content = '<div class="comment-delete"><a href="#" id ="comment-delete-'+this.client_id+'-'+list[i].id+'" title="'+M.str.moodle.deletecomment+'"><img alt="" src="'+M.util.image_url('t/delete', 'core')+'" /></a></div>' + list[i].content;
|
||||
list[i].content = '<div class="comment-delete"><a href="#" id ="comment-delete-'+this.client_id+'-'+list[i].id+'" title="'+M.util.get_string('deletecomment', 'moodle')+'"><img alt="" src="'+M.util.image_url('t/delete', 'core')+'" /></a></div>' + list[i].content;
|
||||
}
|
||||
val = val.replace('___time___', list[i].time);
|
||||
val = val.replace('___picture___', list[i].avatar);
|
||||
@ -201,9 +201,9 @@ M.core_comment = {
|
||||
scope: scope,
|
||||
params: params,
|
||||
callback: function(id, ret, args) {
|
||||
var linktext = Y.one('#comment-link-text-'+scope.client_id);
|
||||
if (ret.count && linktext) {
|
||||
linktext.set('innerHTML', M.str.moodle.comments + ' ('+ret.count+')');
|
||||
var linkText = Y.one('#comment-link-text-' + scope.client_id);
|
||||
if (ret.count && linkText) {
|
||||
linkText.set('innerHTML', M.util.get_string('commentscount', 'moodle', ret.count));
|
||||
}
|
||||
var container = Y.one('#comment-list-'+scope.client_id);
|
||||
var pagination = Y.one('#comment-pagination-'+scope.client_id);
|
||||
@ -215,7 +215,7 @@ M.core_comment = {
|
||||
}
|
||||
if (ret.error == 'require_login') {
|
||||
var result = {};
|
||||
result.html = M.str.moodle.commentsrequirelogin;
|
||||
result.html = M.util.get_string('commentsrequirelogin', 'moodle');
|
||||
} else {
|
||||
var result = scope.render(ret.list);
|
||||
}
|
||||
@ -231,10 +231,16 @@ M.core_comment = {
|
||||
},
|
||||
|
||||
dodelete: function(id) { // note: delete is a reserved word in javascript, chrome and safary do not like it at all here!
|
||||
var scope = this;
|
||||
var params = {'commentid': id};
|
||||
var scope = this,
|
||||
cid = scope.client_id,
|
||||
params = {'commentid': id};
|
||||
function remove_dom(type, anim, cmt) {
|
||||
cmt.remove();
|
||||
var linkText = Y.one('#comment-link-text-' + cid),
|
||||
comments = Y.all('#comment-list-' + cid + ' li');
|
||||
if (linkText && comments) {
|
||||
linkText.set('innerHTML', M.util.get_string('commentscount', 'moodle', comments.size()));
|
||||
}
|
||||
}
|
||||
this.request({
|
||||
action: 'delete',
|
||||
@ -374,13 +380,13 @@ M.core_comment = {
|
||||
return false;
|
||||
}
|
||||
if (focus) {
|
||||
if (t.get('value') == M.str.moodle.addcomment) {
|
||||
if (t.get('value') == M.util.get_string('addcomment', 'moodle')) {
|
||||
t.set('value', '');
|
||||
t.setStyle('color', 'black');
|
||||
}
|
||||
}else{
|
||||
if (t.get('value') == '') {
|
||||
t.set('value', M.str.moodle.addcomment);
|
||||
t.set('value', M.util.get_string('addcomment', 'moodle'));
|
||||
t.setStyle('color','grey');
|
||||
t.set('rows', 2);
|
||||
}
|
||||
@ -425,7 +431,7 @@ M.core_comment = {
|
||||
return;
|
||||
}
|
||||
var args = {};
|
||||
args.message = M.str.admin.confirmdeletecomments;
|
||||
args.message = M.util.get_string('confirmdeletecomments', 'admin');
|
||||
args.callback = function() {
|
||||
var url = M.cfg.wwwroot + '/comment/index.php';
|
||||
|
||||
|
@ -246,10 +246,15 @@ class comment {
|
||||
self::$comment_page = optional_param('comment_page', '', PARAM_INT);
|
||||
self::$comment_area = optional_param('comment_area', '', PARAM_AREA);
|
||||
|
||||
$page->requires->string_for_js('addcomment', 'moodle');
|
||||
$page->requires->string_for_js('deletecomment', 'moodle');
|
||||
$page->requires->string_for_js('comments', 'moodle');
|
||||
$page->requires->string_for_js('commentsrequirelogin', 'moodle');
|
||||
$page->requires->strings_for_js(array(
|
||||
'addcomment',
|
||||
'comments',
|
||||
'commentscount',
|
||||
'commentsrequirelogin',
|
||||
'deletecomment',
|
||||
),
|
||||
'moodle'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,6 +262,7 @@ $string['collapseall'] = 'Collapse all';
|
||||
$string['collapsecategory'] = 'Collapse {$a}';
|
||||
$string['commentincontext'] = 'Find this comment in context';
|
||||
$string['comments'] = 'Comments';
|
||||
$string['commentscount'] = 'Comments ({$a})';
|
||||
$string['commentsnotenabled'] = 'Comments feature is not enabled';
|
||||
$string['commentsrequirelogin'] = 'You need to login to view the comments';
|
||||
$string['comparelanguage'] = 'Compare and edit current language';
|
||||
|
Loading…
x
Reference in New Issue
Block a user