-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarousel.html
More file actions
271 lines (211 loc) · 7.32 KB
/
Carousel.html
File metadata and controls
271 lines (211 loc) · 7.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Carousel Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link href="../style.css" rel="stylesheet" type="text/css" />
<!-- JavaXT Includes -->
<script type="text/javascript" src="../../src/carousel/Carousel.js"></script>
<script type="text/javascript" src="../../src/utils/Utils.js"></script>
<style>
.panelID {
font-size:50px;
color: #757575;
border: 5px solid #757575;
border-radius: 100px;
width: 100px;
height: 100px;
line-height: 100px;
position: relative;
top: 50%;
transform: translateY(-50%);
}
</style>
</head>
<body>
<h1>Carousel Demos</h1>
<h2>Demo 1</h2>
<p>Basic looping carousel with 3 panels. In this example, the carousel is
initiated using existing DOM elements.
</p>
<table style="width:500px;">
<tr>
<td align="center" class="javaxt-noselect">
<div id="carousel" style="width:250px;height:250px;border:1px solid #757575;">
<div style="background:#f0f8ff;height:100%;">
<div class="panelID">1</div>
</div>
<div style="background:#96a5b2;height:100%;">
<div class="panelID">2</div>
</div>
<div style="background:#ffd8d6;height:100%;">
<div class="panelID">3</div>
</div>
</div>
<div style="padding-top:10px;">
<input type="button" id="Back" value="Back"/>
<input type="button" id="Next" value="Next"/>
</div>
</td>
</tr>
</table>
<script type="text/javascript">
var demo1 = function() {
var carousel = new javaxt.dhtml.Carousel(document.getElementById("carousel"),{
loop: true,
animate: true
});
document.getElementById("Back").onclick = function(){
carousel.back();
};
document.getElementById("Next").onclick = function(){
carousel.next();
};
};
</script>
<h2>Demo 2</h2>
<p>Looping carousel with slide over effect. As with the previous example, the
carousel is initiated using existing DOM elements. However, unlike the
previous example, the "next" panel slides over the current panel during the
transitions.
</p>
<table style="width:500px;">
<tr>
<td align="center" class="javaxt-noselect">
<div id="carousel2" style="width:300px;height:450px;border:1px solid #757575;">
<div style="background:#f0f8ff;height:100%;">
<div class="panelID">1</div>
</div>
<div style="background:#96a5b2;height:100%;">
<div class="panelID">2</div>
</div>
<div style="background:#ffd8d6;height:100%;">
<div class="panelID">3</div>
</div>
</div>
<div style="padding-top:10px;">
<input type="button" id="Back2" value="Back"/>
<input type="button" id="Next2" value="Next"/>
</div>
</td>
</tr>
</table>
<script type="text/javascript">
var demo2 = function() {
var carousel = new javaxt.dhtml.Carousel(document.getElementById("carousel2"),{
loop: true,
animate: true,
slideOver: true
});
document.getElementById("Back2").onclick = function(){
carousel.back();
};
document.getElementById("Next2").onclick = function(){
carousel.next();
};
};
</script>
<h2>Demo 3</h2>
<p>Looping carousel with incrementing/decrementing panel IDs.
The carousel consists of only 3 panels but the content is updated to appear
as though it is made up of many panels.
</p>
<table style="width:500px;">
<tr>
<td align="center" class="javaxt-noselect">
<div id="carousel3" style="width:250px;height:250px;border:1px solid #757575;"></div>
<div style="padding-top:10px;">
<input type="button" id="Back3" value="Back"/>
<input type="button" id="Next3" value="Next"/>
</div>
</td>
</tr>
</table>
<script type="text/javascript">
var demo3 = function() {
var carouselDiv = document.getElementById("carousel3");
var carousel = new javaxt.dhtml.Carousel(carouselDiv,{
loop: true,
animate: true
});
//Create 3 panels
var currPanel = document.createElement('div');
currPanel.style.background = "#f0f8ff";
currPanel.style.height = "100%";
currPanel.setAttribute("panelID", "currPanel");
var nextPanel = document.createElement('div');
nextPanel.style.background = "#96a5b2";
nextPanel.style.height = "100%";
nextPanel.setAttribute("panelID", "nextPanel");
var prevPanel = document.createElement('div');
prevPanel.style.background = "#ffd8d6";
prevPanel.style.height = "100%";
prevPanel.setAttribute("panelID", "prevPanel");
//Populate the first panel
var currID = 0;
var panelID = document.createElement('div');
panelID.className = "panelID";
panelID.innerHTML = currID;
currPanel.appendChild(panelID);
//Add panels to the carousel
carousel.add(currPanel);
carousel.add(nextPanel);
carousel.add(prevPanel);
//Watch for beforeChange events. Update the contents of the "next" panel
//before the transition.
carousel.beforeChange = function(currPanel, nextPanel){
nextPanel.innerHTML = "";
};
//Watch for onChange events. Update contents of the "current" panel after
//the transition.
carousel.onChange = function(currPanel, prevPanel){
if (currPanel.getAttribute("panelID")=="nextPanel"){
currID++;
currPanel.setAttribute("panelID", "currPanel");
prevPanel.setAttribute("panelID", "prevPanel");
var panels = carousel.getPanels();
for (var i=0; i<panels.length; i++){
var panel = panels[i];
var div = panel.div;
if (div!=currPanel && div!=prevPanel){
div.setAttribute("panelID", "nextPanel");
}
}
}
else if (currPanel.getAttribute("panelID")=="prevPanel"){
currID--;
currPanel.setAttribute("panelID", "currPanel");
prevPanel.setAttribute("panelID", "nextPanel");
var panels = carousel.getPanels();
for (var i=0; i<panels.length; i++){
var panel = panels[i];
var div = panel.div;
if (div!=currPanel && div!=prevPanel){
div.setAttribute("panelID", "prevPanel");
}
}
}
var div = panelID.cloneNode();
div.innerHTML = currID;
currPanel.innerHTML = "";
currPanel.appendChild(div);
};
document.getElementById("Back3").onclick = function(){
carousel.back();
};
document.getElementById("Next3").onclick = function(){
carousel.next();
};
};
</script>
<script type="text/javascript">
window.onload = function() {
demo1();
demo2();
demo3();
};
</script>
</body>
</html>