diff --git a/comment/comment.js b/comment/comment.js index d1cf768a0f330..90c767d2f669e 100644 --- a/comment/comment.js +++ b/comment/comment.js @@ -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 = '
' + list[i].content; + list[i].content = '
' + 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'; diff --git a/comment/lib.php b/comment/lib.php index e7172586f6c15..cea8c66a6d6c6 100644 --- a/comment/lib.php +++ b/comment/lib.php @@ -246,10 +246,15 @@ public static function init(moodle_page $page = null) { 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' + ); } /** diff --git a/lang/en/moodle.php b/lang/en/moodle.php index cbcbbd3a232de..1974d59d810c6 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -262,6 +262,7 @@ $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';