MDL-64819 output: Activity menu icons

Remove duplicate alt text from activity menu icons and the links to add new sections.
This commit is contained in:
Damyon Wiese 2019-02-11 09:34:18 +08:00 committed by Sara Arjona
parent f9e436a2b6
commit cce54c4732
6 changed files with 39 additions and 51 deletions

File diff suppressed because one or more lines are too long

View file

@ -341,30 +341,21 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* @param {String} image new image name ("i/show", "i/hide", etc.) * @param {String} image new image name ("i/show", "i/hide", etc.)
* @param {String} stringname new string for the action menu item * @param {String} stringname new string for the action menu item
* @param {String} stringcomponent * @param {String} stringcomponent
* @param {String} titlestr string for "title" attribute (if different from stringname) * @param {String} titlestr not used
* @param {String} titlecomponent * @param {String} titlecomponent not used
* @param {String} newaction new value for data-action attribute of the link * @param {String} newaction new value for data-action attribute of the link
* @return {Promise} promise which is resolved when the replacement has completed * @return {Promise} promise which is resolved when the replacement has completed
*/ */
var replaceActionItem = function(actionitem, image, stringname, var replaceActionItem = function(actionitem, image, stringname,
stringcomponent, titlestr, titlecomponent, newaction) { stringcomponent, titlestr, titlecomponent, newaction) {
var stringRequests = [{key: stringname, component: stringcomponent}]; var stringRequests = [{key: stringname, component: stringcomponent}];
if (titlestr) { // Do not provide an icon with duplicate, different text to the menu item.
stringRequests.push({key: titlestr, component: titlecomponent});
}
return str.get_strings(stringRequests).then(function(strings) { return str.get_strings(stringRequests).then(function(strings) {
actionitem.find('span.menu-action-text').html(strings[0]); actionitem.find('span.menu-action-text').html(strings[0]);
actionitem.attr('title', strings[0]);
var title = ''; return templates.renderPix(image, 'core');
if (titlestr) {
title = strings[1];
actionitem.attr('title', title);
}
return templates.renderPix(image, 'core', title);
}).then(function(pixhtml) { }).then(function(pixhtml) {
actionitem.find('.icon').replaceWith(pixhtml); actionitem.find('.icon').replaceWith(pixhtml);
actionitem.attr('data-action', newaction); actionitem.attr('data-action', newaction);

View file

@ -117,10 +117,9 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$name = empty($value['name']) ? '' : $value['name']; $name = empty($value['name']) ? '' : $value['name'];
$attr = empty($value['attr']) ? array() : $value['attr']; $attr = empty($value['attr']) ? array() : $value['attr'];
$class = empty($value['pixattr']['class']) ? '' : $value['pixattr']['class']; $class = empty($value['pixattr']['class']) ? '' : $value['pixattr']['class'];
$alt = empty($value['pixattr']['alt']) ? '' : $value['pixattr']['alt'];
$al = new action_menu_link_secondary( $al = new action_menu_link_secondary(
new moodle_url($url), new moodle_url($url),
new pix_icon($icon, $alt, null, array('class' => "smallicon " . $class)), new pix_icon($icon, '', null, array('class' => "smallicon " . $class)),
$name, $name,
$attr $attr
); );
@ -328,8 +327,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
'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)),
'icon' => 'i/settings', 'icon' => 'i/settings',
'name' => $streditsection, 'name' => $streditsection,
'pixattr' => array('class' => '', 'alt' => $streditsection), 'pixattr' => array('class' => ''),
'attr' => array('class' => 'icon edit', 'title' => $streditsection)); 'attr' => array('class' => 'icon edit'));
} }
if ($section->section) { if ($section->section) {
@ -343,8 +342,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
'url' => $url, 'url' => $url,
'icon' => 'i/hide', 'icon' => 'i/hide',
'name' => $strhidefromothers, 'name' => $strhidefromothers,
'pixattr' => array('class' => '', 'alt' => $strhidefromothers), 'pixattr' => array('class' => ''),
'attr' => array('class' => 'icon editing_showhide', 'title' => $strhidefromothers, 'attr' => array('class' => 'icon editing_showhide',
'data-sectionreturn' => $sectionreturn, 'data-action' => 'hide')); 'data-sectionreturn' => $sectionreturn, 'data-action' => 'hide'));
} else { } else {
$strshowfromothers = get_string('showfromothers', 'format_'.$course->format); $strshowfromothers = get_string('showfromothers', 'format_'.$course->format);
@ -353,8 +352,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
'url' => $url, 'url' => $url,
'icon' => 'i/show', 'icon' => 'i/show',
'name' => $strshowfromothers, 'name' => $strshowfromothers,
'pixattr' => array('class' => '', 'alt' => $strshowfromothers), 'pixattr' => array('class' => ''),
'attr' => array('class' => 'icon editing_showhide', 'title' => $strshowfromothers, 'attr' => array('class' => 'icon editing_showhide',
'data-sectionreturn' => $sectionreturn, 'data-action' => 'show')); 'data-sectionreturn' => $sectionreturn, 'data-action' => 'show'));
} }
} }
@ -370,8 +369,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
'url' => $url, 'url' => $url,
'icon' => 'i/up', 'icon' => 'i/up',
'name' => $strmoveup, 'name' => $strmoveup,
'pixattr' => array('class' => '', 'alt' => $strmoveup), 'pixattr' => array('class' => ''),
'attr' => array('class' => 'icon moveup', 'title' => $strmoveup)); 'attr' => array('class' => 'icon moveup'));
} }
$url = clone($baseurl); $url = clone($baseurl);
@ -383,8 +382,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
'url' => $url, 'url' => $url,
'icon' => 'i/down', 'icon' => 'i/down',
'name' => $strmovedown, 'name' => $strmovedown,
'pixattr' => array('class' => '', 'alt' => $strmovedown), 'pixattr' => array('class' => ''),
'attr' => array('class' => 'icon movedown', 'title' => $strmovedown)); 'attr' => array('class' => 'icon movedown'));
} }
} }
} }
@ -405,8 +404,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
'url' => $url, 'url' => $url,
'icon' => 'i/delete', 'icon' => 'i/delete',
'name' => $strdelete, 'name' => $strdelete,
'pixattr' => array('class' => '', 'alt' => $strdelete), 'pixattr' => array('class' => ''),
'attr' => array('class' => 'icon editing_delete', 'title' => $strdelete)); 'attr' => array('class' => 'icon editing_delete'));
} }
} }
@ -1009,7 +1008,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
if ($sectionreturn !== null) { if ($sectionreturn !== null) {
$url->param('sectionreturn', $sectionreturn); $url->param('sectionreturn', $sectionreturn);
} }
$icon = $this->output->pix_icon('t/add', $straddsections); $icon = $this->output->pix_icon('t/add', '');
$newsections = $maxsections - $lastsection; $newsections = $maxsections - $lastsection;
echo html_writer::link($url, $icon . $straddsections, echo html_writer::link($url, $icon . $straddsections,
array('class' => 'add-sections', 'data-add-sections' => $straddsections, 'new-sections' => $newsections)); array('class' => 'add-sections', 'data-add-sections' => $straddsections, 'new-sections' => $newsections));

