Merge branch 'MDL-81419-main' of https://github.com/andrewnicols/moodle
[moodle.git] / lib / templates / showmore.mustache
blob2f26c5f07d38a47d624a7649d37e26244cea18c0
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/showmore
20     Displays content with 'Show more'/'Show less' feature.
22     Example context (json):
23     {
24         "collapsedcontent": "Hello...",
25         "expandedcontent": "Hello...<br>Is it me you're looking for? I can see it in your eyes",
26         "extraclasses": "p-3",
27         "collapsedextraclasses": "bg-secondary",
28         "expandedextraclasses": "bg-secondary"
29     }
31 <div class="showmore-container collapsed {{$extraclasses}}{{extraclasses}}{{/extraclasses}}" data-region="showmore">
32     <button
33         type="button"
34         class="btn btn-sm btn-link p-0 {{$buttonextraclasses}}{{buttonextraclasses}}{{/buttonextraclasses}}"
35         aria-expanded="false"
36         data-action="toggle-content"
37     >
38         <span class="collapsed-content"> {{#str}} showmore, core {{/str}} {{#pix}} t/expandedchevron, core {{/pix}} </span>
39         <span class="expanded-content"> {{#str}} showless, core {{/str}} {{#pix}} t/collapsedchevron_up, core {{/pix}} </span>
40     </button>
41     <div class="collapsed-content {{$collapsedextraclasses}}{{collapsedextraclasses}}{{/collapsedextraclasses}}">
42         {{$collapsedcontent}}{{{collapsedcontent}}}{{/collapsedcontent}}
43     </div>
44     <div class="expanded-content {{$expandedextraclasses}}{{expandedextraclasses}}{{/expandedextraclasses}}">
45         {{$expandedcontent}}{{{expandedcontent}}}{{/expandedcontent}}
46     </div>
47 </div>
48 {{#js}}
49 require(['core/showmore'], function(showmore) {
50     showmore.init();
51 });
52 {{/js}}