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.
This commit is contained in:
Jake Dallimore 2017-02-10 14:06:23 +08:00
parent 0f59b6dd75
commit 86f1d1bb86
5 changed files with 15 additions and 4 deletions

View File

@ -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) {

View File

@ -192,7 +192,17 @@ 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.util.get_string('deletecomment', 'moodle')+'"><img alt="" src="'+M.util.image_url('t/delete', 'core')+'" /></a></div>' + 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 = '<div class="comment-delete">' +
'<a href="#" role="button" id ="comment-delete-' + this.client_id + '-' + list[i].id + '"' +
' title="' + deleteStr + '">' +
'<img alt="' + deleteStr + '" 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);

View File

@ -263,7 +263,7 @@ class comment {
'comments',
'commentscount',
'commentsrequirelogin',
'deletecomment',
'deletecommentbyon',
),
'moodle'
);

View File

@ -466,6 +466,7 @@ $string['deletecategoryempty'] = 'This category is empty.';
$string['deletecategorycheck'] = 'Are you absolutely sure you want to completely delete this category <b>\'{$a}\'</b>?<br />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?';

View File

@ -747,7 +747,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;