From dfbdf40af9f56a38e5f2df5ac34016e397092f97 Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Fri, 10 Feb 2017 14:06:23 +0800 Subject: [PATCH] MDL-35980 comment: add comment info to delete button for screen readers For each delete button in the comments widget, make the spoken text a string containing the name of the poster and the datetime. --- admin/tool/lp/templates/comment_area.mustache | 2 +- comment/comment.js | 12 +++++++++++- comment/lib.php | 2 +- lang/en/moodle.php | 1 + lib/outputrequirementslib.php | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/admin/tool/lp/templates/comment_area.mustache b/admin/tool/lp/templates/comment_area.mustache index a93697a6f69..19f8fdb3a65 100644 --- a/admin/tool/lp/templates/comment_area.mustache +++ b/admin/tool/lp/templates/comment_area.mustache @@ -93,7 +93,7 @@ require(['core/str'], function(Str) { { key: 'comments', component: 'moodle' }, { key: 'commentscount', component: 'moodle' }, { key: 'commentsrequirelogin', component: 'moodle' }, - { key: 'deletecomment', component: 'moodle' }, + { key: 'deletecommentbyon', component: 'moodle' }, ]).then(function() { // Kick off when strings are loaded. Y.use('core_comment', function(Y) { diff --git a/comment/comment.js b/comment/comment.js index bdcc7bc9236..d93a357245a 100644 --- a/comment/comment.js +++ b/comment/comment.js @@ -192,7 +192,17 @@ M.core_comment = { val = val.replace('___name___', list[i].fullname); } if (list[i]['delete']||newcmt) { - list[i].content = '
' + list[i].content; + var tokens = { + user: list[i].fullname, + time: list[i].time + }; + var deleteStr = Y.Escape.html(M.util.get_string('deletecommentbyon', 'moodle', tokens)); + list[i].content = '
' + + '' + + '' + deleteStr + '' + + '' + + '
' + list[i].content; } val = val.replace('___time___', list[i].time); val = val.replace('___picture___', list[i].avatar); diff --git a/comment/lib.php b/comment/lib.php index 8bc01976e74..1a770f8b450 100644 --- a/comment/lib.php +++ b/comment/lib.php @@ -263,7 +263,7 @@ class comment { 'comments', 'commentscount', 'commentsrequirelogin', - 'deletecomment', + 'deletecommentbyon', ), 'moodle' ); diff --git a/lang/en/moodle.php b/lang/en/moodle.php index d89a33c36b1..c04f627b68e 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -464,6 +464,7 @@ $string['deletecategoryempty'] = 'This category is empty.'; $string['deletecategorycheck'] = 'Are you absolutely sure you want to completely delete this category \'{$a}\'?
This will move all courses into the parent category if there is one, or into Miscellaneous.'; $string['deletecategorycheck2'] = 'If you delete this category, you need to choose what to do with the courses and subcategories it contains.'; $string['deletecomment'] = 'Delete this comment'; +$string['deletecommentbyon'] = 'Delete comment posted by {$a->user} on {$a->time}'; $string['deletecompletely'] = 'Delete completely'; $string['deletecourse'] = 'Delete a course'; $string['deletecoursecheck'] = 'Are you absolutely sure you want to completely delete this course and all the data it contains?'; diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index ed868fa1b4b..55287f47740 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -743,7 +743,7 @@ class page_requirements_manager { case 'core_comment': $module = array('name' => 'core_comment', 'fullpath' => '/comment/comment.js', - 'requires' => array('base', 'io-base', 'node', 'json', 'yui2-animation', 'overlay'), + 'requires' => array('base', 'io-base', 'node', 'json', 'yui2-animation', 'overlay', 'escape'), 'strings' => array(array('confirmdeletecomments', 'admin'), array('yes', 'moodle'), array('no', 'moodle')) ); break;