be8707e42f4a39e47ae027435303df52c978671b
[moodle.git] / theme / boost / templates / core / action_menu_trigger.mustache
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/>.
16 }}
17 {{!
18     @template core/action_menu_trigger
20     Action menu trigger.
22     Example context (json):
23     {
24         "text": "Example link text",
25         "title": "Example link title",
26         "url": "http://example.com/link",
27         "classes": "icon menu-action",
28         "instance": "1",
29         "triggerextraclasses": "",
30         "attributes": [
31             {"name": "role", "value": "menuitem" },
32             {"name": "data-title", "value": "mymoodle,admin" }
33         ],
34         "secondary": {
35             "classes": "menu  align-tr-br",
36             "attributes": [
37                 {"name": "id", "value": "action-menu-0-menu"},
38                 {"name": "data-rel", "value": "menu-content"},
39                 {"name": "role", "value": "menu"},
40                 {"name": "data-align", "value": "tr-br"}
41             ],
42             "items": [
43                 {"actionmenulink":
44                     {
45                     "id": "action_link59ecf8394a68078",
46                     "disabled": false,
47                     "text": "Dashboard",
48                     "url": "http://example.com/link",
49                     "icon": {
50                         "key": "i/dashboard",
51                         "component": null,
52                         "title": "Dashboard"
53                         },
54                     "classes": "icon menu-action",
55                     "attributes": [
56                         {"name": "role", "value": "menuitem"},
57                         {"name": "data-title", "value": "mymoodle,admin"}
58                         ],
59                     "instance": 1,
60                     "showtext": true
61                     }
62                 },
63                 {"actionmenufiller":
64                     {
65                     "id": "action_link59ecf8394a68079",
66                     "disabled": false,
67                     "text": "",
68                     "url": "",
69                     "icon": null,
70                     "classes": "",
71                     "attributes": [
72                         {"name": "role", "value": "menuitem"}
73                         ]
74                     }
75                 }
76             ]
77         }
78     }
79 }}
80 <div class="dropdown">
81     <a href="#" tabindex="0" class="btn {{triggerextraclasses}} dropdown-toggle" id="dropdown-{{instance}}" aria-label="{{title}}" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" aria-controls="action-menu-{{instance}}-menu">
82         {{{actiontext}}}
83         {{{menutrigger}}}
84             {{#icon}}
85                 {{#pix}}
86                     {{key}},{{component}},{{title}}
87                 {{/pix}}
88             {{/icon}}
89             {{#rawicon}}{{{.}}}{{/rawicon}}
90         {{#menutrigger}}
91         <b class="caret"></b>
92         {{/menutrigger}}
93     </a>
94     {{#secondary}}
95         <div class="dropdown-menu dropdown-menu-right {{classes}}"{{#attributes}} {{name}}="{{value}}"{{/attributes}} id="dropdown-menu-{{instance}}">
96             {{#items}}
97                 {{#actionmenulink}}
98                     <a href="{{url}}" class="dropdown-item {{classes}}" {{#attributes}}{{name}}={{#quote}}{{value}}{{/quote}} {{/attributes}}{{#showtext}}aria-labelledby="actionmenuaction-{{instance}}"{{/showtext}}>
99                         {{#icon}}
100                             {{#pix}}{{key}},{{component}},{{title}}{{/pix}}
101                         {{/icon}}
102                         {{#showtext}}
103                         <span class="menu-action-text" id="actionmenuaction-{{instance}}">
104                             {{{text}}}
105                         </span>
106                         {{/showtext}}
107                     </a>
108                 {{/actionmenulink}}
109                 {{#actionmenufiller}}
110                     <div class="dropdown-divider" role="presentation"><span class="filler">&nbsp;</span></div>
111                 {{/actionmenufiller}}
112                 {{^actionmenulink}}
113                     {{^actionmenufiller}}
114                         <div class="dropdown-item">{{> core/action_menu_item }}</div>
115                     {{/actionmenufiller}}
116                 {{/actionmenulink}}
117             {{/items}}
118         </div>
119     {{/secondary}}
120 </div>