AutorÃa | Ultima modificación | Ver Log |
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
{{!
@template mod_unilabel/setting_configselect
Template to show a dropdown select box with graphical icons for the custom buttons.
Example context (json):
{
"id": "idjjfldsfxy_fjsdlf",
"name": "fjlsdjflsdf",
"values": [
{
"value": 0,
"title": "Design",
"istext": 1
},
{
"value": 1,
"title": "fa-solid fa-arrow-right"
},
{
"value": 2,
"title": "fa-solid fa-angle-right"
}
],
"cssjsonstring": "'css-selector {overflow: hidden;}'",
"currentvalue": "fa-solid fa-arrow-right"
}
}}
<div class="dropdown">
<button type="button" id="btn-{{id}}" class="btn py-0 my-0 pr-2 border dropdown-toggle" data-toggle="dropdown">
{{#currentvalueistext}}
{{currentvalue}}
{{/currentvalueistext}}
{{^currentvalueistext}}
<i class="{{currentvalue}}"></i>
{{/currentvalueistext}}
</button>
<div id="dd-{{id}}" class="dropdown-menu">
{{#values}}
<div class="dropdown-item px-2{{#checked}} checked{{/checked}}">
<input class="d-none" type="radio" id="{{name}}_{{value}}" name="{{name}}" value="{{value}}"{{#checked}} checked="checked"{{/checked}}>
<label class="w-100" for="{{name}}_{{value}}">
{{#istext}}
{{title}}
{{/istext}}
{{^istext}}
<i class="fa {{title}}"></i>
{{/istext}}
</label>
</div>
{{/values}}
</div>
</div>
{{#js}}
require(['mod_unilabel/add_css'], function(mod) {
// To make sure we have clean html we have to put the css into the <head> by using javascript.
mod.init({{{cssjsonstring}}});
});
require(['mod_unilabel/dropdown_radio'], function(mod) {
mod.init("{{id}}");
});
{{/js}}