View file

@ -123,21 +123,19 @@ class format_topics_renderer extends format_section_renderer_base {
if ($section->section && has_capability('moodle/course:setcurrentsection', $coursecontext)) { if ($section->section && has_capability('moodle/course:setcurrentsection', $coursecontext)) {
if ($course->marker == $section->section) { // Show the "light globe" on/off. if ($course->marker == $section->section) { // Show the "light globe" on/off.
$url->param('marker', 0); $url->param('marker', 0);
$markedthistopic = get_string('markedthistopic');
$highlightoff = get_string('highlightoff'); $highlightoff = get_string('highlightoff');
$controls['highlight'] = array('url' => $url, "icon" => 'i/marked', $controls['highlight'] = array('url' => $url, "icon" => 'i/marked',
'name' => $highlightoff, 'name' => $highlightoff,
'pixattr' => array('class' => '', 'alt' => $markedthistopic), 'pixattr' => array('class' => ''),
'attr' => array('class' => 'editing_highlight', 'title' => $markedthistopic, 'attr' => array('class' => 'editing_highlight',
'data-action' => 'removemarker')); 'data-action' => 'removemarker'));
} else { } else {
$url->param('marker', $section->section); $url->param('marker', $section->section);
$markthistopic = get_string('markthistopic');
$highlight = get_string('highlight'); $highlight = get_string('highlight');
$controls['highlight'] = array('url' => $url, "icon" => 'i/marker', $controls['highlight'] = array('url' => $url, "icon" => 'i/marker',
'name' => $highlight, 'name' => $highlight,
'pixattr' => array('class' => '', 'alt' => $markthistopic), 'pixattr' => array('class' => ''),
'attr' => array('class' => 'editing_highlight', 'title' => $markthistopic, 'attr' => array('class' => 'editing_highlight',
'data-action' => 'setmarker')); 'data-action' => 'setmarker'));
} }
} }

