MDL-31976 Accessbility: Action icons on course page do not need title attributes

This commit is contained in:
Frederic Massart 2012-09-11 14:53:15 +08:00
parent a3ab18c735
commit aad982aa24
5 changed files with 22 additions and 27 deletions

View file

@ -168,7 +168,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $context)) { if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $context)) {
$url = new moodle_url('/course/editsection.php', array('id'=>$section->id, 'sr'=>$sectionreturn)); $url = new moodle_url('/course/editsection.php', array('id'=>$section->id, 'sr'=>$sectionreturn));
$o.= html_writer::link($url, $o.= html_writer::link($url,
html_writer::empty_tag('img', array('src' => $this->output->pix_url('t/edit'), 'class' => 'iconsmall edit')), html_writer::empty_tag('img', array('src' => $this->output->pix_url('t/edit'),
'class' => 'iconsmall edit', 'alt' => get_string('editsummary'))),
array('title' => get_string('editsummary'))); array('title' => get_string('editsummary')));
} }
$o.= html_writer::end_tag('div'); $o.= html_writer::end_tag('div');

View file

@ -1576,8 +1576,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
// Display link itself // Display link itself
echo '<a ' . $linkcss . $mod->extra . $onclick . echo '<a ' . $linkcss . $mod->extra . $onclick .
' href="' . $url . '"><img src="' . $mod->get_icon_url() . ' href="' . $url . '"><img src="' . $mod->get_icon_url() .
'" class="activityicon" alt="' . '" class="activityicon" alt="" /> ' .
$modulename . '" /> ' .
$accesstext . '<span class="instancename">' . $accesstext . '<span class="instancename">' .
$instancename . $altname . '</span></a>'; $instancename . $altname . '</span></a>';
@ -1612,9 +1611,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
// Display greyed-out text of link // Display greyed-out text of link
echo '<div ' . $textcss . $mod->extra . echo '<div ' . $textcss . $mod->extra .
' >' . '<img src="' . $mod->get_icon_url() . ' >' . '<img src="' . $mod->get_icon_url() .
'" class="activityicon" alt="' . '" class="activityicon" alt="" /> <span>'. $instancename . $altname .
$modulename .
'" /> <span>'. $instancename . $altname .
'</span></div>'; '</span></div>';
// Do not display content after link when it is greyed out like this. // Do not display content after link when it is greyed out like this.
@ -3206,7 +3203,7 @@ function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $movesele
if ($mod->modname !== 'label' && $hasmanageactivities && course_ajax_enabled($COURSE)) { if ($mod->modname !== 'label' && $hasmanageactivities && course_ajax_enabled($COURSE)) {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('update' => $mod->id)), new moodle_url($baseurl, array('update' => $mod->id)),
new pix_icon('t/editstring', $str->edittitle, 'moodle', array('class' => 'iconsmall visibleifjs')), new pix_icon('t/editstring', $str->edittitle, 'moodle', array('class' => 'iconsmall visibleifjs', 'title' => '')),
null, null,
array('class' => 'editing_title', 'title' => $str->edittitle) array('class' => 'editing_title', 'title' => $str->edittitle)
); );
@ -3225,7 +3222,7 @@ function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $movesele
if ($indent > 0) { if ($indent > 0) {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('id' => $mod->id, 'indent' => '-1')), new moodle_url($baseurl, array('id' => $mod->id, 'indent' => '-1')),
new pix_icon($leftarrow, $str->moveleft, 'moodle', array('class' => 'iconsmall')), new pix_icon($leftarrow, $str->moveleft, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_moveleft', 'title' => $str->moveleft) array('class' => 'editing_moveleft', 'title' => $str->moveleft)
); );
@ -3233,7 +3230,7 @@ function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $movesele
if ($indent >= 0) { if ($indent >= 0) {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('id' => $mod->id, 'indent' => '1')), new moodle_url($baseurl, array('id' => $mod->id, 'indent' => '1')),
new pix_icon($rightarrow, $str->moveright, 'moodle', array('class' => 'iconsmall')), new pix_icon($rightarrow, $str->moveright, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_moveright', 'title' => $str->moveright) array('class' => 'editing_moveright', 'title' => $str->moveright)
); );
@ -3245,20 +3242,20 @@ function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $movesele
if ($moveselect) { if ($moveselect) {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('copy' => $mod->id)), new moodle_url($baseurl, array('copy' => $mod->id)),
new pix_icon('t/move', $str->move, 'moodle', array('class' => 'iconsmall')), new pix_icon('t/move', $str->move, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_move', 'title' => $str->move) array('class' => 'editing_move', 'title' => $str->move)
); );
} else { } else {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('id' => $mod->id, 'move' => '-1')), new moodle_url($baseurl, array('id' => $mod->id, 'move' => '-1')),
new pix_icon('t/up', $str->moveup, 'moodle', array('class' => 'iconsmall')), new pix_icon('t/up', $str->moveup, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_moveup', 'title' => $str->moveup) array('class' => 'editing_moveup', 'title' => $str->moveup)
); );
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('id' => $mod->id, 'move' => '1')), new moodle_url($baseurl, array('id' => $mod->id, 'move' => '1')),
new pix_icon('t/down', $str->movedown, 'moodle', array('class' => 'iconsmall')), new pix_icon('t/down', $str->movedown, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_movedown', 'title' => $str->movedown) array('class' => 'editing_movedown', 'title' => $str->movedown)
); );
@ -3269,7 +3266,7 @@ function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $movesele
if ($hasmanageactivities) { if ($hasmanageactivities) {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('update' => $mod->id)), new moodle_url($baseurl, array('update' => $mod->id)),
new pix_icon('t/edit', $str->update, 'moodle', array('class' => 'iconsmall')), new pix_icon('t/edit', $str->update, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_update', 'title' => $str->update) array('class' => 'editing_update', 'title' => $str->update)
); );
@ -3279,7 +3276,7 @@ function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $movesele
if (has_all_capabilities($dupecaps, $coursecontext) && plugin_supports('mod', $mod->modname, FEATURE_BACKUP_MOODLE2)) { if (has_all_capabilities($dupecaps, $coursecontext) && plugin_supports('mod', $mod->modname, FEATURE_BACKUP_MOODLE2)) {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('duplicate' => $mod->id)), new moodle_url($baseurl, array('duplicate' => $mod->id)),
new pix_icon('t/copy', $str->duplicate, 'moodle', array('class' => 'iconsmall')), new pix_icon('t/copy', $str->duplicate, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_duplicate', 'title' => $str->duplicate) array('class' => 'editing_duplicate', 'title' => $str->duplicate)
); );
@ -3289,7 +3286,7 @@ function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $movesele
if ($hasmanageactivities) { if ($hasmanageactivities) {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('delete' => $mod->id)), new moodle_url($baseurl, array('delete' => $mod->id)),
new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall')), new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_delete', 'title' => $str->delete) array('class' => 'editing_delete', 'title' => $str->delete)
); );
@ -3300,14 +3297,14 @@ function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $movesele
if ($mod->visible) { if ($mod->visible) {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('hide' => $mod->id)), new moodle_url($baseurl, array('hide' => $mod->id)),
new pix_icon('t/hide', $str->hide, 'moodle', array('class' => 'iconsmall')), new pix_icon('t/hide', $str->hide, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_hide', 'title' => $str->hide) array('class' => 'editing_hide', 'title' => $str->hide)
); );
} else { } else {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('show' => $mod->id)), new moodle_url($baseurl, array('show' => $mod->id)),
new pix_icon('t/show', $str->show, 'moodle', array('class' => 'iconsmall')), new pix_icon('t/show', $str->show, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_show', 'title' => $str->show) array('class' => 'editing_show', 'title' => $str->show)
); );
@ -3338,7 +3335,7 @@ function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $movesele
if ($mod->groupmodelink) { if ($mod->groupmodelink) {
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url($baseurl, array('id' => $mod->id, 'groupmode' => $groupmode)), new moodle_url($baseurl, array('id' => $mod->id, 'groupmode' => $groupmode)),
new pix_icon($groupimage, $grouptitle, 'moodle', array('class' => 'iconsmall')), new pix_icon($groupimage, $grouptitle, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => $groupclass, 'title' => $grouptitle) array('class' => $groupclass, 'title' => $grouptitle)
); );
@ -3351,7 +3348,7 @@ function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $movesele
if (has_capability('moodle/role:assign', $modcontext)){ if (has_capability('moodle/role:assign', $modcontext)){
$actions[] = new action_link( $actions[] = new action_link(
new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid' => $modcontext->id)), new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid' => $modcontext->id)),
new pix_icon('i/roles', $str->assign, 'moodle', array('class' => 'iconsmall')), new pix_icon('i/roles', $str->assign, 'moodle', array('class' => 'iconsmall', 'title' => '')),
null, null,
array('class' => 'editing_assign', 'title' => $str->assign) array('class' => 'editing_assign', 'title' => $str->assign)
); );

