Commit b9b409cf authored by Damyon Wiese's avatar Damyon Wiese
Browse files

MDL-40759 icons: Peer review fixes (all minor)

parent 1caabd84
......@@ -55,7 +55,7 @@
<div class="mdl-left">
{{^notoggle}}
<a href="#" class="comment-link" id="comment-link-{{cid}}">
{{#pix}}{{collapsediconkey}}, {{linktext}}{{/pix}}<span id="comment-link-text-{{cid}}">{{linktext}}
{{#pix}}{{collapsediconkey}}, core, {{linktext}}{{/pix}}<span id="comment-link-text-{{cid}}">{{linktext}}
{{#displaytotalcount}}
({{count}})
{{/displaytotalcount}}</span>
......
......@@ -82,6 +82,6 @@ function tool_usertours_get_fontawesome_icon_map() {
return [
'tool_usertours:t/export' => 'fa-download',
'tool_usertours:i/reload' => 'fa-refresh',
'tool_usertours:filler' => 'fa-spacer',
'tool_usertours:t/filler' => 'fa-spacer',
];
}
......@@ -187,7 +187,7 @@
} else {
$columnicon = ($dir == "ASC") ? "sort_asc" : "sort_desc";
}
$columnicon = $OUTPUT->pix_icon('t/' . $columnicon, '', 'core', ['class' => 'iconsort']);
$columnicon = $OUTPUT->pix_icon('t/' . $columnicon, get_string($columndir), 'core', ['class' => 'iconsort']);
}
$$column = "<a href=\"user.php?sort=$column&amp;dir=$columndir\">".$string[$column]."</a>$columnicon";
......
......@@ -114,10 +114,9 @@ foreach ($columns as $column) {
} else {
$columndir = ($dir == 'asc') ? 'desc' : 'asc';
$icon = 't/down';
$iconstr = 'movedown';
$iconstr = $columndir;
if ($dir != 'asc') {
$icon = 't/up';
$iconstr = 'moveup';
}
$columnicon = ' ' . $OUTPUT->pix_icon($icon, get_string($iconstr));
}
......
......@@ -58,10 +58,9 @@ foreach ($columns as $column) {
} else {
$columndir = $dir == 'asc' ? 'desc' : 'asc';
$icon = 't/down';
$iconstr = 'movedown';
$iconstr = $columndir;
if ($dir != 'asc') {
$icon = 't/up';
$iconstr = 'moveup';
}
$columnicon = ' ' . $OUTPUT->pix_icon($icon, get_string($iconstr));
}
......
......@@ -75,7 +75,8 @@ class block_course_overview_renderer extends plugin_renderer_base {
$moveurl = new moodle_url('/blocks/course_overview/move.php',
array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid));
// Create move icon, so it can be used.
$movetofirsticon = $this->output->pix_icon('movehere', get_string('movetofirst', 'block_course_overview', $courses[$movingcourseid]->fullname));
$name = $courses[$movingcourseid]->fullname;
$movetofirsticon = $this->output->pix_icon('movehere', get_string('movetofirst', 'block_course_overview', $name));
$moveurl = html_writer::link($moveurl, $movetofirsticon);
$html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
}
......
......@@ -339,7 +339,6 @@ M.core_comment = {
Templates.renderPix('t/delete', 'core', M.util.get_string('deletecomment', 'moodle')).then(function(html) {
Y.all('div.comment-delete a').set('innerHTML', html);
}).catch(Notification.exception);
});
},
register_pagination: function() {
......
......@@ -162,7 +162,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
* @return string HTML to output.
*/
protected function section_left_content($section, $course, $onsectionpage) {
$o = $this->output->spacer();
$o = '';
if ($section->section != 0) {
// Only in the non-general sections.
......
......@@ -730,4 +730,3 @@ class enrol_manual_plugin extends enrol_plugin {
}
}
......@@ -123,9 +123,6 @@ class stored_file_exporter extends \core\external\exporter {
'icon' => array(
'type' => PARAM_RAW,
),
'iconurl' => array(
'type' => PARAM_URL,
),
'timecreatedformatted' => array(
'type' => PARAM_RAW
),
......
......@@ -54,7 +54,7 @@ class filter_emoticon_testcase extends advanced_testcase {
$this->assertEquals($expected, $filter->filter('(grr)', $options));
// And texts matching target formats are filtered.
$expected = '<i class="icon fa s/angry fa-fw emoticon" aria-hidden="true" title=""></i><span class="sr-only"></span>';
$expected = '<img class="icon emoticon" alt="angry" title="angry" src="http://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/angry" />';
$options = array('originalformat' => FORMAT_HTML); // Only FORMAT_HTML is filtered, see {@link testable_filter_emoticon}.
$this->assertEquals($expected, $filter->filter('(grr)', $options));
}
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -57,7 +57,7 @@ define(['jquery'], function($) {
* @return {String}
* @method renderIcon
*/
IconSystem.prototype.renderIcon = function(key, component, title, template) { //eslint-disable-line no-unused-vars
IconSystem.prototype.renderIcon = function(key, component, title, template) { // eslint-disable-line no-unused-vars
throw new Error('Abstract function not implemented.');
};
......
......@@ -39,7 +39,7 @@ define(['core/icon_system', 'jquery', 'core/ajax', 'core/mustache', 'core/locals
* Prefetch resources so later calls to renderIcon can be resolved synchronously.
*
* @method init
* @return Promise
* @return {Promise}
*/
IconSystemFontawesome.prototype.init = function() {
if (staticMap) {
......@@ -67,7 +67,7 @@ define(['core/icon_system', 'jquery', 'core/ajax', 'core/mustache', 'core/locals
staticMap = {};
$.each(map, function(index, value) {
staticMap[value.component + '/' + value.pix] = value.to;
}.bind(this));
});
LocalStorage.set('core/iconmap-fontawesome', JSON.stringify(staticMap));
return this;
}.bind(this));
......@@ -83,7 +83,7 @@ define(['core/icon_system', 'jquery', 'core/ajax', 'core/mustache', 'core/locals
* @return {String}
* @method renderIcon
*/
IconSystemFontawesome.prototype.renderIcon = function(key, component, title, template) { //eslint-disable-line no-unused-vars
IconSystemFontawesome.prototype.renderIcon = function(key, component, title, template) { // eslint-disable-line no-unused-vars
var mappedIcon = staticMap[component + '/' + key];
if (typeof mappedIcon === "undefined") {
mappedIcon = component + '/' + key;
......
......@@ -42,7 +42,7 @@ define(['core/icon_system', 'core/url', 'core/mustache'],
* @return {String}
* @method renderIcon
*/
IconSystemStandard.prototype.renderIcon = function(key, component, title, template) { //eslint-disable-line no-unused-vars
IconSystemStandard.prototype.renderIcon = function(key, component, title, template) { // eslint-disable-line no-unused-vars
var url = CoreUrl.imageUrl(key, component);
var templatecontext = {
......
......@@ -107,11 +107,9 @@ class external extends external_api {
/**
* Return a mapping of icon names to icons.
*
* @param string $system
* @return array the mapping
*/
public static function load_fontawesome_icon_map() {
$instance = icon_system::instance(icon_system::FONTAWESOME);
$map = $instance->get_icon_name_map();
......
......@@ -28,6 +28,8 @@ namespace core\output;
use renderer_base;
use pix_icon;
defined('MOODLE_INTERNAL') || die();
/**
* Class allowing different systems for mapping and rendering icons.
*
......@@ -42,15 +44,37 @@ use pix_icon;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class icon_system {
/**
* @const STANDARD Default icon system.
*/
const STANDARD = '\\core\\output\\icon_system_standard';
/**
* @const FONTAWESOME Default icon system.
*/
const FONTAWESOME = '\\core\\output\\icon_system_fontawesome';
/**
* @var \core\output\icon_system $instance The cached default instance
*/
private static $instance = null;
/**
* @var array $map A cached mapping of moodle icons to other icons
*/
private $map = null;
/**
* Constructor
*/
private function __construct() {
}
/**
* Factory method
*
* @param $type Either a specific type, or null to get the default type.
* @return \core\output\icon_system
*/
public final static function instance($type = null) {
global $PAGE;
......
......@@ -25,6 +25,8 @@
namespace core\output;
defined('MOODLE_INTERNAL') || die();
/**
* Class allowing different systems for mapping and rendering icons.
*
......
......@@ -28,6 +28,8 @@ namespace core\output;
use renderer_base;
use pix_icon;
defined('MOODLE_INTERNAL') || die();
/**
* Class allowing different systems for mapping and rendering icons.
*
......@@ -43,6 +45,11 @@ use pix_icon;
*/
class icon_system_fontawesome extends icon_system_font {
/**
* @var array $map Cached map of moodle icon names to font awesome icon names.
*/
private $map = [];
public function get_core_icon_map() {
return [
'core:docs' => 'fa-info-circle',
......@@ -89,7 +96,7 @@ class icon_system_fontawesome extends icon_system_font {
'core:e/delete' => 'fa-minus',
'core:e/delete_table' => 'fa-minus',
'core:e/document_properties' => 'fa-info',
'core:e/emoticons' => 'fa-meh-o',
'core:e/emoticons' => 'fa-smile-o',
'core:e/find_replace' => 'fa-search-plus',
'core:e/forward' => 'fa-arrow-right',
'core:e/fullpage' => 'fa-arrows-alt',
......@@ -241,7 +248,7 @@ class icon_system_fontawesome extends icon_system_font {
'core:i/completion-manual-enabled' => 'fa-square-o',
'core:i/completion-manual-y' => 'fa-check-square',
'core:i/completion-manual-n' => 'fa-square-o',
'core:i/completion-self' => 'fa-user-o',
'core:i/completion_self' => 'fa-user-o',
'core:i/lock' => 'fa-lock',
'core:i/courseevent' => 'fa-calendar',
'core:i/course' => 'fa-globe',
......@@ -252,10 +259,10 @@ class icon_system_fontawesome extends icon_system_font {
'core:i/duration' => 'fa-clock-o',
'core:i/edit' => 'fa-pencil',
'core:i/email' => 'fa-envelope',
'core:i/enrolmentsuspended' => 'fa-user-circle',
'core:i/enrolmentsuspended' => 'fa-pause',
'core:i/enrolusers' => 'fa-user-plus',
'core:i/expired' => 'fa-exclamation text-warning',
'core:i/export' => 'fa-level-down',
'core:i/export' => 'fa-download',
'core:i/files' => 'fa-file',
'core:i/filter' => 'fa-filter',
'core:i/flagged' => 'fa-flag',
......@@ -270,7 +277,7 @@ class icon_system_fontawesome extends icon_system_font {
'core:i/groups' => 'fa-user-circle',
'core:i/groupv' => 'fa-user-circle-o',
'core:i/hide' => 'fa-eye',
'core:i/heirarchylock' => 'fa-lock',
'core:i/hierarchylock' => 'fa-lock',
'core:i/import' => 'fa-level-up',
'core:i/info' => 'fa-info',
'core:i/invalid' => 'fa-exclamation text-danger',
......@@ -289,7 +296,7 @@ class icon_system_fontawesome extends icon_system_font {
'core:i/moodle_host' => 'fa-graduation-cap',
'core:i/move_2d' => 'fa-arrows',
'core:i/navigationitem' => 'fa-angle-right',
'core:i/ns_red_mark' => 'fa-remove',
'core:i/ne_red_mark' => 'fa-remove',
'core:i/new' => 'fa-plus',
'core:i/news' => 'fa-newspaper-o',
'core:i/nosubcat' => 'fa-plus-square-o',
......@@ -324,7 +331,7 @@ class icon_system_fontawesome extends icon_system_font {
'core:i/settings' => 'fa-cogs',
'core:i/show' => 'fa-eye-slash',
'core:i/siteevent' => 'fa-share-alt',
'core:i/starrating' => 'fa-star',
'core:i/star-rating' => 'fa-star',
'core:i/stats' => 'fa-line-chart',
'core:i/switch' => 'fa-exchange',
'core:i/switchrole' => 'fa-user-secret',
......@@ -418,8 +425,6 @@ class icon_system_fontawesome extends icon_system_font {
];
}
private $map = [];
/**
* Overridable function to get a mapping of all icons.
* Default is to do no mapping.
......
......@@ -28,6 +28,8 @@ namespace core\output;
use renderer_base;
use pix_icon;
defined('MOODLE_INTERNAL') || die();
/**
* Standard icon rendering. No mapping - img tags used.
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment