acfd680282d9536ef374d92c20599023e908f10f
[moodle.git] / lib / form / templates / filetypes-browser.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_form/filetypes-browser
20     The template is used to render the content of the UI widget allowing the
21     user to select individual file types or their groups.
23     Classes required for JS:
24     * none
26     Data attributes required for JS:
27     * none
29     Context variables required for this template:
30     * groups
31         * key
32         * name
33         * selectable
34         * expanded
35         * ext
36         * types
37             * key
38             * name
39             * selected
40             * expanded
41             * ext
43     Example context (json):
44     {
45         "groups": [
46             {
47                 "key": "web_file",
48                 "name": "Web files",
49                 "selectable": true,
50                 "selected": false,
51                 "ext": ".css .html .xhtml .htm .js",
52                 "types": [
53                     {
54                         "key": ".css",
55                         "name": "Cascading Style-Sheet",
56                         "selected": true,
57                         "ext": ".css"
58                     },
59                     {
60                         "key": ".htm",
61                         "name": "HTML text",
62                         "selected": false,
63                         "ext": ".htm .xhtml .html"
64                     }
65                 ]
66             },
67             {
68                 "key": "web_audio",
69                 "name": "Web-safe audio files",
70                 "selectable": false,
71                 "selected": false,
72                 "ext": null,
73                 "types": [
74                     {
75                         "key": "audio/mp3",
76                         "name": "Audio file (MP3)",
77                         "selected": false,
78                         "ext": ".mp3"
79                     }
80                 ]
81             }
82         ]
83     }
84 }}
85 <div data-filetypesbrowserbody="{{elementid}}" role="tree">
86 {{#groups}}
87     <div data-filetypesbrowserkey="{{key}}" role="treeitem" aria-expanded="{{#expanded}}true{{/expanded}}{{^expanded}}false{{/expanded}}">
88         <label>
89             {{#selectable}}
90             <input data-filetypesbrowserkey="{{key}}" type="checkbox" {{#selected}}checked{{/selected}}>
91             <strong data-filetypesname="{{key}}">{{name}}</strong>
92             <small class="muted" data-filetypesextensions="{{key}}">
93                 {{ext}}
94             </small>
95             {{/selectable}}
96             {{^selectable}}
97             <strong>{{name}}</strong>
98             {{/selectable}}
99         </label>
100         {{#types.0}}
101         {{! The tree provides its own accessibility controls, these two links are here for mouse users.
102             For that reason, we hide them from assistive technologies. }}
103         <small aria-hidden="true" data-filetypesbrowserfeature="hideifexpanded" class="pull-right float-right"><a href="#">{{#str}}expand{{/str}}</a></small>
104         <small aria-hidden="true" data-filetypesbrowserfeature="hideifcollapsed" class="pull-right float-right"><a href="#">{{#str}}collapse{{/str}}</a></small>
105         {{/types.0}}
106         <ul class="unstyled list-unstyled" role="group">
107             {{#types}}
108             <li data-filetypesbrowserkey="{{key}}" style="margin-left: 2em" role="treeitem">
109                 <label>
110                     <input data-filetypesbrowserkey="{{key}}" type="checkbox" {{#selected}}checked{{/selected}}>
111                     <span data-filetypesname="{{key}}">{{name}}</span>
112                     <small class="muted" data-filetypesextensions="{{key}}">
113                         {{ext}}
114                     </small>
115                 </label>
116             </li>
117             {{/types}}
118         </ul>
119         <hr style="clear:both">
120     </div>
121 {{/groups}}
122 </div>