View file

@ -1891,7 +1891,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
if ($hasmanageactivities) { if ($hasmanageactivities) {
$actions['update'] = new action_menu_link_secondary( $actions['update'] = new action_menu_link_secondary(
new moodle_url($baseurl, array('update' => $mod->id)), new moodle_url($baseurl, array('update' => $mod->id)),
new pix_icon('t/edit', $str->editsettings, 'moodle', array('class' => 'iconsmall', 'title' => '')), new pix_icon('t/edit', '', 'moodle', array('class' => 'iconsmall')),
$str->editsettings, $str->editsettings,
array('class' => 'editing_update', 'data-action' => 'update') array('class' => 'editing_update', 'data-action' => 'update')
); );
@ -1917,7 +1917,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
} }
$actions['moveright'] = new action_menu_link_secondary( $actions['moveright'] = new action_menu_link_secondary(
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', 'title' => '')), new pix_icon($rightarrow, '', 'moodle', array('class' => 'iconsmall')),
$str->moveright, $str->moveright,
array('class' => 'editing_moveright ' . $enabledclass, 'data-action' => 'moveright', array('class' => 'editing_moveright ' . $enabledclass, 'data-action' => 'moveright',
'data-keepopen' => true, 'data-sectionreturn' => $sr) 'data-keepopen' => true, 'data-sectionreturn' => $sr)
@ -1930,7 +1930,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
} }
$actions['moveleft'] = new action_menu_link_secondary( $actions['moveleft'] = new action_menu_link_secondary(
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', 'title' => '')), new pix_icon($leftarrow, '', 'moodle', array('class' => 'iconsmall')),
$str->moveleft, $str->moveleft,
array('class' => 'editing_moveleft ' . $enabledclass, 'data-action' => 'moveleft', array('class' => 'editing_moveleft ' . $enabledclass, 'data-action' => 'moveleft',
'data-keepopen' => true, 'data-sectionreturn' => $sr) 'data-keepopen' => true, 'data-sectionreturn' => $sr)
@ -1953,7 +1953,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
if ($displayedoncoursepage) { if ($displayedoncoursepage) {
$actions['hide'] = new action_menu_link_secondary( $actions['hide'] = new action_menu_link_secondary(
new moodle_url($baseurl, array('hide' => $mod->id)), new moodle_url($baseurl, array('hide' => $mod->id)),
new pix_icon('t/hide', $str->modhide, 'moodle', array('class' => 'iconsmall', 'title' => '')), new pix_icon('t/hide', '', 'moodle', array('class' => 'iconsmall')),
$str->modhide, $str->modhide,
array('class' => 'editing_hide', 'data-action' => 'hide') array('class' => 'editing_hide', 'data-action' => 'hide')
); );
@ -1961,7 +1961,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
// Offer to "show" only if the section is visible. // Offer to "show" only if the section is visible.
$actions['show'] = new action_menu_link_secondary( $actions['show'] = new action_menu_link_secondary(
new moodle_url($baseurl, array('show' => $mod->id)), new moodle_url($baseurl, array('show' => $mod->id)),
new pix_icon('t/show', $str->modshow, 'moodle', array('class' => 'iconsmall', 'title' => '')), new pix_icon('t/show', '', 'moodle', array('class' => 'iconsmall')),
$str->modshow, $str->modshow,
array('class' => 'editing_show', 'data-action' => 'show') array('class' => 'editing_show', 'data-action' => 'show')
); );
@ -1971,7 +1971,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
// When making the "stealth" module unavailable we perform the same action as hiding the visible module. // When making the "stealth" module unavailable we perform the same action as hiding the visible module.
$actions['hide'] = new action_menu_link_secondary( $actions['hide'] = new action_menu_link_secondary(
new moodle_url($baseurl, array('hide' => $mod->id)), new moodle_url($baseurl, array('hide' => $mod->id)),
new pix_icon('t/unblock', $str->makeunavailable, 'moodle', array('class' => 'iconsmall', 'title' => '')), new pix_icon('t/unblock', '', 'moodle', array('class' => 'iconsmall')),
$str->makeunavailable, $str->makeunavailable,
array('class' => 'editing_makeunavailable', 'data-action' => 'hide', 'data-sectionreturn' => $sr) array('class' => 'editing_makeunavailable', 'data-action' => 'hide', 'data-sectionreturn' => $sr)
); );
@ -1982,7 +1982,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
$action = $sectionvisible ? 'stealth' : 'show'; $action = $sectionvisible ? 'stealth' : 'show';
$actions[$action] = new action_menu_link_secondary( $actions[$action] = new action_menu_link_secondary(
new moodle_url($baseurl, array($action => $mod->id)), new moodle_url($baseurl, array($action => $mod->id)),
new pix_icon('t/block', $str->makeavailable, 'moodle', array('class' => 'iconsmall', 'title' => '')), new pix_icon('t/block', '', 'moodle', array('class' => 'iconsmall')),
$str->makeavailable, $str->makeavailable,
array('class' => 'editing_makeavailable', 'data-action' => $action, 'data-sectionreturn' => $sr) array('class' => 'editing_makeavailable', 'data-action' => $action, 'data-sectionreturn' => $sr)
); );
@ -1995,7 +1995,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
course_allowed_module($mod->get_course(), $mod->modname)) { course_allowed_module($mod->get_course(), $mod->modname)) {
$actions['duplicate'] = new action_menu_link_secondary( $actions['duplicate'] = new action_menu_link_secondary(
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', 'title' => '')), new pix_icon('t/copy', '', 'moodle', array('class' => 'iconsmall')),
$str->duplicate, $str->duplicate,
array('class' => 'editing_duplicate', 'data-action' => 'duplicate', 'data-sectionreturn' => $sr) array('class' => 'editing_duplicate', 'data-action' => 'duplicate', 'data-sectionreturn' => $sr)
); );
@ -2026,7 +2026,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
$actions[$actionname] = new action_menu_link_primary( $actions[$actionname] = new action_menu_link_primary(
new moodle_url($baseurl, array('id' => $mod->id, 'groupmode' => $nextgroupmode)), new moodle_url($baseurl, array('id' => $mod->id, 'groupmode' => $nextgroupmode)),
new pix_icon($groupimage, $grouptitle, 'moodle', array('class' => 'iconsmall')), new pix_icon($groupimage, '', 'moodle', array('class' => 'iconsmall')),
$grouptitle, $grouptitle,
array('class' => 'editing_'. $actionname, 'data-action' => $nextactionname, array('class' => 'editing_'. $actionname, 'data-action' => $nextactionname,
'aria-live' => 'assertive', 'data-sectionreturn' => $sr) 'aria-live' => 'assertive', 'data-sectionreturn' => $sr)
@ -2040,7 +2040,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
if (has_capability('moodle/role:assign', $modcontext)){ if (has_capability('moodle/role:assign', $modcontext)){
$actions['assign'] = new action_menu_link_secondary( $actions['assign'] = new action_menu_link_secondary(
new moodle_url('/admin/roles/assign.php', array('contextid' => $modcontext->id)), new moodle_url('/admin/roles/assign.php', array('contextid' => $modcontext->id)),
new pix_icon('t/assignroles', $str->assign, 'moodle', array('class' => 'iconsmall', 'title' => '')), new pix_icon('t/assignroles', '', 'moodle', array('class' => 'iconsmall')),
$str->assign, $str->assign,
array('class' => 'editing_assign', 'data-action' => 'assignroles', 'data-sectionreturn' => $sr) array('class' => 'editing_assign', 'data-action' => 'assignroles', 'data-sectionreturn' => $sr)
); );
@ -2050,7 +2050,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
if ($hasmanageactivities) { if ($hasmanageactivities) {
$actions['delete'] = new action_menu_link_secondary( $actions['delete'] = new action_menu_link_secondary(
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', 'title' => '')), new pix_icon('t/delete', '', 'moodle', array('class' => 'iconsmall')),
$str->delete, $str->delete,
array('class' => 'editing_delete', 'data-action' => 'delete', 'data-sectionreturn' => $sr) array('class' => 'editing_delete', 'data-action' => 'delete', 'data-sectionreturn' => $sr)
); );

View file

@ -306,7 +306,7 @@ class behat_course extends behat_base {
// Click on highlight topic link. // Click on highlight topic link.
$this->execute('behat_general::i_click_on_in_the', $this->execute('behat_general::i_click_on_in_the',
array(get_string('markthistopic'), "link", $this->escape($xpath), "xpath_element") array(get_string('highlight'), "link", $this->escape($xpath), "xpath_element")
); );
} }
@ -328,7 +328,7 @@ class behat_course extends behat_base {
// Click on un-highlight topic link. // Click on un-highlight topic link.
$this->execute('behat_general::i_click_on_in_the', $this->execute('behat_general::i_click_on_in_the',
array(get_string('markedthistopic'), "link", $this->escape($xpath), "xpath_element") array(get_string('highlightoff'), "link", $this->escape($xpath), "xpath_element")
); );
} }
@ -446,7 +446,7 @@ class behat_course extends behat_base {
$xpath = $this->section_exists($sectionnumber); $xpath = $this->section_exists($sectionnumber);
// The important checking, we can not check the img. // The important checking, we can not check the img.
$this->execute('behat_general::should_exist_in_the', ['This topic is highlighted as the current topic', 'icon', $xpath, 'xpath_element']); $this->execute('behat_general::should_exist_in_the', ['Remove highlight', 'link', $xpath, 'xpath_element']);
} }
/** /**
@ -1186,7 +1186,7 @@ class behat_course extends behat_base {
// Checking the show button alt text and show icon. // Checking the show button alt text and show icon.
$showtext = get_string('showfromothers', $courseformat); $showtext = get_string('showfromothers', $courseformat);
$linkxpath = $xpath . "/descendant::a[@title=" . behat_context_helper::escape($showtext) . "]"; $linkxpath = $xpath . "//a[*[contains(text(), " . behat_context_helper::escape($showtext) . ")]]";
$exception = new ElementNotFoundException($this->getSession(), 'Show section link'); $exception = new ElementNotFoundException($this->getSession(), 'Show section link');