Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
{{!
2
    @template core/url_select
3
 
4
    Example context (json):
5
    {
6
        "id": "url_select_test",
7
        "action": "https://example.com/post",
8
        "formid": "url_select_form",
9
        "sesskey": "sesskey",
10
        "label": "core/url_select",
11
        "helpicon": {
12
            "title": "Help with something",
13
            "text": "Help with something",
14
            "url": "http://example.org/help",
15
            "linktext": "",
16
            "icon":{
1441 ariadna 17
                "extraclasses": "",
1 efrain 18
                "attributes": [
19
                    {"name": "src", "value": "../../../pix/help.svg"},
20
                    {"name": "alt", "value": "Help icon"}
21
                ]
22
            }
23
        },
24
        "showbutton": "Go",
25
        "options": [{
26
            "name": "Group 1", "isgroup": true, "options":
27
            [
28
                {"name": "Item 1", "isgroup": false, "value": "1"},
1441 ariadna 29
                {"name": "Item 2", "isgroup": false, "value": "2"},
30
                {"name": "Item 1", "isgroup": false, "value": "3", "disabled": true}
1 efrain 31
            ]},
32
            {"name": "Group 2", "isgroup": true, "options":
33
            [
34
                {"name": "Item 3", "isgroup": false, "value": "3"},
35
                {"name": "Item 4", "isgroup": false, "value": "4"}
1441 ariadna 36
            ]},
37
            {"name": "Group 3", "isgroup": false, "value":"1"},
38
            {"name": "Group 4", "isgroup": false, "value":"1", "disabled": true}
39
        ],
40
 
1 efrain 41
        "disabled": false,
42
        "title": "Some cool title"
43
    }
44
}}
45
<div class="{{classes}}">
46
    <form method="post" action="{{action}}" class="d-flex flex-wrap align-items-center" id="{{formid}}">
47
        <input type="hidden" name="sesskey" value="{{sesskey}}">
48
        {{#label}}
49
            <label for="{{id}}"{{#labelattributes}} {{name}}="{{value}}"{{/labelattributes}}>
50
                {{label}}
51
            </label>
52
        {{/label}}
53
        {{#helpicon}}
54
            {{>core/help_icon}}
55
        {{/helpicon}}
1441 ariadna 56
        <select {{#attributes}}{{name}}="{{value}}" {{/attributes}} id="{{id}}" class="form-select {{classes}}" name="jump"
1 efrain 57
                {{#title}}title="{{.}}"{{/title}} {{#disabled}}disabled{{/disabled}}>
58
            {{#options}}
59
                {{#isgroup}}
60
                    <optgroup label="{{name}}">
61
                        {{#options}}
1441 ariadna 62
                            <option value="{{value}}" {{#selected}}selected{{/selected}} {{#disabled}}disabled{{/disabled}}>{{{name}}}</option>
1 efrain 63
                        {{/options}}
64
                    </optgroup>
65
                {{/isgroup}}
66
                {{^isgroup}}
1441 ariadna 67
                    <option value="{{value}}" {{#selected}}selected{{/selected}} {{#disabled}}disabled{{/disabled}}>{{{name}}}</option>
1 efrain 68
                {{/isgroup}}
69
            {{/options}}
70
        </select>
71
        {{#showbutton}}
1441 ariadna 72
            <input type="submit" class="btn btn-secondary ms-1" value="{{showbutton}}">
1 efrain 73
        {{/showbutton}}
74
        {{^showbutton}}
75
            <noscript>
1441 ariadna 76
                <input type="submit" class="btn btn-secondary ms-1" value="{{#str}}go, core{{/str}}">
1 efrain 77
            </noscript>
78
        {{/showbutton}}
79
    </form>
80
</div>
81
{{^showbutton}}
82
    {{#js}}
83
        require(['jquery', 'core/custom_interaction_events'], function($, CustomEvents) {
84
            CustomEvents.define('#{{id}}', [CustomEvents.events.accessibleChange]);
85
            $('#{{id}}').on(CustomEvents.events.accessibleChange, function() {
86
                if ($(this).val()) {
87
                    $('#{{formid}}').submit();
88
                }
89
            });
90
        });
91
    {{/js}}
92
{{/showbutton}}