on-demand release 3.7dev+
[moodle.git] / tag / templates / taglist.mustache
blob72975fd8068843300af3290dd6dc2232b98d3837
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_tag/taglist
20     Displays a tag list, usually the list of tags some entry is tagged with
22     Classes required for JS:
23     * hideoverlimit
24     * tagmorelink
25     * taglesslink
27     Data attributes required for JS:
28     * none
30     Context variables required for this template:
31     * none
33     Example context (json):
34     {
35     "tags": [
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}
39     ],
40         "label": "Tags",
41         "tagscount": 3,
42         "overflow": 1,
43         "classes": "someadditionalclass"
44     }
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}}>
55                 <a href="{{viewurl}}" class="badge badge-info {{#isstandard}}standardtag{{/isstandard}}" >
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}}
76 {{#js}}
77 require(['jquery'], function($) {
78     $('.tag_list .tagmorelink').click(function(e) {
79         e.preventDefault();
80         $(this).closest('.tag_list').removeClass('hideoverlimit');
81     });
82     $('.tag_list .taglesslink').click(function(e) {
83         e.preventDefault();
84         $(this).closest('.tag_list').addClass('hideoverlimit');
85     });
86 });
87 {{/js}}