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 |
"classes": "extraclasses"
|
|
|
53 |
}
|
|
|
54 |
}}
|
|
|
55 |
<div
|
|
|
56 |
class="dropdown {{!
|
|
|
57 |
}} {{$ dropdownclasses }} {{!
|
|
|
58 |
}} {{#classes}} {{classes}} {{/classes}} {{!
|
|
|
59 |
}} {{/ dropdownclasses }}"
|
|
|
60 |
id="{{$ dropdownid }}{{!
|
|
|
61 |
}}{{#dropdownid}}{{dropdownid}}{{/dropdownid}}{{!
|
|
|
62 |
}}{{^dropdownid}}dropdownDialog_{{uniqid}}{{/dropdownid}}{{!
|
|
|
63 |
}}{{/ dropdownid }}"
|
|
|
64 |
{{$ extras }}
|
|
|
65 |
{{#extras}}
|
|
|
66 |
{{attribute}}="{{value}}"
|
|
|
67 |
{{/extras}}
|
|
|
68 |
{{/ extras }}
|
|
|
69 |
>
|
|
|
70 |
<button
|
|
|
71 |
class="{{#buttonclasses}} {{buttonclasses}} {{/buttonclasses}} btn--dialog"
|
|
|
72 |
type="button"
|
|
|
73 |
id="{{#buttonid}}{{buttonid}}{{/buttonid}}{{^buttonid}}dropdownDialog{{uniqid}}{{/buttonid}}"
|
|
|
74 |
data-toggle="dropdown"
|
|
|
75 |
aria-haspopup="true"
|
|
|
76 |
aria-expanded="false"
|
|
|
77 |
data-for="dropdowndialog_button"
|
|
|
78 |
>
|
|
|
79 |
<svg width="20" height="20" fill="none" viewBox="0 0 24 24">
|
|
|
80 |
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 13V15"></path>
|
|
|
81 |
<circle cx="12" cy="9" r="1" fill="currentColor"></circle>
|
|
|
82 |
<circle cx="12" cy="12" r="7.25" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></circle>
|
|
|
83 |
</svg>
|
|
|
84 |
</button>
|
|
|
85 |
<div
|
|
|
86 |
class="dropdown-menu {{!
|
|
|
87 |
}} dropright {{!
|
|
|
88 |
}} {{$ dialogclasses }} {{!
|
|
|
89 |
}} {{#dialogclasses}} {{dialogclasses}} {{/dialogclasses}} {{!
|
|
|
90 |
}} {{/ dialogclasses }}"
|
|
|
91 |
aria-labelledby="{{#buttonid}}{{buttonid}}{{/buttonid}}{{^buttonid}}dropdownDialog{{uniqid}}{{/buttonid}}"
|
|
|
92 |
data-for="dropdowndialog_dialog"
|
|
|
93 |
>
|
|
|
94 |
<span class="badge badge-xs badge-light">{{$ buttoncontent }}{{{ buttoncontent }}}{{/ buttoncontent }}</span>
|
|
|
95 |
<div data-for="dropdowndialog_content">
|
|
|
96 |
{{$ dialogcontent }}
|
|
|
97 |
{{{dialogcontent}}}
|
|
|
98 |
{{/ dialogcontent }}
|
|
|
99 |
</div>
|
|
|
100 |
</div>
|
|
|
101 |
</div>
|
|
|
102 |
{{#js}}
|
|
|
103 |
require(['core/local/dropdown/dialog'], function(Module) {
|
|
|
104 |
Module.init('#' + '{{$ dropdownid }}{{!
|
|
|
105 |
}}{{#dropdownid}}{{dropdownid}}{{/dropdownid}}{{!
|
|
|
106 |
}}{{^dropdownid}}dropdownDialog_{{uniqid}}{{/dropdownid}}{{!
|
|
|
107 |
}}{{/ dropdownid }}');
|
|
|
108 |
});
|
|
|
109 |
{{/js}}
|