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
    @template core/local/dropdown/dialog
19
 
20
    Displays a dropdown dialog component.
21
 
22
    Classes required for JS:
23
    * none
24
 
25
    Context variables required for this template:
26
    * buttoncontent String - the dropdown trigger button content.
27
    * dialogcontent String - the dropdown dialog content.
28
 
29
    Optional blocks:
30
    * dropdownclasses - additional classes for the dropdown.
31
    * buttonclasses - additional classes for the dropdown trigger button.
32
    * dialogclasses - additional classes for the dropdown dialog.
33
    * dialogcontent - the dropdown dialog content.
34
    * buttoncontent - the dropdown trigger button content.
35
    * extras - custom HTML attributes for the component.
36
    * dropdownid - the dropdown id (will be auto-generate if no id is passed).
37
 
38
    Example context (json):
39
    {
40
        "dropdownid": "internaldropdownid",
41
        "buttonid": "internalbuttonid",
42
        "buttoncontent": "Trigger button",
43
        "dialogcontent": "<a href=\"#\">Moodle</a>",
44
        "extras": [
45
            {
46
                "attribute": "data-example",
47
                "value": "stickyfooter"
48
            }
49
        ],
50
        "buttonclasses": "extraclasses",
51
        "dialogclasses": "extraclasses",
52
        "disabledbutton": false,
53
        "classes": "extraclasses"
54
    }
55
}}
56
<div
57
    class="dropdown {{!
58
        }} {{$ dropdownclasses }} {{!
59
            }} {{#classes}} {{classes}} {{/classes}} {{!
60
        }} {{/ dropdownclasses }}"
61
    id="{{$ dropdownid }}{{!
62
            }}{{#dropdownid}}{{dropdownid}}{{/dropdownid}}{{!
63
            }}{{^dropdownid}}dropdownDialog_{{uniqid}}{{/dropdownid}}{{!
64
        }}{{/ dropdownid }}"
65
    {{$ extras }}
66
        {{#extras}}
67
            {{attribute}}="{{value}}"
68
        {{/extras}}
69
    {{/ extras }}
70
>
71
    <button
72
        class="{{$ buttonclasses }} {{!
73
                }} {{^buttonclasses}} btn btn-light btn-outline-secondary dropdown-toggle {{/buttonclasses}} {{!
74
                }} {{#buttonclasses}} {{buttonclasses}} {{/buttonclasses}} {{!
75
            }} {{/ buttonclasses }}"
76
        type="button"
77
        id="{{#buttonid}}{{buttonid}}{{/buttonid}}{{^buttonid}}dropdownDialog{{uniqid}}{{/buttonid}}"
78
        data-toggle="dropdown"
79
        aria-haspopup="true"
80
        aria-expanded="false"
81
        data-for="dropdowndialog_button"
82
        {{#disabledbutton}} disabled {{/disabledbutton}}
83
    >
84
        {{$ buttoncontent }}
85
            {{{ buttoncontent }}}
86
        {{/ buttoncontent }}
87
    </button>
88
    <div
89
        class="dropdown-menu {{!
90
            }} {{#position}} {{position}} {{/position}} {{!
91
            }} {{$ dialogclasses }} {{!
92
                }} {{#dialogclasses}} {{dialogclasses}} {{/dialogclasses}} {{!
93
            }} {{/ dialogclasses }}"
94
        aria-labelledby="{{#buttonid}}{{buttonid}}{{/buttonid}}{{^buttonid}}dropdownDialog{{uniqid}}{{/buttonid}}"
95
        data-for="dropdowndialog_dialog"
96
    >
97
        <div class="p-2" data-for="dropdowndialog_content">
98
            {{$ dialogcontent }}
99
                {{{dialogcontent}}}
100
            {{/ dialogcontent }}
101
        </div>
102
    </div>
103
</div>
104
{{#js}}
105
    require(['core/local/dropdown/dialog'], function(Module) {
106
        Module.init('#' + '{{$ dropdownid }}{{!
107
            }}{{#dropdownid}}{{dropdownid}}{{/dropdownid}}{{!
108
            }}{{^dropdownid}}dropdownDialog_{{uniqid}}{{/dropdownid}}{{!
109
        }}{{/ dropdownid }}');
110
    });
111
{{/js}}