1 // This file is part of Moodle - http://moodle.org/
3 // Moodle is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
8 // Moodle is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 * Icon System base module.
20 * @copyright 2017 Damyon Wiese
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 define(['jquery'], function($) {
27 * Icon System abstract class.
29 * Any icon system needs to define a module extending this one and return this module name from the php icon_system class.
31 var IconSystem = function() {
35 * Initialise the icon system.
40 IconSystem.prototype.init = function() {
47 * The key, component and title come from either the pix mustache helper tag, or the call to templates.renderIcon.
48 * The template is the pre-loaded template string matching the template from getTemplateName() in this class.
49 * This function must return a string (not a promise) because it is used during the internal rendering of the mustache
50 * template (which is unfortunately synchronous). To render the mustache template in this function call
51 * core/mustache.render() directly and do not use any partials, blocks or helper functions in the template.
54 * @param {String} component
55 * @param {String} title
56 * @param {String} template
60 IconSystem.prototype.renderIcon = function(key, component, title, template) { // eslint-disable-line no-unused-vars
61 throw new Error('Abstract function not implemented.');
68 * @method getTemplateName
70 IconSystem.prototype.getTemplateName = function() {
71 throw new Error('Abstract function not implemented.');
74 return /** @alias module:core/icon_system */ IconSystem;