Merge branch 'MDL-77272-main' of https://github.com/SergioComeron/moodle
[moodle.git] / lib / templates / action_menu_trigger.mustache
blobfbe27c74f5aa960c67c8a9de236a660166fcd1f7
1 {{!
2     This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
17 {{!
18     @template core/action_menu_trigger
20     Action menu trigger.
22     Example context (json):
23     {
24         "actiontext": "Example link text",
25         "title": "Example link title",
26         "triggerrole": "button",
27         "triggerattributes": [
28             {"name": "data-boundary", "value": "window" }
29         ],
30         "url": "http://example.com/link",
31         "classes": "icon menu-action",
32         "instance": "1",
33         "triggerextraclasses": "",
34         "attributes": [
35             {"name": "role", "value": "menuitem" },
36             {"name": "data-title", "value": "mymoodle,admin" }
37         ],
38         "secondary": {
39             "classes": "menu  align-tr-br",
40             "dropdownalignment": "dropdown-menu-right",
41             "attributes": [
42                 {"name": "id", "value": "action-menu-0-menu"},
43                 {"name": "data-rel", "value": "menu-content"},
44                 {"name": "role", "value": "menu"},
45                 {"name": "data-align", "value": "tr-br"}
46             ],
47             "items": [
48                 {"actionmenulink":
49                     {
50                     "id": "action_link59ecf8394a68078",
51                     "disabled": false,
52                     "text": "Dashboard",
53                     "url": "http://example.com/link",
54                     "icon": {
55                         "key": "i/dashboard",
56                         "component": null,
57                         "title": "Dashboard"
58                         },
59                     "classes": "menu-action",
60                     "attributes": [
61                         {"name": "role", "value": "menuitem"},
62                         {"name": "data-title", "value": "mymoodle,admin"}
63                         ],
64                     "instance": 1,
65                     "showtext": true
66                     }
67                 },
68                 {"actionmenufiller":
69                     {
70                     "id": "action_link59ecf8394a68079",
71                     "disabled": false,
72                     "text": "",
73                     "url": "",
74                     "icon": null,
75                     "classes": "",
76                     "attributes": [
77                         {"name": "role", "value": "menuitem"}
78                         ]
79                     }
80                 }
81             ]
82         }
83     }
85 <div class="dropdown{{^secondary.items}} hidden{{/secondary.items}}">
86     <a
87         href="#"
88         tabindex="0"
89         class="{{triggerextraclasses}} dropdown-toggle icon-no-margin"
90         id="action-menu-toggle-{{instance}}"
91         aria-label="{{title}}"
92         data-toggle="dropdown"
93         role="{{triggerrole}}"
94         aria-haspopup="true"
95         aria-expanded="false"
96         aria-controls="action-menu-{{instance}}-menu"
97     {{#triggerattributes}}
98         {{name}}="{{value}}"
99     {{/triggerattributes}}
100     >
101         {{{actiontext}}}
102         {{{menutrigger}}}
103             {{#icon}}
104                 {{#pix}}
105                     {{key}},{{component}},{{title}}
106                 {{/pix}}
107             {{/icon}}
108             {{#rawicon}}{{{.}}}{{/rawicon}}
109         {{#menutrigger}}
110         <b class="caret"></b>
111         {{/menutrigger}}
112     </a>
113     {{#secondary}}
114         <div class="dropdown-menu {{classes}} {{dropdownalignment}}"{{#attributes}} {{name}}="{{value}}"{{/attributes}}>
115             {{#items}}
116                 {{#actionmenulink}}
117                     {{< core/action_menu_link}}
118                         {{$actionmenulinkclasses}}dropdown-item {{classes}}{{/actionmenulinkclasses}}
119                     {{/ core/action_menu_link}}
120                 {{/actionmenulink}}
121                 {{#actionmenufiller}}
122                     <div class="dropdown-divider" role="presentation"><span class="filler">&nbsp;</span></div>
123                 {{/actionmenufiller}}
124                 {{#subpanel}}
125                     {{> core/local/action_menu/subpanel}}
126                 {{/subpanel}}
127                 {{#simpleitem}}
128                     <div class="dropdown-item">{{> core/action_menu_item }}</div>
129                 {{/simpleitem}}
130             {{/items}}
131         </div>
132     {{/secondary}}
133 </div>