MDL-66845 mod_forum: Hook up save button
[moodle.git] / tag / templates / taglist.mustache
blob7dc30a386c3aafb261e5626a654132810959c099
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         "accesshidelabel": false,
42         "tagscount": 3,
43         "overflow": 1,
44         "classes": "someadditionalclass"
45     }
48 {{#tagscount}}
49     <div class="tag_list hideoverlimit {{classes}}">
50     {{#label}}
51         <b{{#accesshidelabel}} class="accesshide"{{/accesshidelabel}}>{{label}}:</b>
52     {{/label}}
53     <ul class="inline-list">
54         {{#tags}}
55             <li {{#overlimit}}class="overlimit"{{/overlimit}}>
56                 <a href="{{viewurl}}" class="badge badge-info {{#isstandard}}standardtag{{/isstandard}}" >
57                 {{#flag}}
58                     <span class="flagged-tag">{{name}}</span></a>
59                 {{/flag}}
60                 {{^flag}}
61                     {{name}}</a>
62                 {{/flag}}
63             </li>
64         {{/tags}}
65         {{#overflow}}
66             <li class="visibleifjs">
67                 <a href="#" class="tagmorelink">{{#str}}moretags, core_tag{{/str}}</a>
68             </li>
69             <li class="visibleifjs">
70                 <a href="#" class="taglesslink">{{#str}}lesstags, core_tag{{/str}}</a>
71             </li>
72         {{/overflow}}
73     </ul>
74     </div>
75 {{/tagscount}}
77 {{#js}}
78 require(['jquery'], function($) {
79     $('.tag_list .tagmorelink').click(function(e) {
80         e.preventDefault();
81         $(this).closest('.tag_list').removeClass('hideoverlimit');
82     });
83     $('.tag_list .taglesslink').click(function(e) {
84         e.preventDefault();
85         $(this).closest('.tag_list').addClass('hideoverlimit');
86     });
87 });
88 {{/js}}