Commit | Line | Data |
---|---|---|
c026a28d MG |
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_tag/taglist | |
19 | ||
20 | Displays a tag list, usually the list of tags some entry is tagged with | |
21 | ||
22 | Classes required for JS: | |
23 | * hideoverlimit | |
24 | * tagmorelink | |
25 | * taglesslink | |
26 | ||
27 | Data attributes required for JS: | |
28 | * none | |
29 | ||
30 | Context variables required for this template: | |
31 | * none | |
32 | ||
33 | Example context (json): | |
34 | { | |
7fa6a8f1 | 35 | "tags": [ |
e11d7380 MG |
36 | {"id":1,"name":"Cats","viewurl":"http://moodle.org/tag/index.php?tag=Cats","isstandard":"1","flag":0}, |
37 | {"id":1,"name":"Dogs","viewurl":"http://moodle.org/tag/index.php?tag=Dogs","isstandard":"0","flag":1}, | |
38 | {"id":1,"name":"Mice","viewurl":"http://moodle.org/tag/index.php?tag=Mice","isstandard":"0","flag":0} | |
7fa6a8f1 | 39 | ], |
c026a28d MG |
40 | "label": "Tags", |
41 | "tagscount": 3, | |
42 | "overflow": 1, | |
43 | "classes": "someadditionalclass" | |
44 | } | |
45 | ||
46 | }} | |
47 | {{#tagscount}} | |
48 | <div class="tag_list hideoverlimit {{classes}}"> | |
49 | {{#label}} | |
50 | <b>{{label}}:</b> | |
51 | {{/label}} | |
52 | <ul class="inline-list"> | |
53 | {{#tags}} | |
54 | <li {{#overlimit}}class="overlimit"{{/overlimit}}> | |
3f2c68f1 | 55 | <a href="{{viewurl}}" class="badge badge-info {{#isstandard}}standardtag{{/isstandard}}" > |
c026a28d MG |
56 | {{#flag}} |
57 | <span class="flagged-tag">{{name}}</span></a> | |
58 | {{/flag}} | |
59 | {{^flag}} | |
60 | {{name}}</a> | |
61 | {{/flag}} | |
62 | </li> | |
63 | {{/tags}} | |
64 | {{#overflow}} | |
65 | <li class="visibleifjs"> | |
66 | <a href="#" class="tagmorelink">{{#str}}moretags, core_tag{{/str}}</a> | |
67 | </li> | |
68 | <li class="visibleifjs"> | |
69 | <a href="#" class="taglesslink">{{#str}}lesstags, core_tag{{/str}}</a> | |
70 | </li> | |
71 | {{/overflow}} | |
72 | </ul> | |
73 | </div> | |
74 | {{/tagscount}} | |
75 | ||
76 | {{#js}} | |
77 | require(['jquery'], function($) { | |
4139259c DM |
78 | $('.tag_list .tagmorelink').click(function(e) { |
79 | e.preventDefault(); | |
c026a28d MG |
80 | $(this).closest('.tag_list').removeClass('hideoverlimit'); |
81 | }); | |
4139259c DM |
82 | $('.tag_list .taglesslink').click(function(e) { |
83 | e.preventDefault(); | |
c026a28d MG |
84 | $(this).closest('.tag_list').addClass('hideoverlimit'); |
85 | }); | |
86 | }); | |
7fa6a8f1 | 87 | {{/js}} |