View file

@ -106,7 +106,6 @@ YUI.add('moodle-course-toolboxes', function(Y) {
var newstring = M.util.get_string(status, 'moodle'); var newstring = M.util.get_string(status, 'moodle');
hideicon.setAttrs({ hideicon.setAttrs({
'alt' : newstring, 'alt' : newstring,
'title' : newstring,
'src' : M.util.image_url('t/' + status) 'src' : M.util.image_url('t/' + status)
}); });
button.set('title', newstring); button.set('title', newstring);
@ -446,7 +445,6 @@ YUI.add('moodle-course-toolboxes', function(Y) {
// Change the UI // Change the UI
icon.setAttrs({ icon.setAttrs({
'alt' : newtitle, 'alt' : newtitle,
'title' : newtitle,
'src' : iconsrc 'src' : iconsrc
}); });
button.setAttribute('title', newtitle); button.setAttribute('title', newtitle);
@ -473,7 +471,6 @@ YUI.add('moodle-course-toolboxes', function(Y) {
.addClass(CSS.GENERICICONCLASS) .addClass(CSS.GENERICICONCLASS)
.setAttrs({ .setAttrs({
'src' : M.util.image_url('t/left', 'moodle'), 'src' : M.util.image_url('t/left', 'moodle'),
'title' : left_string,
'alt' : left_string 'alt' : left_string
}); });
var moveright = target.one(CSS.MOVERIGHT); var moveright = target.one(CSS.MOVERIGHT);
@ -682,7 +679,6 @@ YUI.add('moodle-course-toolboxes', function(Y) {
var newstring = M.util.get_string(status + 'fromothers', 'format_' + this.get('format')); var newstring = M.util.get_string(status + 'fromothers', 'format_' + this.get('format'));
hideicon.setAttrs({ hideicon.setAttrs({
'alt' : newstring, 'alt' : newstring,
'title' : newstring,
'src' : M.util.image_url('i/' + status) 'src' : M.util.image_url('i/' + status)
}); });
button.set('title', newstring); button.set('title', newstring);
@ -740,7 +736,6 @@ YUI.add('moodle-course-toolboxes', function(Y) {
.set('title', old_string); .set('title', old_string);
Y.one(CSS.PAGECONTENT) Y.one(CSS.PAGECONTENT)
.all(M.course.format.get_section_selector(Y) + '.current ' + CSS.HIGHLIGHT + ' img') .all(M.course.format.get_section_selector(Y) + '.current ' + CSS.HIGHLIGHT + ' img')
.set('title', old_string)
.set('alt', old_string) .set('alt', old_string)
.set('src', M.util.image_url('i/marker')); .set('src', M.util.image_url('i/marker'));
@ -756,7 +751,6 @@ YUI.add('moodle-course-toolboxes', function(Y) {
button button
.set('title', new_string); .set('title', new_string);
buttonicon buttonicon
.set('title', new_string)
.set('alt', new_string) .set('alt', new_string)
.set('src', M.util.image_url('i/marked')); .set('src', M.util.image_url('i/marked'));
} }

View file

@ -550,6 +550,10 @@ class pix_icon implements renderable {
} }
if (!isset($this->attributes['title'])) { if (!isset($this->attributes['title'])) {
$this->attributes['title'] = $this->attributes['alt']; $this->attributes['title'] = $this->attributes['alt'];
} else if (empty($this->attributes['title'])) {
// Remove the title attribute if empty, we probably want to use the parent node's title
// and some browsers might overwrite it with an empty title.
unset($this->attributes['title']);
} }
} }
} }

View file

@ -36,8 +36,7 @@ YUI.add('moodle-core-dragdrop', function(Y) {
.setStyle('cursor', 'move') .setStyle('cursor', 'move')
.setAttrs({ .setAttrs({
'src' : M.util.image_url(MOVEICON.pix, MOVEICON.component), 'src' : M.util.image_url(MOVEICON.pix, MOVEICON.component),
'alt' : title, 'alt' : title
'title' : M.str.moodle.move
}); });
if (iconclass) { if (iconclass) {
dragicon.addClass(iconclass); dragicon.addClass(iconclass);