1 |
efrain |
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 unilabeltype_carousel/carousel
|
|
|
19 |
Template to show a bootstrap carousel.
|
|
|
20 |
|
|
|
21 |
Example context (json):
|
|
|
22 |
{
|
|
|
23 |
"showintro": false,
|
|
|
24 |
"intro": "",
|
|
|
25 |
"interval": "5",
|
|
|
26 |
"height": "300",
|
|
|
27 |
"autoheight": false,
|
|
|
28 |
"background": "#A0E2FD",
|
|
|
29 |
"fontawesomeprev": "fa-solid fa-forward",
|
|
|
30 |
"fontawesomenext": "fa-solid fa-forward",
|
|
|
31 |
"captionstyle": "dark",
|
|
|
32 |
"captionwidth": "600",
|
|
|
33 |
"slides": [
|
|
|
34 |
{
|
|
|
35 |
"id": "4",
|
|
|
36 |
"carouselid": "1",
|
|
|
37 |
"url": "",
|
|
|
38 |
"newwindow": 1,
|
|
|
39 |
"caption": "<p>Slide 1<br><\/p>",
|
|
|
40 |
"imageurl": "https://url-to-image",
|
|
|
41 |
"imagemobileurl": "",
|
|
|
42 |
"nr": 0
|
|
|
43 |
},
|
|
|
44 |
{
|
|
|
45 |
"id": "5",
|
|
|
46 |
"carouselid": "1",
|
|
|
47 |
"url": "",
|
|
|
48 |
"newwindow": 1,
|
|
|
49 |
"caption": "<p>Slide 2<br><\/p>",
|
|
|
50 |
"imageurl": "https://url-to-image",
|
|
|
51 |
"imagemobileurl": "",
|
|
|
52 |
"nr": 1
|
|
|
53 |
},
|
|
|
54 |
{
|
|
|
55 |
"id": "6",
|
|
|
56 |
"carouselid": "1",
|
|
|
57 |
"url": "",
|
|
|
58 |
"newwindow": 1,
|
|
|
59 |
"caption": "<p>Slide 3<br><\/p>",
|
|
|
60 |
"imageurl": "https://url-to-image",
|
|
|
61 |
"imagemobileurl": "",
|
|
|
62 |
"nr": 2
|
|
|
63 |
}
|
|
|
64 |
],
|
|
|
65 |
"hasslides": true,
|
|
|
66 |
"custombuttons": true,
|
|
|
67 |
"cssjsonstring": "'css-selector {overflow: hidden;}'",
|
|
|
68 |
"cmid": "55"
|
|
|
69 |
}
|
|
|
70 |
}}
|
|
|
71 |
|
|
|
72 |
{{#showintro}}
|
|
|
73 |
{{{intro}}}
|
|
|
74 |
{{/showintro}}
|
|
|
75 |
{{#hasslides}}
|
|
|
76 |
<div id="{{plugin}}-{{uniqid}}-{{cmid}}" class="{{plugin}} carousel slide my-2" data-ride="carousel" data-interval="{{#interval}}{{.}}000{{/interval}}{{^interval}}false{{/interval}}">
|
|
|
77 |
|
|
|
78 |
<!-- Indicators -->
|
|
|
79 |
<ul class="carousel-indicators" style="z-index:999;">
|
|
|
80 |
{{#slides}}
|
|
|
81 |
<li data-target="#{{plugin}}-{{uniqid}}-{{cmid}}" data-slide-to="{{nr}}"{{^nr}} class="active"{{/nr}}></li>
|
|
|
82 |
{{/slides}}
|
|
|
83 |
</ul>
|
|
|
84 |
|
|
|
85 |
<!-- The slideshow -->
|
|
|
86 |
<div class="carousel-inner" style="background-color:{{background}};">
|
|
|
87 |
{{#slides}}
|
|
|
88 |
<div class="carousel-item text-center py-4{{^nr}} active{{/nr}}">
|
|
|
89 |
{{#url}}
|
|
|
90 |
<!-- The overlay is used as button to show the modal dialog -->
|
|
|
91 |
<a href="{{{url}}}"{{#newwindow}} target="_blank"{{/newwindow}}>
|
|
|
92 |
<div class="unilabel-overlay-effect bg-primary h-100 w-100"></div>
|
|
|
93 |
</a>
|
|
|
94 |
{{/url}}
|
|
|
95 |
{{^autoheight}}<div style="height:{{{height}}}px;width:100%;">{{/autoheight}}
|
|
|
96 |
|
|
|
97 |
{{#imagemobileurl}}
|
|
|
98 |
{{#imageurl}}
|
|
|
99 |
<img class="img-fluid d-none d-md-inline" alt="{{captionplain}}" src="{{{imageurl}}}"{{^autoheight}} style="height:100%;object-fit:contain;"{{/autoheight}}>
|
|
|
100 |
{{/imageurl}}
|
|
|
101 |
<img class="img-fluid d-inline d-md-none" alt="{{captionplain}}" src="{{{imagemobileurl}}}"{{^autoheight}} style="height:100%;object-fit:contain;"{{/autoheight}}>
|
|
|
102 |
{{/imagemobileurl}}
|
|
|
103 |
{{^imagemobileurl}}
|
|
|
104 |
{{#imageurl}}
|
|
|
105 |
<img class="img-fluid" alt="{{captionplain}}" src="{{{imageurl}}}"{{^autoheight}} style="height:100%;object-fit:contain;"{{/autoheight}}>
|
|
|
106 |
{{/imageurl}}
|
|
|
107 |
{{/imagemobileurl}}
|
|
|
108 |
|
|
|
109 |
{{^autoheight}}</div>{{/autoheight}}
|
|
|
110 |
|
|
|
111 |
{{#caption}}
|
|
|
112 |
{{> unilabeltype_carousel/carousel_caption }}
|
|
|
113 |
{{/caption}}
|
|
|
114 |
|
|
|
115 |
</div>
|
|
|
116 |
{{/slides}}
|
|
|
117 |
</div>
|
|
|
118 |
|
|
|
119 |
<!-- Left and right controls -->
|
|
|
120 |
{{< unilabeltype_carousel/carousel_control}}{{!
|
|
|
121 |
}} {{$direction}}next{{/direction}}{{!
|
|
|
122 |
}} {{$icon}}{{#fontawesomenext}}{{.}}{{/fontawesomenext}}{{^fontawesomenext}}d-none{{/fontawesomenext}}{{/icon}}{{!
|
|
|
123 |
}} {{/ unilabeltype_carousel/carousel_control}}
|
|
|
124 |
{{< unilabeltype_carousel/carousel_control}}{{!
|
|
|
125 |
}} {{$direction}}prev{{/direction}}{{!
|
|
|
126 |
}} {{$icon}}{{#fontawesomeprev}}{{.}}{{/fontawesomeprev}}{{^fontawesomeprev}}d-none{{/fontawesomeprev}}{{/icon}}{{!
|
|
|
127 |
}} {{/ unilabeltype_carousel/carousel_control}}
|
|
|
128 |
</div>
|
|
|
129 |
{{/hasslides}}
|
|
|
130 |
{{^hasslides}}
|
|
|
131 |
<span>{{#str}} nocontent , unilabeltype_carousel {{/str}}</span>
|
|
|
132 |
{{/hasslides}}
|
|
|
133 |
{{#js}}
|
|
|
134 |
require(['theme_boost/loader']);
|
|
|
135 |
require(['theme_boost/bootstrap/carousel']);
|
|
|
136 |
{{#interval}}
|
|
|
137 |
require(['mod_unilabel/carouselstart'], function(mod) {
|
|
|
138 |
mod.init('{{plugin}}-{{uniqid}}-{{cmid}}');
|
|
|
139 |
});
|
|
|
140 |
{{/interval}}
|
|
|
141 |
|
|
|
142 |
{{#hasslides}}
|
|
|
143 |
{{#custombuttons}}
|
|
|
144 |
require(['mod_unilabel/add_css'], function(mod) {
|
|
|
145 |
// To make sure we have clean html we have to put the css into the <head> by using javascript.
|
|
|
146 |
mod.init({{{cssjsonstring}}});
|
|
|
147 |
});
|
|
|
148 |
{{/custombuttons}}
|
|
|
149 |
{{/hasslides}}
|
|
|
150 |
|
|
|
151 |
{{/js}}
|