Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
{{!
2
    This file is part of Moodle - http://moodle.org/
3
 
4
    Moodle is free software: you can redistribute it and/or modify
5
    it under the terms of the GNU General Public License as published by
6
    the Free Software Foundation, either version 3 of the License, or
7
    (at your option) any later version.
8
 
9
    Moodle is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    GNU General Public License for more details.
13
 
14
    You should have received a copy of the GNU General Public License
15
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
}}
17
{{!
18
{{!
19
    @template mod_unilabel/setting_configselect
20
    Template to show a dropdown select box with graphical icons for the custom buttons.
21
 
22
    Example context (json):
23
    {
24
        "id": "idjjfldsfxy_fjsdlf",
25
        "name": "fjlsdjflsdf",
26
        "values": [
27
            {
28
                "value": 0,
29
                "title": "Design",
30
                "istext": 1
31
            },
32
            {
33
                "value": 1,
34
                "title": "fa-solid fa-arrow-right"
35
            },
36
            {
37
                "value": 2,
38
                "title": "fa-solid fa-angle-right"
39
            }
40
        ],
41
        "cssjsonstring": "'css-selector {overflow: hidden;}'",
42
        "currentvalue": "fa-solid fa-arrow-right"
43
    }
44
}}
45
<div class="dropdown">
46
    <button type="button" id="btn-{{id}}" class="btn py-0 my-0 pr-2 border dropdown-toggle" data-toggle="dropdown">
47
        {{#currentvalueistext}}
48
            {{currentvalue}}
49
        {{/currentvalueistext}}
50
        {{^currentvalueistext}}
51
            <i class="{{currentvalue}}"></i>
52
        {{/currentvalueistext}}
53
    </button>
54
    <div id="dd-{{id}}" class="dropdown-menu">
55
        {{#values}}
56
            <div class="dropdown-item px-2{{#checked}} checked{{/checked}}">
57
                <input class="d-none" type="radio" id="{{name}}_{{value}}" name="{{name}}" value="{{value}}"{{#checked}} checked="checked"{{/checked}}>
58
                <label class="w-100" for="{{name}}_{{value}}">
59
                    {{#istext}}
60
                        {{title}}
61
                    {{/istext}}
62
                    {{^istext}}
63
                        <i class="fa {{title}}"></i>
64
                    {{/istext}}
65
                </label>
66
            </div>
67
        {{/values}}
68
    </div>
69
</div>
70
 
71
{{#js}}
72
    require(['mod_unilabel/add_css'], function(mod) {
73
        // To make sure we have clean html we have to put the css into the <head> by using javascript.
74
        mod.init({{{cssjsonstring}}});
75
    });
76
    require(['mod_unilabel/dropdown_radio'], function(mod) {
77
        mod.init("{{id}}");
78
    });
79
{{/js}}