jquery_image_gallery 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.idea/workspace.xml +265 -39
- data/app/assets/images/browser-icons.png +0 -0
- data/app/assets/javascripts/jquery_image_gallery.js +2775 -0
- data/app/assets/javascripts/jquery_image_gallery_initializer.js +178 -0
- data/app/assets/javascripts/jquery_image_gallery_main.js +1 -0
- data/app/assets/javascripts/jquery_image_gallery_slider.js +4198 -0
- data/app/assets/stylesheets/jquery_image_gallery.css +36 -0
- data/lib/jquery_image_gallery/version.rb +1 -1
- metadata +8 -2
@@ -0,0 +1,4198 @@
|
|
1
|
+
/*
|
2
|
+
* Jssor.Slider 19.0
|
3
|
+
* http://www.jssor.com/
|
4
|
+
*
|
5
|
+
* Licensed under the MIT license:
|
6
|
+
* http://www.opensource.org/licenses/MIT
|
7
|
+
*
|
8
|
+
* TERMS OF USE - Jssor.Slider
|
9
|
+
*
|
10
|
+
* Copyright 2014 Jssor
|
11
|
+
*
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
13
|
+
* a copy of this software and associated documentation files (the
|
14
|
+
* "Software"), to deal in the Software without restriction, including
|
15
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
16
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
17
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
18
|
+
* the following conditions:
|
19
|
+
*
|
20
|
+
* The above copyright notice and this permission notice shall be
|
21
|
+
* included in all copies or substantial portions of the Software.
|
22
|
+
*
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
27
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
28
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
29
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
30
|
+
*/
|
31
|
+
|
32
|
+
|
33
|
+
var $JssorSlideshowFormations$ = window.$JssorSlideshowFormations$ = new function () {
|
34
|
+
var _This = this;
|
35
|
+
|
36
|
+
//Constants +++++++
|
37
|
+
|
38
|
+
var COLUMN_INCREASE = 0;
|
39
|
+
var COLUMN_DECREASE = 1;
|
40
|
+
var ROW_INCREASE = 2;
|
41
|
+
var ROW_DECREASE = 3;
|
42
|
+
|
43
|
+
var DIRECTION_HORIZONTAL = 0x0003;
|
44
|
+
var DIRECTION_VERTICAL = 0x000C;
|
45
|
+
|
46
|
+
var TO_LEFT = 0x0001;
|
47
|
+
var TO_RIGHT = 0x0002;
|
48
|
+
var TO_TOP = 0x0004;
|
49
|
+
var TO_BOTTOM = 0x0008;
|
50
|
+
|
51
|
+
var FROM_LEFT = 0x0100;
|
52
|
+
var FROM_TOP = 0x0200;
|
53
|
+
var FROM_RIGHT = 0x0400;
|
54
|
+
var FROM_BOTTOM = 0x0800;
|
55
|
+
|
56
|
+
var ASSEMBLY_BOTTOM_LEFT = FROM_BOTTOM + TO_LEFT;
|
57
|
+
var ASSEMBLY_BOTTOM_RIGHT = FROM_BOTTOM + TO_RIGHT;
|
58
|
+
var ASSEMBLY_TOP_LEFT = FROM_TOP + TO_LEFT;
|
59
|
+
var ASSEMBLY_TOP_RIGHT = FROM_TOP + TO_RIGHT;
|
60
|
+
var ASSEMBLY_LEFT_TOP = FROM_LEFT + TO_TOP;
|
61
|
+
var ASSEMBLY_LEFT_BOTTOM = FROM_LEFT + TO_BOTTOM;
|
62
|
+
var ASSEMBLY_RIGHT_TOP = FROM_RIGHT + TO_TOP;
|
63
|
+
var ASSEMBLY_RIGHT_BOTTOM = FROM_RIGHT + TO_BOTTOM;
|
64
|
+
|
65
|
+
//Constants -------
|
66
|
+
|
67
|
+
//Formation Definition +++++++
|
68
|
+
function isToLeft(roadValue) {
|
69
|
+
return (roadValue & TO_LEFT) == TO_LEFT;
|
70
|
+
}
|
71
|
+
|
72
|
+
function isToRight(roadValue) {
|
73
|
+
return (roadValue & TO_RIGHT) == TO_RIGHT;
|
74
|
+
}
|
75
|
+
|
76
|
+
function isToTop(roadValue) {
|
77
|
+
return (roadValue & TO_TOP) == TO_TOP;
|
78
|
+
}
|
79
|
+
|
80
|
+
function isToBottom(roadValue) {
|
81
|
+
return (roadValue & TO_BOTTOM) == TO_BOTTOM;
|
82
|
+
}
|
83
|
+
|
84
|
+
function PushFormationOrder(arr, order, formationItem) {
|
85
|
+
formationItem.push(order);
|
86
|
+
arr[order] = arr[order] || [];
|
87
|
+
arr[order].push(formationItem);
|
88
|
+
}
|
89
|
+
|
90
|
+
_This.$FormationStraight = function (transition) {
|
91
|
+
var cols = transition.$Cols;
|
92
|
+
var rows = transition.$Rows;
|
93
|
+
var formationDirection = transition.$Assembly;
|
94
|
+
var count = transition.$Count;
|
95
|
+
var a = [];
|
96
|
+
var i = 0;
|
97
|
+
var col = 0;
|
98
|
+
var r = 0;
|
99
|
+
var cl = cols - 1;
|
100
|
+
var rl = rows - 1;
|
101
|
+
var il = count - 1;
|
102
|
+
var cr;
|
103
|
+
var order;
|
104
|
+
for (r = 0; r < rows; r++) {
|
105
|
+
for (col = 0; col < cols; col++) {
|
106
|
+
cr = r + ',' + col;
|
107
|
+
switch (formationDirection) {
|
108
|
+
case ASSEMBLY_BOTTOM_LEFT:
|
109
|
+
order = il - (col * rows + (rl - r));
|
110
|
+
break;
|
111
|
+
case ASSEMBLY_RIGHT_TOP:
|
112
|
+
order = il - (r * cols + (cl - col));
|
113
|
+
break;
|
114
|
+
case ASSEMBLY_TOP_LEFT:
|
115
|
+
order = il - (col * rows + r);
|
116
|
+
case ASSEMBLY_LEFT_TOP:
|
117
|
+
order = il - (r * cols + col);
|
118
|
+
break;
|
119
|
+
case ASSEMBLY_BOTTOM_RIGHT:
|
120
|
+
order = col * rows + r;
|
121
|
+
break;
|
122
|
+
case ASSEMBLY_LEFT_BOTTOM:
|
123
|
+
order = r * cols + (cl - col);
|
124
|
+
break;
|
125
|
+
case ASSEMBLY_TOP_RIGHT:
|
126
|
+
order = col * rows + (rl - r);
|
127
|
+
break;
|
128
|
+
default:
|
129
|
+
order = r * cols + col;
|
130
|
+
break; //ASSEMBLY_RIGHT_BOTTOM
|
131
|
+
}
|
132
|
+
PushFormationOrder(a, order, [r, col]);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
return a;
|
137
|
+
};
|
138
|
+
|
139
|
+
_This.$FormationSwirl = function (transition) {
|
140
|
+
var cols = transition.$Cols;
|
141
|
+
var rows = transition.$Rows;
|
142
|
+
var formationDirection = transition.$Assembly;
|
143
|
+
var count = transition.$Count;
|
144
|
+
var a = [];
|
145
|
+
var hit = [];
|
146
|
+
var i = 0;
|
147
|
+
var col = 0;
|
148
|
+
var r = 0;
|
149
|
+
var cl = cols - 1;
|
150
|
+
var rl = rows - 1;
|
151
|
+
var il = count - 1;
|
152
|
+
var cr;
|
153
|
+
var courses;
|
154
|
+
var course = 0;
|
155
|
+
switch (formationDirection) {
|
156
|
+
case ASSEMBLY_BOTTOM_LEFT:
|
157
|
+
col = cl;
|
158
|
+
r = 0;
|
159
|
+
courses = [ROW_INCREASE, COLUMN_DECREASE, ROW_DECREASE, COLUMN_INCREASE];
|
160
|
+
break;
|
161
|
+
case ASSEMBLY_RIGHT_TOP:
|
162
|
+
col = 0;
|
163
|
+
r = rl;
|
164
|
+
courses = [COLUMN_INCREASE, ROW_DECREASE, COLUMN_DECREASE, ROW_INCREASE];
|
165
|
+
break;
|
166
|
+
case ASSEMBLY_TOP_LEFT:
|
167
|
+
col = cl;
|
168
|
+
r = rl;
|
169
|
+
courses = [ROW_DECREASE, COLUMN_DECREASE, ROW_INCREASE, COLUMN_INCREASE];
|
170
|
+
break;
|
171
|
+
case ASSEMBLY_LEFT_TOP:
|
172
|
+
col = cl;
|
173
|
+
r = rl;
|
174
|
+
courses = [COLUMN_DECREASE, ROW_DECREASE, COLUMN_INCREASE, ROW_INCREASE];
|
175
|
+
break;
|
176
|
+
case ASSEMBLY_BOTTOM_RIGHT:
|
177
|
+
col = 0;
|
178
|
+
r = 0;
|
179
|
+
courses = [ROW_INCREASE, COLUMN_INCREASE, ROW_DECREASE, COLUMN_DECREASE];
|
180
|
+
break;
|
181
|
+
case ASSEMBLY_LEFT_BOTTOM:
|
182
|
+
col = cl;
|
183
|
+
r = 0;
|
184
|
+
courses = [COLUMN_DECREASE, ROW_INCREASE, COLUMN_INCREASE, ROW_DECREASE];
|
185
|
+
break;
|
186
|
+
case ASSEMBLY_TOP_RIGHT:
|
187
|
+
col = 0;
|
188
|
+
r = rl;
|
189
|
+
courses = [ROW_DECREASE, COLUMN_INCREASE, ROW_INCREASE, COLUMN_DECREASE];
|
190
|
+
break;
|
191
|
+
default:
|
192
|
+
col = 0;
|
193
|
+
r = 0;
|
194
|
+
courses = [COLUMN_INCREASE, ROW_INCREASE, COLUMN_DECREASE, ROW_DECREASE];
|
195
|
+
break; //ASSEMBLY_RIGHT_BOTTOM
|
196
|
+
}
|
197
|
+
i = 0;
|
198
|
+
while (i < count) {
|
199
|
+
cr = r + ',' + col;
|
200
|
+
if (col >= 0 && col < cols && r >= 0 && r < rows && !hit[cr]) {
|
201
|
+
//a[cr] = i++;
|
202
|
+
hit[cr] = true;
|
203
|
+
PushFormationOrder(a, i++, [r, col]);
|
204
|
+
}
|
205
|
+
else {
|
206
|
+
switch (courses[course++ % courses.length]) {
|
207
|
+
case COLUMN_INCREASE:
|
208
|
+
col--;
|
209
|
+
break;
|
210
|
+
case ROW_INCREASE:
|
211
|
+
r--;
|
212
|
+
break;
|
213
|
+
case COLUMN_DECREASE:
|
214
|
+
col++;
|
215
|
+
break;
|
216
|
+
case ROW_DECREASE:
|
217
|
+
r++;
|
218
|
+
break;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
switch (courses[course % courses.length]) {
|
223
|
+
case COLUMN_INCREASE:
|
224
|
+
col++;
|
225
|
+
break;
|
226
|
+
case ROW_INCREASE:
|
227
|
+
r++;
|
228
|
+
break;
|
229
|
+
case COLUMN_DECREASE:
|
230
|
+
col--;
|
231
|
+
break;
|
232
|
+
case ROW_DECREASE:
|
233
|
+
r--;
|
234
|
+
break;
|
235
|
+
}
|
236
|
+
}
|
237
|
+
return a;
|
238
|
+
};
|
239
|
+
|
240
|
+
_This.$FormationZigZag = function (transition) {
|
241
|
+
var cols = transition.$Cols;
|
242
|
+
var rows = transition.$Rows;
|
243
|
+
var formationDirection = transition.$Assembly;
|
244
|
+
var count = transition.$Count;
|
245
|
+
var a = [];
|
246
|
+
var i = 0;
|
247
|
+
var col = 0;
|
248
|
+
var r = 0;
|
249
|
+
var cl = cols - 1;
|
250
|
+
var rl = rows - 1;
|
251
|
+
var il = count - 1;
|
252
|
+
var cr;
|
253
|
+
var courses;
|
254
|
+
var course = 0;
|
255
|
+
switch (formationDirection) {
|
256
|
+
case ASSEMBLY_BOTTOM_LEFT:
|
257
|
+
col = cl;
|
258
|
+
r = 0;
|
259
|
+
courses = [ROW_INCREASE, COLUMN_DECREASE, ROW_DECREASE, COLUMN_DECREASE];
|
260
|
+
break;
|
261
|
+
case ASSEMBLY_RIGHT_TOP:
|
262
|
+
col = 0;
|
263
|
+
r = rl;
|
264
|
+
courses = [COLUMN_INCREASE, ROW_DECREASE, COLUMN_DECREASE, ROW_DECREASE];
|
265
|
+
break;
|
266
|
+
case ASSEMBLY_TOP_LEFT:
|
267
|
+
col = cl;
|
268
|
+
r = rl;
|
269
|
+
courses = [ROW_DECREASE, COLUMN_DECREASE, ROW_INCREASE, COLUMN_DECREASE];
|
270
|
+
break;
|
271
|
+
case ASSEMBLY_LEFT_TOP:
|
272
|
+
col = cl;
|
273
|
+
r = rl;
|
274
|
+
courses = [COLUMN_DECREASE, ROW_DECREASE, COLUMN_INCREASE, ROW_DECREASE];
|
275
|
+
break;
|
276
|
+
case ASSEMBLY_BOTTOM_RIGHT:
|
277
|
+
col = 0;
|
278
|
+
r = 0;
|
279
|
+
courses = [ROW_INCREASE, COLUMN_INCREASE, ROW_DECREASE, COLUMN_INCREASE];
|
280
|
+
break;
|
281
|
+
case ASSEMBLY_LEFT_BOTTOM:
|
282
|
+
col = cl;
|
283
|
+
r = 0;
|
284
|
+
courses = [COLUMN_DECREASE, ROW_INCREASE, COLUMN_INCREASE, ROW_INCREASE];
|
285
|
+
break;
|
286
|
+
case ASSEMBLY_TOP_RIGHT:
|
287
|
+
col = 0;
|
288
|
+
r = rl;
|
289
|
+
courses = [ROW_DECREASE, COLUMN_INCREASE, ROW_INCREASE, COLUMN_INCREASE];
|
290
|
+
break;
|
291
|
+
default:
|
292
|
+
col = 0;
|
293
|
+
r = 0;
|
294
|
+
courses = [COLUMN_INCREASE, ROW_INCREASE, COLUMN_DECREASE, ROW_INCREASE];
|
295
|
+
break; //ASSEMBLY_RIGHT_BOTTOM
|
296
|
+
}
|
297
|
+
i = 0;
|
298
|
+
while (i < count) {
|
299
|
+
cr = r + ',' + col;
|
300
|
+
if (col >= 0 && col < cols && r >= 0 && r < rows && typeof (a[cr]) == 'undefined') {
|
301
|
+
PushFormationOrder(a, i++, [r, col]);
|
302
|
+
//a[cr] = i++;
|
303
|
+
switch (courses[course % courses.length]) {
|
304
|
+
case COLUMN_INCREASE:
|
305
|
+
col++;
|
306
|
+
break;
|
307
|
+
case ROW_INCREASE:
|
308
|
+
r++;
|
309
|
+
break;
|
310
|
+
case COLUMN_DECREASE:
|
311
|
+
col--;
|
312
|
+
break;
|
313
|
+
case ROW_DECREASE:
|
314
|
+
r--;
|
315
|
+
break;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
else {
|
319
|
+
switch (courses[course++ % courses.length]) {
|
320
|
+
case COLUMN_INCREASE:
|
321
|
+
col--;
|
322
|
+
break;
|
323
|
+
case ROW_INCREASE:
|
324
|
+
r--;
|
325
|
+
break;
|
326
|
+
case COLUMN_DECREASE:
|
327
|
+
col++;
|
328
|
+
break;
|
329
|
+
case ROW_DECREASE:
|
330
|
+
r++;
|
331
|
+
break;
|
332
|
+
}
|
333
|
+
switch (courses[course++ % courses.length]) {
|
334
|
+
case COLUMN_INCREASE:
|
335
|
+
col++;
|
336
|
+
break;
|
337
|
+
case ROW_INCREASE:
|
338
|
+
r++;
|
339
|
+
break;
|
340
|
+
case COLUMN_DECREASE:
|
341
|
+
col--;
|
342
|
+
break;
|
343
|
+
case ROW_DECREASE:
|
344
|
+
r--;
|
345
|
+
break;
|
346
|
+
}
|
347
|
+
}
|
348
|
+
}
|
349
|
+
return a;
|
350
|
+
};
|
351
|
+
|
352
|
+
_This.$FormationStraightStairs = function (transition) {
|
353
|
+
var cols = transition.$Cols;
|
354
|
+
var rows = transition.$Rows;
|
355
|
+
var formationDirection = transition.$Assembly;
|
356
|
+
var count = transition.$Count;
|
357
|
+
var a = [];
|
358
|
+
var i = 0;
|
359
|
+
var col = 0;
|
360
|
+
var r = 0;
|
361
|
+
var cl = cols - 1;
|
362
|
+
var rl = rows - 1;
|
363
|
+
var il = count - 1;
|
364
|
+
var cr;
|
365
|
+
switch (formationDirection) {
|
366
|
+
case ASSEMBLY_BOTTOM_LEFT:
|
367
|
+
case ASSEMBLY_TOP_RIGHT:
|
368
|
+
case ASSEMBLY_TOP_LEFT:
|
369
|
+
case ASSEMBLY_BOTTOM_RIGHT:
|
370
|
+
var C = 0;
|
371
|
+
var R = 0;
|
372
|
+
break;
|
373
|
+
case ASSEMBLY_LEFT_BOTTOM:
|
374
|
+
case ASSEMBLY_RIGHT_TOP:
|
375
|
+
case ASSEMBLY_LEFT_TOP:
|
376
|
+
case ASSEMBLY_RIGHT_BOTTOM:
|
377
|
+
var C = cl;
|
378
|
+
var R = 0;
|
379
|
+
break;
|
380
|
+
default:
|
381
|
+
formationDirection = ASSEMBLY_RIGHT_BOTTOM;
|
382
|
+
var C = cl;
|
383
|
+
var R = 0;
|
384
|
+
break;
|
385
|
+
}
|
386
|
+
col = C;
|
387
|
+
r = R;
|
388
|
+
while (i < count) {
|
389
|
+
cr = r + ',' + col;
|
390
|
+
if (isToTop(formationDirection) || isToRight(formationDirection)) {
|
391
|
+
PushFormationOrder(a, il - i++, [r, col]);
|
392
|
+
//a[cr] = il - i++;
|
393
|
+
}
|
394
|
+
else {
|
395
|
+
PushFormationOrder(a, i++, [r, col]);
|
396
|
+
//a[cr] = i++;
|
397
|
+
}
|
398
|
+
switch (formationDirection) {
|
399
|
+
case ASSEMBLY_BOTTOM_LEFT:
|
400
|
+
case ASSEMBLY_TOP_RIGHT:
|
401
|
+
col--;
|
402
|
+
r++;
|
403
|
+
break;
|
404
|
+
case ASSEMBLY_TOP_LEFT:
|
405
|
+
case ASSEMBLY_BOTTOM_RIGHT:
|
406
|
+
col++;
|
407
|
+
r--;
|
408
|
+
break;
|
409
|
+
case ASSEMBLY_LEFT_BOTTOM:
|
410
|
+
case ASSEMBLY_RIGHT_TOP:
|
411
|
+
col--;
|
412
|
+
r--;
|
413
|
+
break;
|
414
|
+
case ASSEMBLY_RIGHT_BOTTOM:
|
415
|
+
case ASSEMBLY_LEFT_TOP:
|
416
|
+
default:
|
417
|
+
col++;
|
418
|
+
r++;
|
419
|
+
break;
|
420
|
+
}
|
421
|
+
if (col < 0 || r < 0 || col > cl || r > rl) {
|
422
|
+
switch (formationDirection) {
|
423
|
+
case ASSEMBLY_BOTTOM_LEFT:
|
424
|
+
case ASSEMBLY_TOP_RIGHT:
|
425
|
+
C++;
|
426
|
+
break;
|
427
|
+
case ASSEMBLY_LEFT_BOTTOM:
|
428
|
+
case ASSEMBLY_RIGHT_TOP:
|
429
|
+
case ASSEMBLY_TOP_LEFT:
|
430
|
+
case ASSEMBLY_BOTTOM_RIGHT:
|
431
|
+
R++;
|
432
|
+
break;
|
433
|
+
case ASSEMBLY_RIGHT_BOTTOM:
|
434
|
+
case ASSEMBLY_LEFT_TOP:
|
435
|
+
default:
|
436
|
+
C--;
|
437
|
+
break;
|
438
|
+
}
|
439
|
+
if (C < 0 || R < 0 || C > cl || R > rl) {
|
440
|
+
switch (formationDirection) {
|
441
|
+
case ASSEMBLY_BOTTOM_LEFT:
|
442
|
+
case ASSEMBLY_TOP_RIGHT:
|
443
|
+
C = cl;
|
444
|
+
R++;
|
445
|
+
break;
|
446
|
+
case ASSEMBLY_TOP_LEFT:
|
447
|
+
case ASSEMBLY_BOTTOM_RIGHT:
|
448
|
+
R = rl;
|
449
|
+
C++;
|
450
|
+
break;
|
451
|
+
case ASSEMBLY_LEFT_BOTTOM:
|
452
|
+
case ASSEMBLY_RIGHT_TOP: R = rl; C--;
|
453
|
+
break;
|
454
|
+
case ASSEMBLY_RIGHT_BOTTOM:
|
455
|
+
case ASSEMBLY_LEFT_TOP:
|
456
|
+
default:
|
457
|
+
C = 0;
|
458
|
+
R++;
|
459
|
+
break;
|
460
|
+
}
|
461
|
+
if (R > rl)
|
462
|
+
R = rl;
|
463
|
+
else if (R < 0)
|
464
|
+
R = 0;
|
465
|
+
else if (C > cl)
|
466
|
+
C = cl;
|
467
|
+
else if (C < 0)
|
468
|
+
C = 0;
|
469
|
+
}
|
470
|
+
r = R;
|
471
|
+
col = C;
|
472
|
+
}
|
473
|
+
}
|
474
|
+
return a;
|
475
|
+
};
|
476
|
+
|
477
|
+
_This.$FormationSquare = function (transition) {
|
478
|
+
var cols = transition.$Cols || 1;
|
479
|
+
var rows = transition.$Rows || 1;
|
480
|
+
var arr = [];
|
481
|
+
var i = 0;
|
482
|
+
var col;
|
483
|
+
var r;
|
484
|
+
var dc;
|
485
|
+
var dr;
|
486
|
+
var cr;
|
487
|
+
dc = cols < rows ? (rows - cols) / 2 : 0;
|
488
|
+
dr = cols > rows ? (cols - rows) / 2 : 0;
|
489
|
+
cr = Math.round(Math.max(cols / 2, rows / 2)) + 1;
|
490
|
+
for (col = 0; col < cols; col++) {
|
491
|
+
for (r = 0; r < rows; r++)
|
492
|
+
PushFormationOrder(arr, cr - Math.min(col + 1 + dc, r + 1 + dr, cols - col + dc, rows - r + dr), [r, col]);
|
493
|
+
}
|
494
|
+
return arr;
|
495
|
+
};
|
496
|
+
|
497
|
+
_This.$FormationRectangle = function (transition) {
|
498
|
+
var cols = transition.$Cols || 1;
|
499
|
+
var rows = transition.$Rows || 1;
|
500
|
+
var arr = [];
|
501
|
+
var i = 0;
|
502
|
+
var col;
|
503
|
+
var r;
|
504
|
+
var cr;
|
505
|
+
cr = Math.round(Math.min(cols / 2, rows / 2)) + 1;
|
506
|
+
for (col = 0; col < cols; col++) {
|
507
|
+
for (r = 0; r < rows; r++)
|
508
|
+
PushFormationOrder(arr, cr - Math.min(col + 1, r + 1, cols - col, rows - r), [r, col]);
|
509
|
+
}
|
510
|
+
return arr;
|
511
|
+
};
|
512
|
+
|
513
|
+
_This.$FormationRandom = function (transition) {
|
514
|
+
var a = [];
|
515
|
+
var r, col, i;
|
516
|
+
for (r = 0; r < transition.$Rows; r++) {
|
517
|
+
for (col = 0; col < transition.$Cols; col++)
|
518
|
+
PushFormationOrder(a, Math.ceil(100000 * Math.random()) % 13, [r, col]);
|
519
|
+
}
|
520
|
+
|
521
|
+
return a;
|
522
|
+
};
|
523
|
+
|
524
|
+
_This.$FormationCircle = function (transition) {
|
525
|
+
var cols = transition.$Cols || 1;
|
526
|
+
var rows = transition.$Rows || 1;
|
527
|
+
var arr = [];
|
528
|
+
var i = 0;
|
529
|
+
var col;
|
530
|
+
var r;
|
531
|
+
var hc = cols / 2 - 0.5;
|
532
|
+
var hr = rows / 2 - 0.5;
|
533
|
+
for (col = 0; col < cols; col++) {
|
534
|
+
for (r = 0; r < rows; r++)
|
535
|
+
PushFormationOrder(arr, Math.round(Math.sqrt(Math.pow(col - hc, 2) + Math.pow(r - hr, 2))), [r, col]);
|
536
|
+
}
|
537
|
+
return arr;
|
538
|
+
};
|
539
|
+
|
540
|
+
_This.$FormationCross = function (transition) {
|
541
|
+
var cols = transition.$Cols || 1;
|
542
|
+
var rows = transition.$Rows || 1;
|
543
|
+
var arr = [];
|
544
|
+
var i = 0;
|
545
|
+
var col;
|
546
|
+
var r;
|
547
|
+
var hc = cols / 2 - 0.5;
|
548
|
+
var hr = rows / 2 - 0.5;
|
549
|
+
for (col = 0; col < cols; col++) {
|
550
|
+
for (r = 0; r < rows; r++)
|
551
|
+
PushFormationOrder(arr, Math.round(Math.min(Math.abs(col - hc), Math.abs(r - hr))), [r, col]);
|
552
|
+
}
|
553
|
+
return arr;
|
554
|
+
};
|
555
|
+
|
556
|
+
_This.$FormationRectangleCross = function (transition) {
|
557
|
+
var cols = transition.$Cols || 1;
|
558
|
+
var rows = transition.$Rows || 1;
|
559
|
+
var arr = [];
|
560
|
+
var i = 0;
|
561
|
+
var col;
|
562
|
+
var r;
|
563
|
+
var hc = cols / 2 - 0.5;
|
564
|
+
var hr = rows / 2 - 0.5;
|
565
|
+
var cr = Math.max(hc, hr) + 1;
|
566
|
+
for (col = 0; col < cols; col++) {
|
567
|
+
for (r = 0; r < rows; r++)
|
568
|
+
PushFormationOrder(arr, Math.round(cr - Math.max(hc - Math.abs(col - hc), hr - Math.abs(r - hr))) - 1, [r, col]);
|
569
|
+
}
|
570
|
+
return arr;
|
571
|
+
};
|
572
|
+
};
|
573
|
+
|
574
|
+
var $JssorSlideshowRunner$ = window.$JssorSlideshowRunner$ = function (slideContainer, slideContainerWidth, slideContainerHeight, slideshowOptions, isTouchDevice) {
|
575
|
+
|
576
|
+
var _SelfSlideshowRunner = this;
|
577
|
+
|
578
|
+
//var _State = 0; //-1 fullfill, 0 clean, 1 initializing, 2 stay, 3 playing
|
579
|
+
var _EndTime;
|
580
|
+
|
581
|
+
var _SliderFrameCount;
|
582
|
+
|
583
|
+
var _SlideshowPlayerBelow;
|
584
|
+
var _SlideshowPlayerAbove;
|
585
|
+
|
586
|
+
var _PrevItem;
|
587
|
+
var _SlideItem;
|
588
|
+
|
589
|
+
var _TransitionIndex = 0;
|
590
|
+
var _TransitionsOrder = slideshowOptions.$TransitionsOrder;
|
591
|
+
|
592
|
+
var _SlideshowTransition;
|
593
|
+
|
594
|
+
var _SlideshowPerformance = 8;
|
595
|
+
|
596
|
+
//#region Private Methods
|
597
|
+
function EnsureTransitionInstance(options, slideshowInterval) {
|
598
|
+
|
599
|
+
var slideshowTransition = {
|
600
|
+
$Interval: slideshowInterval, //Delay to play next frame
|
601
|
+
$Duration: 1, //Duration to finish the entire transition
|
602
|
+
$Delay: 0, //Delay to assembly blocks
|
603
|
+
$Cols: 1, //Number of columns
|
604
|
+
$Rows: 1, //Number of rows
|
605
|
+
$Opacity: 0, //Fade block or not
|
606
|
+
$Zoom: 0, //Zoom block or not
|
607
|
+
$Clip: 0, //Clip block or not
|
608
|
+
$Move: false, //Move block or not
|
609
|
+
$SlideOut: false, //Slide the previous slide out to display next slide instead
|
610
|
+
//$FlyDirection: 0, //Specify fly transform with direction
|
611
|
+
$Reverse: false, //Reverse the assembly or not
|
612
|
+
$Formation: $JssorSlideshowFormations$.$FormationRandom, //Shape that assembly blocks as
|
613
|
+
$Assembly: 0x0408, //The way to assembly blocks ASSEMBLY_RIGHT_BOTTOM
|
614
|
+
$ChessMode: { $Column: 0, $Row: 0 }, //Chess move or fly direction
|
615
|
+
$Easing: $JssorEasing$.$EaseSwing, //Specify variation of speed during transition
|
616
|
+
$Round: {},
|
617
|
+
$Blocks: [],
|
618
|
+
$During: {}
|
619
|
+
};
|
620
|
+
|
621
|
+
$Jssor$.$Extend(slideshowTransition, options);
|
622
|
+
|
623
|
+
slideshowTransition.$Count = slideshowTransition.$Cols * slideshowTransition.$Rows;
|
624
|
+
if ($Jssor$.$IsFunction(slideshowTransition.$Easing))
|
625
|
+
slideshowTransition.$Easing = { $Default: slideshowTransition.$Easing };
|
626
|
+
|
627
|
+
slideshowTransition.$FramesCount = Math.ceil(slideshowTransition.$Duration / slideshowTransition.$Interval);
|
628
|
+
|
629
|
+
slideshowTransition.$GetBlocks = function (width, height) {
|
630
|
+
width /= slideshowTransition.$Cols;
|
631
|
+
height /= slideshowTransition.$Rows;
|
632
|
+
var wh = width + 'x' + height;
|
633
|
+
if (!slideshowTransition.$Blocks[wh]) {
|
634
|
+
slideshowTransition.$Blocks[wh] = { $Width: width, $Height: height };
|
635
|
+
for (var col = 0; col < slideshowTransition.$Cols; col++) {
|
636
|
+
for (var r = 0; r < slideshowTransition.$Rows; r++)
|
637
|
+
slideshowTransition.$Blocks[wh][r + ',' + col] = { $Top: r * height, $Right: col * width + width, $Bottom: r * height + height, $Left: col * width };
|
638
|
+
}
|
639
|
+
}
|
640
|
+
|
641
|
+
return slideshowTransition.$Blocks[wh];
|
642
|
+
};
|
643
|
+
|
644
|
+
if (slideshowTransition.$Brother) {
|
645
|
+
slideshowTransition.$Brother = EnsureTransitionInstance(slideshowTransition.$Brother, slideshowInterval);
|
646
|
+
slideshowTransition.$SlideOut = true;
|
647
|
+
}
|
648
|
+
|
649
|
+
return slideshowTransition;
|
650
|
+
}
|
651
|
+
//#endregion
|
652
|
+
|
653
|
+
//#region Private Classes
|
654
|
+
function JssorSlideshowPlayer(slideContainer, slideElement, slideTransition, beginTime, slideContainerWidth, slideContainerHeight) {
|
655
|
+
var _Self = this;
|
656
|
+
|
657
|
+
var _Block;
|
658
|
+
var _StartStylesArr = {};
|
659
|
+
var _AnimationStylesArrs = {};
|
660
|
+
var _AnimationBlockItems = [];
|
661
|
+
var _StyleStart;
|
662
|
+
var _StyleEnd;
|
663
|
+
var _StyleDif;
|
664
|
+
var _ChessModeColumn = slideTransition.$ChessMode.$Column || 0;
|
665
|
+
var _ChessModeRow = slideTransition.$ChessMode.$Row || 0;
|
666
|
+
|
667
|
+
var _Blocks = slideTransition.$GetBlocks(slideContainerWidth, slideContainerHeight);
|
668
|
+
var _FormationInstance = GetFormation(slideTransition);
|
669
|
+
var _MaxOrder = _FormationInstance.length - 1;
|
670
|
+
var _Period = slideTransition.$Duration + slideTransition.$Delay * _MaxOrder;
|
671
|
+
var _EndTime = beginTime + _Period;
|
672
|
+
|
673
|
+
var _SlideOut = slideTransition.$SlideOut;
|
674
|
+
var _IsIn;
|
675
|
+
|
676
|
+
//_EndTime += $Jssor$.$IsBrowserChrome() ? 260 : 50;
|
677
|
+
_EndTime += 50;
|
678
|
+
|
679
|
+
//#region Private Methods
|
680
|
+
|
681
|
+
function GetFormation(transition) {
|
682
|
+
|
683
|
+
var formationInstance = transition.$Formation(transition);
|
684
|
+
|
685
|
+
return transition.$Reverse ? formationInstance.reverse() : formationInstance;
|
686
|
+
|
687
|
+
}
|
688
|
+
//#endregion
|
689
|
+
|
690
|
+
_Self.$EndTime = _EndTime;
|
691
|
+
|
692
|
+
_Self.$ShowFrame = function (time) {
|
693
|
+
time -= beginTime;
|
694
|
+
|
695
|
+
var isIn = time < _Period;
|
696
|
+
|
697
|
+
if (isIn || _IsIn) {
|
698
|
+
_IsIn = isIn;
|
699
|
+
|
700
|
+
if (!_SlideOut)
|
701
|
+
time = _Period - time;
|
702
|
+
|
703
|
+
var frameIndex = Math.ceil(time / slideTransition.$Interval);
|
704
|
+
|
705
|
+
$Jssor$.$Each(_AnimationStylesArrs, function (value, index) {
|
706
|
+
|
707
|
+
var itemFrameIndex = Math.max(frameIndex, value.$Min);
|
708
|
+
itemFrameIndex = Math.min(itemFrameIndex, value.length - 1);
|
709
|
+
|
710
|
+
if (value.$LastFrameIndex != itemFrameIndex) {
|
711
|
+
if (!value.$LastFrameIndex && !_SlideOut) {
|
712
|
+
$Jssor$.$ShowElement(_AnimationBlockItems[index]);
|
713
|
+
}
|
714
|
+
else if (itemFrameIndex == value.$Max && _SlideOut) {
|
715
|
+
$Jssor$.$HideElement(_AnimationBlockItems[index]);
|
716
|
+
}
|
717
|
+
value.$LastFrameIndex = itemFrameIndex;
|
718
|
+
$Jssor$.$SetStylesEx(_AnimationBlockItems[index], value[itemFrameIndex]);
|
719
|
+
}
|
720
|
+
});
|
721
|
+
}
|
722
|
+
};
|
723
|
+
|
724
|
+
//constructor
|
725
|
+
{
|
726
|
+
slideElement = $Jssor$.$CloneNode(slideElement);
|
727
|
+
//$Jssor$.$RemoveAttribute(slideElement, "id");
|
728
|
+
if ($Jssor$.$IsBrowserIe9Earlier()) {
|
729
|
+
var hasImage = !slideElement["no-image"];
|
730
|
+
var slideChildElements = $Jssor$.$FindChildrenByTag(slideElement);
|
731
|
+
$Jssor$.$Each(slideChildElements, function (slideChildElement) {
|
732
|
+
if (hasImage || slideChildElement["jssor-slider"])
|
733
|
+
$Jssor$.$CssOpacity(slideChildElement, $Jssor$.$CssOpacity(slideChildElement), true);
|
734
|
+
});
|
735
|
+
}
|
736
|
+
|
737
|
+
$Jssor$.$Each(_FormationInstance, function (formationItems, order) {
|
738
|
+
$Jssor$.$Each(formationItems, function (formationItem) {
|
739
|
+
var row = formationItem[0];
|
740
|
+
var col = formationItem[1];
|
741
|
+
{
|
742
|
+
var columnRow = row + ',' + col;
|
743
|
+
|
744
|
+
var chessHorizontal = false;
|
745
|
+
var chessVertical = false;
|
746
|
+
var chessRotate = false;
|
747
|
+
|
748
|
+
if (_ChessModeColumn && col % 2) {
|
749
|
+
if (_ChessModeColumn & 3/*$JssorDirection$.$IsHorizontal(_ChessModeColumn)*/) {
|
750
|
+
chessHorizontal = !chessHorizontal;
|
751
|
+
}
|
752
|
+
if (_ChessModeColumn & 12/*$JssorDirection$.$IsVertical(_ChessModeColumn)*/) {
|
753
|
+
chessVertical = !chessVertical;
|
754
|
+
}
|
755
|
+
|
756
|
+
if (_ChessModeColumn & 16)
|
757
|
+
chessRotate = !chessRotate;
|
758
|
+
}
|
759
|
+
|
760
|
+
if (_ChessModeRow && row % 2) {
|
761
|
+
if (_ChessModeRow & 3/*$JssorDirection$.$IsHorizontal(_ChessModeRow)*/) {
|
762
|
+
chessHorizontal = !chessHorizontal;
|
763
|
+
}
|
764
|
+
if (_ChessModeRow & 12/*$JssorDirection$.$IsVertical(_ChessModeRow)*/) {
|
765
|
+
chessVertical = !chessVertical;
|
766
|
+
}
|
767
|
+
if (_ChessModeRow & 16)
|
768
|
+
chessRotate = !chessRotate;
|
769
|
+
}
|
770
|
+
|
771
|
+
slideTransition.$Top = slideTransition.$Top || (slideTransition.$Clip & 4);
|
772
|
+
slideTransition.$Bottom = slideTransition.$Bottom || (slideTransition.$Clip & 8);
|
773
|
+
slideTransition.$Left = slideTransition.$Left || (slideTransition.$Clip & 1);
|
774
|
+
slideTransition.$Right = slideTransition.$Right || (slideTransition.$Clip & 2);
|
775
|
+
|
776
|
+
var topBenchmark = chessVertical ? slideTransition.$Bottom : slideTransition.$Top;
|
777
|
+
var bottomBenchmark = chessVertical ? slideTransition.$Top : slideTransition.$Bottom;
|
778
|
+
var leftBenchmark = chessHorizontal ? slideTransition.$Right : slideTransition.$Left;
|
779
|
+
var rightBenchmark = chessHorizontal ? slideTransition.$Left : slideTransition.$Right;
|
780
|
+
|
781
|
+
slideTransition.$Clip = topBenchmark || bottomBenchmark || leftBenchmark || rightBenchmark;
|
782
|
+
|
783
|
+
_StyleDif = {};
|
784
|
+
_StyleEnd = { $Top: 0, $Left: 0, $Opacity: 1, $Width: slideContainerWidth, $Height: slideContainerHeight };
|
785
|
+
_StyleStart = $Jssor$.$Extend({}, _StyleEnd);
|
786
|
+
_Block = $Jssor$.$Extend({}, _Blocks[columnRow]);
|
787
|
+
|
788
|
+
if (slideTransition.$Opacity) {
|
789
|
+
_StyleEnd.$Opacity = 2 - slideTransition.$Opacity;
|
790
|
+
}
|
791
|
+
|
792
|
+
if (slideTransition.$ZIndex) {
|
793
|
+
_StyleEnd.$ZIndex = slideTransition.$ZIndex;
|
794
|
+
_StyleStart.$ZIndex = 0;
|
795
|
+
}
|
796
|
+
|
797
|
+
var allowClip = slideTransition.$Cols * slideTransition.$Rows > 1 || slideTransition.$Clip;
|
798
|
+
|
799
|
+
if (slideTransition.$Zoom || slideTransition.$Rotate) {
|
800
|
+
var allowRotate = true;
|
801
|
+
if ($Jssor$.$IsBrowserIe9Earlier()) {
|
802
|
+
if (slideTransition.$Cols * slideTransition.$Rows > 1)
|
803
|
+
allowRotate = false;
|
804
|
+
else
|
805
|
+
allowClip = false;
|
806
|
+
}
|
807
|
+
|
808
|
+
if (allowRotate) {
|
809
|
+
_StyleEnd.$Zoom = slideTransition.$Zoom ? slideTransition.$Zoom - 1 : 1;
|
810
|
+
_StyleStart.$Zoom = 1;
|
811
|
+
|
812
|
+
if ($Jssor$.$IsBrowserIe9Earlier() || $Jssor$.$IsBrowserOpera())
|
813
|
+
_StyleEnd.$Zoom = Math.min(_StyleEnd.$Zoom, 2);
|
814
|
+
|
815
|
+
var rotate = slideTransition.$Rotate;
|
816
|
+
|
817
|
+
_StyleEnd.$Rotate = rotate * 360 * ((chessRotate) ? -1 : 1);
|
818
|
+
_StyleStart.$Rotate = 0;
|
819
|
+
}
|
820
|
+
}
|
821
|
+
|
822
|
+
if (allowClip) {
|
823
|
+
if (slideTransition.$Clip) {
|
824
|
+
var clipScale = slideTransition.$ScaleClip || 1;
|
825
|
+
var blockOffset = _Block.$Offset = {};
|
826
|
+
if (topBenchmark && bottomBenchmark) {
|
827
|
+
blockOffset.$Top = _Blocks.$Height / 2 * clipScale;
|
828
|
+
blockOffset.$Bottom = -blockOffset.$Top;
|
829
|
+
}
|
830
|
+
else if (topBenchmark) {
|
831
|
+
blockOffset.$Bottom = -_Blocks.$Height * clipScale;
|
832
|
+
}
|
833
|
+
else if (bottomBenchmark) {
|
834
|
+
blockOffset.$Top = _Blocks.$Height * clipScale;
|
835
|
+
}
|
836
|
+
|
837
|
+
if (leftBenchmark && rightBenchmark) {
|
838
|
+
blockOffset.$Left = _Blocks.$Width / 2 * clipScale;
|
839
|
+
blockOffset.$Right = -blockOffset.$Left;
|
840
|
+
}
|
841
|
+
else if (leftBenchmark) {
|
842
|
+
blockOffset.$Right = -_Blocks.$Width * clipScale;
|
843
|
+
}
|
844
|
+
else if (rightBenchmark) {
|
845
|
+
blockOffset.$Left = _Blocks.$Width * clipScale;
|
846
|
+
}
|
847
|
+
}
|
848
|
+
|
849
|
+
_StyleDif.$Clip = _Block;
|
850
|
+
_StyleStart.$Clip = _Blocks[columnRow];
|
851
|
+
}
|
852
|
+
|
853
|
+
//fly
|
854
|
+
{
|
855
|
+
var chessHor = chessHorizontal ? 1 : -1;
|
856
|
+
var chessVer = chessVertical ? 1 : -1;
|
857
|
+
|
858
|
+
if (slideTransition.x)
|
859
|
+
_StyleEnd.$Left += slideContainerWidth * slideTransition.x * chessHor;
|
860
|
+
|
861
|
+
if (slideTransition.y)
|
862
|
+
_StyleEnd.$Top += slideContainerHeight * slideTransition.y * chessVer;
|
863
|
+
}
|
864
|
+
|
865
|
+
$Jssor$.$Each(_StyleEnd, function (propertyEnd, property) {
|
866
|
+
if ($Jssor$.$IsNumeric(propertyEnd)) {
|
867
|
+
if (propertyEnd != _StyleStart[property]) {
|
868
|
+
_StyleDif[property] = propertyEnd - _StyleStart[property];
|
869
|
+
}
|
870
|
+
}
|
871
|
+
});
|
872
|
+
|
873
|
+
_StartStylesArr[columnRow] = _SlideOut ? _StyleStart : _StyleEnd;
|
874
|
+
|
875
|
+
var animationStylesArr = [];
|
876
|
+
var framesCount = slideTransition.$FramesCount;
|
877
|
+
var virtualFrameCount = Math.round(order * slideTransition.$Delay / slideTransition.$Interval);
|
878
|
+
_AnimationStylesArrs[columnRow] = new Array(virtualFrameCount);
|
879
|
+
_AnimationStylesArrs[columnRow].$Min = virtualFrameCount;
|
880
|
+
_AnimationStylesArrs[columnRow].$Max = virtualFrameCount + framesCount - 1;
|
881
|
+
|
882
|
+
for (var frameN = 0; frameN <= framesCount; frameN++) {
|
883
|
+
var styleFrameN = $Jssor$.$Cast(_StyleStart, _StyleDif, frameN / framesCount, slideTransition.$Easing, slideTransition.$During, slideTransition.$Round, { $Move: slideTransition.$Move, $OriginalWidth: slideContainerWidth, $OriginalHeight: slideContainerHeight })
|
884
|
+
|
885
|
+
styleFrameN.$ZIndex = styleFrameN.$ZIndex || 1;
|
886
|
+
|
887
|
+
_AnimationStylesArrs[columnRow].push(styleFrameN);
|
888
|
+
}
|
889
|
+
|
890
|
+
} //for
|
891
|
+
});
|
892
|
+
});
|
893
|
+
|
894
|
+
_FormationInstance.reverse();
|
895
|
+
$Jssor$.$Each(_FormationInstance, function (formationItems) {
|
896
|
+
$Jssor$.$Each(formationItems, function (formationItem) {
|
897
|
+
var row = formationItem[0];
|
898
|
+
var col = formationItem[1];
|
899
|
+
|
900
|
+
var columnRow = row + ',' + col;
|
901
|
+
|
902
|
+
var image = slideElement;
|
903
|
+
if (col || row)
|
904
|
+
image = $Jssor$.$CloneNode(slideElement);
|
905
|
+
|
906
|
+
$Jssor$.$SetStyles(image, _StartStylesArr[columnRow]);
|
907
|
+
$Jssor$.$CssOverflow(image, "hidden");
|
908
|
+
|
909
|
+
$Jssor$.$CssPosition(image, "absolute");
|
910
|
+
slideContainer.$AddClipElement(image);
|
911
|
+
_AnimationBlockItems[columnRow] = image;
|
912
|
+
$Jssor$.$ShowElement(image, !_SlideOut);
|
913
|
+
});
|
914
|
+
});
|
915
|
+
}
|
916
|
+
}
|
917
|
+
|
918
|
+
function SlideshowProcessor() {
|
919
|
+
var _SelfSlideshowProcessor = this;
|
920
|
+
var _CurrentTime = 0;
|
921
|
+
|
922
|
+
$JssorAnimator$.call(_SelfSlideshowProcessor, 0, _EndTime);
|
923
|
+
|
924
|
+
_SelfSlideshowProcessor.$OnPositionChange = function (oldPosition, newPosition) {
|
925
|
+
if ((newPosition - _CurrentTime) > _SlideshowPerformance) {
|
926
|
+
_CurrentTime = newPosition;
|
927
|
+
|
928
|
+
_SlideshowPlayerAbove && _SlideshowPlayerAbove.$ShowFrame(newPosition);
|
929
|
+
_SlideshowPlayerBelow && _SlideshowPlayerBelow.$ShowFrame(newPosition);
|
930
|
+
}
|
931
|
+
};
|
932
|
+
|
933
|
+
_SelfSlideshowProcessor.$Transition = _SlideshowTransition;
|
934
|
+
}
|
935
|
+
//#endregion
|
936
|
+
|
937
|
+
//member functions
|
938
|
+
_SelfSlideshowRunner.$GetTransition = function (slideCount) {
|
939
|
+
var n = 0;
|
940
|
+
|
941
|
+
var transitions = slideshowOptions.$Transitions;
|
942
|
+
|
943
|
+
var transitionCount = transitions.length;
|
944
|
+
|
945
|
+
if (_TransitionsOrder) { /*Sequence*/
|
946
|
+
//if (transitionCount > slideCount && ($Jssor$.$IsBrowserChrome() || $Jssor$.$IsBrowserSafari() || $Jssor$.$IsBrowserFireFox())) {
|
947
|
+
// transitionCount -= transitionCount % slideCount;
|
948
|
+
//}
|
949
|
+
n = _TransitionIndex++ % transitionCount;
|
950
|
+
}
|
951
|
+
else { /*Random*/
|
952
|
+
n = Math.floor(Math.random() * transitionCount);
|
953
|
+
}
|
954
|
+
|
955
|
+
transitions[n] && (transitions[n].$Index = n);
|
956
|
+
|
957
|
+
return transitions[n];
|
958
|
+
};
|
959
|
+
|
960
|
+
_SelfSlideshowRunner.$Initialize = function (slideIndex, prevIndex, slideItem, prevItem, slideshowTransition) {
|
961
|
+
$JssorDebug$.$Execute(function () {
|
962
|
+
if (_SlideshowPlayerBelow) {
|
963
|
+
$JssorDebug$.$Fail("slideshow runner has not been cleared.");
|
964
|
+
}
|
965
|
+
});
|
966
|
+
|
967
|
+
_SlideshowTransition = slideshowTransition;
|
968
|
+
|
969
|
+
slideshowTransition = EnsureTransitionInstance(slideshowTransition, _SlideshowPerformance);
|
970
|
+
|
971
|
+
_SlideItem = slideItem;
|
972
|
+
_PrevItem = prevItem;
|
973
|
+
|
974
|
+
var prevSlideElement = prevItem.$Item;
|
975
|
+
var currentSlideElement = slideItem.$Item;
|
976
|
+
prevSlideElement["no-image"] = !prevItem.$Image;
|
977
|
+
currentSlideElement["no-image"] = !slideItem.$Image;
|
978
|
+
|
979
|
+
var slideElementAbove = prevSlideElement;
|
980
|
+
var slideElementBelow = currentSlideElement;
|
981
|
+
|
982
|
+
var slideTransitionAbove = slideshowTransition;
|
983
|
+
var slideTransitionBelow = slideshowTransition.$Brother || EnsureTransitionInstance({}, _SlideshowPerformance);
|
984
|
+
|
985
|
+
if (!slideshowTransition.$SlideOut) {
|
986
|
+
slideElementAbove = currentSlideElement;
|
987
|
+
slideElementBelow = prevSlideElement;
|
988
|
+
}
|
989
|
+
|
990
|
+
var shift = slideTransitionBelow.$Shift || 0;
|
991
|
+
|
992
|
+
_SlideshowPlayerBelow = new JssorSlideshowPlayer(slideContainer, slideElementBelow, slideTransitionBelow, Math.max(shift - slideTransitionBelow.$Interval, 0), slideContainerWidth, slideContainerHeight);
|
993
|
+
_SlideshowPlayerAbove = new JssorSlideshowPlayer(slideContainer, slideElementAbove, slideTransitionAbove, Math.max(slideTransitionBelow.$Interval - shift, 0), slideContainerWidth, slideContainerHeight);
|
994
|
+
|
995
|
+
_SlideshowPlayerBelow.$ShowFrame(0);
|
996
|
+
_SlideshowPlayerAbove.$ShowFrame(0);
|
997
|
+
|
998
|
+
_EndTime = Math.max(_SlideshowPlayerBelow.$EndTime, _SlideshowPlayerAbove.$EndTime);
|
999
|
+
|
1000
|
+
_SelfSlideshowRunner.$Index = slideIndex;
|
1001
|
+
};
|
1002
|
+
|
1003
|
+
_SelfSlideshowRunner.$Clear = function () {
|
1004
|
+
slideContainer.$Clear();
|
1005
|
+
_SlideshowPlayerBelow = null;
|
1006
|
+
_SlideshowPlayerAbove = null;
|
1007
|
+
};
|
1008
|
+
|
1009
|
+
_SelfSlideshowRunner.$GetProcessor = function () {
|
1010
|
+
var slideshowProcessor = null;
|
1011
|
+
|
1012
|
+
if (_SlideshowPlayerAbove)
|
1013
|
+
slideshowProcessor = new SlideshowProcessor();
|
1014
|
+
|
1015
|
+
return slideshowProcessor;
|
1016
|
+
};
|
1017
|
+
|
1018
|
+
//Constructor
|
1019
|
+
{
|
1020
|
+
if ($Jssor$.$IsBrowserIe9Earlier() || $Jssor$.$IsBrowserOpera() || (isTouchDevice && $Jssor$.$WebKitVersion() < 537)) {
|
1021
|
+
_SlideshowPerformance = 16;
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
$JssorObject$.call(_SelfSlideshowRunner);
|
1025
|
+
$JssorAnimator$.call(_SelfSlideshowRunner, -10000000, 10000000);
|
1026
|
+
}
|
1027
|
+
};
|
1028
|
+
|
1029
|
+
var $JssorSlider$ = window.$JssorSlider$ = function (elmt, options) {
|
1030
|
+
var _SelfSlider = this;
|
1031
|
+
|
1032
|
+
//#region Private Classes
|
1033
|
+
//Conveyor
|
1034
|
+
function Conveyor() {
|
1035
|
+
var _SelfConveyor = this;
|
1036
|
+
$JssorAnimator$.call(_SelfConveyor, -100000000, 200000000);
|
1037
|
+
|
1038
|
+
_SelfConveyor.$GetCurrentSlideInfo = function () {
|
1039
|
+
var positionDisplay = _SelfConveyor.$GetPosition_Display();
|
1040
|
+
var virtualIndex = Math.floor(positionDisplay);
|
1041
|
+
var slideIndex = GetRealIndex(virtualIndex);
|
1042
|
+
var slidePosition = positionDisplay - Math.floor(positionDisplay);
|
1043
|
+
|
1044
|
+
return { $Index: slideIndex, $VirtualIndex: virtualIndex, $Position: slidePosition };
|
1045
|
+
};
|
1046
|
+
|
1047
|
+
_SelfConveyor.$OnPositionChange = function (oldPosition, newPosition) {
|
1048
|
+
|
1049
|
+
var index = Math.floor(newPosition);
|
1050
|
+
if (index != newPosition && newPosition > oldPosition)
|
1051
|
+
index++;
|
1052
|
+
|
1053
|
+
ResetNavigator(index, true);
|
1054
|
+
|
1055
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_POSITION_CHANGE, GetRealIndex(newPosition), GetRealIndex(oldPosition), newPosition, oldPosition);
|
1056
|
+
};
|
1057
|
+
}
|
1058
|
+
//Conveyor
|
1059
|
+
|
1060
|
+
//Carousel
|
1061
|
+
function Carousel() {
|
1062
|
+
var _SelfCarousel = this;
|
1063
|
+
|
1064
|
+
$JssorAnimator$.call(_SelfCarousel, 0, 0, { $LoopLength: _SlideCount });
|
1065
|
+
|
1066
|
+
//Carousel Constructor
|
1067
|
+
{
|
1068
|
+
$Jssor$.$Each(_SlideItems, function (slideItem) {
|
1069
|
+
(_Loop & 1) && slideItem.$SetLoopLength(_SlideCount);
|
1070
|
+
_SelfCarousel.$Chain(slideItem);
|
1071
|
+
slideItem.$Shift(_ParkingPosition / _StepLength);
|
1072
|
+
});
|
1073
|
+
}
|
1074
|
+
}
|
1075
|
+
//Carousel
|
1076
|
+
|
1077
|
+
//Slideshow
|
1078
|
+
function Slideshow() {
|
1079
|
+
var _SelfSlideshow = this;
|
1080
|
+
var _Wrapper = _SlideContainer.$Elmt;
|
1081
|
+
|
1082
|
+
$JssorAnimator$.call(_SelfSlideshow, -1, 2, { $Easing: $JssorEasing$.$EaseLinear, $Setter: { $Position: SetPosition }, $LoopLength: _SlideCount }, _Wrapper, { $Position: 1 }, { $Position: -2 });
|
1083
|
+
|
1084
|
+
_SelfSlideshow.$Wrapper = _Wrapper;
|
1085
|
+
|
1086
|
+
//Slideshow Constructor
|
1087
|
+
{
|
1088
|
+
$JssorDebug$.$Execute(function () {
|
1089
|
+
$Jssor$.$Attribute(_SlideContainer.$Elmt, "debug-id", "slide_container");
|
1090
|
+
});
|
1091
|
+
}
|
1092
|
+
}
|
1093
|
+
//Slideshow
|
1094
|
+
|
1095
|
+
//CarouselPlayer
|
1096
|
+
function CarouselPlayer(carousel, slideshow) {
|
1097
|
+
var _SelfCarouselPlayer = this;
|
1098
|
+
var _FromPosition;
|
1099
|
+
var _ToPosition;
|
1100
|
+
var _Duration;
|
1101
|
+
var _StandBy;
|
1102
|
+
var _StandByPosition;
|
1103
|
+
|
1104
|
+
$JssorAnimator$.call(_SelfCarouselPlayer, -100000000, 200000000, { $IntervalMax: 100 });
|
1105
|
+
|
1106
|
+
_SelfCarouselPlayer.$OnStart = function () {
|
1107
|
+
_IsSliding = true;
|
1108
|
+
_LoadingTicket = null;
|
1109
|
+
|
1110
|
+
//EVT_SWIPE_START
|
1111
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_SWIPE_START, GetRealIndex(_Conveyor.$GetPosition()), _Conveyor.$GetPosition());
|
1112
|
+
};
|
1113
|
+
|
1114
|
+
_SelfCarouselPlayer.$OnStop = function () {
|
1115
|
+
|
1116
|
+
_IsSliding = false;
|
1117
|
+
_StandBy = false;
|
1118
|
+
|
1119
|
+
var currentSlideInfo = _Conveyor.$GetCurrentSlideInfo();
|
1120
|
+
|
1121
|
+
//EVT_SWIPE_END
|
1122
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_SWIPE_END, GetRealIndex(_Conveyor.$GetPosition()), _Conveyor.$GetPosition());
|
1123
|
+
|
1124
|
+
if (!currentSlideInfo.$Position) {
|
1125
|
+
OnPark(currentSlideInfo.$VirtualIndex, _CurrentSlideIndex);
|
1126
|
+
}
|
1127
|
+
};
|
1128
|
+
|
1129
|
+
_SelfCarouselPlayer.$OnPositionChange = function (oldPosition, newPosition) {
|
1130
|
+
|
1131
|
+
var toPosition;
|
1132
|
+
|
1133
|
+
if (_StandBy)
|
1134
|
+
toPosition = _StandByPosition;
|
1135
|
+
else {
|
1136
|
+
toPosition = _ToPosition;
|
1137
|
+
|
1138
|
+
if (_Duration) {
|
1139
|
+
var interPosition = newPosition / _Duration;
|
1140
|
+
toPosition = _Options.$SlideEasing(interPosition) * (_ToPosition - _FromPosition) + _FromPosition;
|
1141
|
+
}
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
_Conveyor.$GoToPosition(toPosition);
|
1145
|
+
};
|
1146
|
+
|
1147
|
+
_SelfCarouselPlayer.$PlayCarousel = function (fromPosition, toPosition, duration, callback) {
|
1148
|
+
$JssorDebug$.$Execute(function () {
|
1149
|
+
if (_SelfCarouselPlayer.$IsPlaying())
|
1150
|
+
$JssorDebug$.$Fail("The carousel is already playing.");
|
1151
|
+
});
|
1152
|
+
|
1153
|
+
_FromPosition = fromPosition;
|
1154
|
+
_ToPosition = toPosition;
|
1155
|
+
_Duration = duration;
|
1156
|
+
|
1157
|
+
_Conveyor.$GoToPosition(fromPosition);
|
1158
|
+
_SelfCarouselPlayer.$GoToPosition(0);
|
1159
|
+
|
1160
|
+
_SelfCarouselPlayer.$PlayToPosition(duration, callback);
|
1161
|
+
};
|
1162
|
+
|
1163
|
+
_SelfCarouselPlayer.$StandBy = function (standByPosition) {
|
1164
|
+
_StandBy = true;
|
1165
|
+
_StandByPosition = standByPosition;
|
1166
|
+
_SelfCarouselPlayer.$Play(standByPosition, null, true);
|
1167
|
+
};
|
1168
|
+
|
1169
|
+
_SelfCarouselPlayer.$SetStandByPosition = function (standByPosition) {
|
1170
|
+
_StandByPosition = standByPosition;
|
1171
|
+
};
|
1172
|
+
|
1173
|
+
_SelfCarouselPlayer.$MoveCarouselTo = function (position) {
|
1174
|
+
_Conveyor.$GoToPosition(position);
|
1175
|
+
};
|
1176
|
+
|
1177
|
+
//CarouselPlayer Constructor
|
1178
|
+
{
|
1179
|
+
_Conveyor = new Conveyor();
|
1180
|
+
|
1181
|
+
_Conveyor.$Combine(carousel);
|
1182
|
+
_Conveyor.$Combine(slideshow);
|
1183
|
+
}
|
1184
|
+
}
|
1185
|
+
//CarouselPlayer
|
1186
|
+
|
1187
|
+
//SlideContainer
|
1188
|
+
function SlideContainer() {
|
1189
|
+
var _Self = this;
|
1190
|
+
var elmt = CreatePanel();
|
1191
|
+
|
1192
|
+
$Jssor$.$CssZIndex(elmt, 0);
|
1193
|
+
$Jssor$.$Css(elmt, "pointerEvents", "none");
|
1194
|
+
|
1195
|
+
_Self.$Elmt = elmt;
|
1196
|
+
|
1197
|
+
_Self.$AddClipElement = function (clipElement) {
|
1198
|
+
$Jssor$.$AppendChild(elmt, clipElement);
|
1199
|
+
$Jssor$.$ShowElement(elmt);
|
1200
|
+
};
|
1201
|
+
|
1202
|
+
_Self.$Clear = function () {
|
1203
|
+
$Jssor$.$HideElement(elmt);
|
1204
|
+
$Jssor$.$Empty(elmt);
|
1205
|
+
};
|
1206
|
+
}
|
1207
|
+
//SlideContainer
|
1208
|
+
|
1209
|
+
//SlideItem
|
1210
|
+
function SlideItem(slideElmt, slideIndex) {
|
1211
|
+
|
1212
|
+
var _SelfSlideItem = this;
|
1213
|
+
|
1214
|
+
var _CaptionSliderIn;
|
1215
|
+
var _CaptionSliderOut;
|
1216
|
+
var _CaptionSliderCurrent;
|
1217
|
+
var _IsCaptionSliderPlayingWhenDragStart;
|
1218
|
+
|
1219
|
+
var _Wrapper;
|
1220
|
+
var _BaseElement = slideElmt;
|
1221
|
+
|
1222
|
+
var _LoadingScreen;
|
1223
|
+
|
1224
|
+
var _ImageItem;
|
1225
|
+
var _ImageElmts = [];
|
1226
|
+
var _LinkItemOrigin;
|
1227
|
+
var _LinkItem;
|
1228
|
+
var _ImageLoading;
|
1229
|
+
var _ImageLoaded;
|
1230
|
+
var _ImageLazyLoading;
|
1231
|
+
var _ContentRefreshed;
|
1232
|
+
|
1233
|
+
var _Processor;
|
1234
|
+
|
1235
|
+
var _PlayerInstanceElement;
|
1236
|
+
var _PlayerInstance;
|
1237
|
+
|
1238
|
+
var _SequenceNumber; //for debug only
|
1239
|
+
|
1240
|
+
$JssorAnimator$.call(_SelfSlideItem, -_DisplayPieces, _DisplayPieces + 1, { $SlideItemAnimator: true });
|
1241
|
+
|
1242
|
+
function ResetCaptionSlider(fresh) {
|
1243
|
+
_CaptionSliderOut && _CaptionSliderOut.$Revert();
|
1244
|
+
_CaptionSliderIn && _CaptionSliderIn.$Revert();
|
1245
|
+
|
1246
|
+
RefreshContent(slideElmt, fresh);
|
1247
|
+
_ContentRefreshed = true;
|
1248
|
+
|
1249
|
+
_CaptionSliderIn = new _CaptionSliderOptions.$Class(slideElmt, _CaptionSliderOptions, 1);
|
1250
|
+
$JssorDebug$.$LiveStamp(_CaptionSliderIn, "caption_slider_" + _CaptionSliderCount + "_in");
|
1251
|
+
_CaptionSliderOut = new _CaptionSliderOptions.$Class(slideElmt, _CaptionSliderOptions);
|
1252
|
+
$JssorDebug$.$LiveStamp(_CaptionSliderOut, "caption_slider_" + _CaptionSliderCount + "_out");
|
1253
|
+
|
1254
|
+
$JssorDebug$.$Execute(function () {
|
1255
|
+
_CaptionSliderCount++;
|
1256
|
+
});
|
1257
|
+
|
1258
|
+
_CaptionSliderOut.$GoToPosition(0);
|
1259
|
+
_CaptionSliderIn.$GoToPosition(0);
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
function EnsureCaptionSliderVersion() {
|
1263
|
+
if (_CaptionSliderIn.$Version < _CaptionSliderOptions.$Version) {
|
1264
|
+
ResetCaptionSlider();
|
1265
|
+
}
|
1266
|
+
}
|
1267
|
+
|
1268
|
+
//event handling begin
|
1269
|
+
function LoadImageCompleteEventHandler(completeCallback, loadingScreen, image) {
|
1270
|
+
if (!_ImageLoaded) {
|
1271
|
+
_ImageLoaded = true;
|
1272
|
+
|
1273
|
+
if (_ImageItem && image) {
|
1274
|
+
var imageWidth = image.width;
|
1275
|
+
var imageHeight = image.height;
|
1276
|
+
var fillWidth = imageWidth;
|
1277
|
+
var fillHeight = imageHeight;
|
1278
|
+
|
1279
|
+
if (imageWidth && imageHeight && _Options.$FillMode) {
|
1280
|
+
|
1281
|
+
//0 stretch, 1 contain (keep aspect ratio and put all inside slide), 2 cover (keep aspect ratio and cover whole slide), 4 actual size, 5 contain for large image, actual size for small image, default value is 0
|
1282
|
+
if (_Options.$FillMode & 3 && (!(_Options.$FillMode & 4) || imageWidth > _SlideWidth || imageHeight > _SlideHeight)) {
|
1283
|
+
var fitHeight = false;
|
1284
|
+
var ratio = _SlideWidth / _SlideHeight * imageHeight / imageWidth;
|
1285
|
+
|
1286
|
+
if (_Options.$FillMode & 1) {
|
1287
|
+
fitHeight = (ratio > 1);
|
1288
|
+
}
|
1289
|
+
else if (_Options.$FillMode & 2) {
|
1290
|
+
fitHeight = (ratio < 1);
|
1291
|
+
}
|
1292
|
+
fillWidth = fitHeight ? imageWidth * _SlideHeight / imageHeight : _SlideWidth;
|
1293
|
+
fillHeight = fitHeight ? _SlideHeight : imageHeight * _SlideWidth / imageWidth;
|
1294
|
+
}
|
1295
|
+
|
1296
|
+
$Jssor$.$CssWidth(_ImageItem, fillWidth);
|
1297
|
+
$Jssor$.$CssHeight(_ImageItem, fillHeight);
|
1298
|
+
$Jssor$.$CssTop(_ImageItem, (_SlideHeight - fillHeight) / 2);
|
1299
|
+
$Jssor$.$CssLeft(_ImageItem, (_SlideWidth - fillWidth) / 2);
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
$Jssor$.$CssPosition(_ImageItem, "absolute");
|
1303
|
+
|
1304
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_LOAD_END, slideIndex);
|
1305
|
+
}
|
1306
|
+
}
|
1307
|
+
|
1308
|
+
$Jssor$.$HideElement(loadingScreen);
|
1309
|
+
completeCallback && completeCallback(_SelfSlideItem);
|
1310
|
+
}
|
1311
|
+
|
1312
|
+
function LoadSlideshowImageCompleteEventHandler(nextIndex, nextItem, slideshowTransition, loadingTicket) {
|
1313
|
+
if (loadingTicket == _LoadingTicket && _CurrentSlideIndex == slideIndex && _AutoPlay) {
|
1314
|
+
if (!_Frozen) {
|
1315
|
+
var nextRealIndex = GetRealIndex(nextIndex);
|
1316
|
+
_SlideshowRunner.$Initialize(nextRealIndex, slideIndex, nextItem, _SelfSlideItem, slideshowTransition);
|
1317
|
+
nextItem.$HideContentForSlideshow();
|
1318
|
+
_Slideshow.$Locate(nextRealIndex, 1);
|
1319
|
+
_Slideshow.$GoToPosition(nextRealIndex);
|
1320
|
+
_CarouselPlayer.$PlayCarousel(nextIndex, nextIndex, 0);
|
1321
|
+
}
|
1322
|
+
}
|
1323
|
+
}
|
1324
|
+
|
1325
|
+
function SlideReadyEventHandler(loadingTicket) {
|
1326
|
+
if (loadingTicket == _LoadingTicket && _CurrentSlideIndex == slideIndex) {
|
1327
|
+
|
1328
|
+
if (!_Processor) {
|
1329
|
+
var slideshowProcessor = null;
|
1330
|
+
if (_SlideshowRunner) {
|
1331
|
+
if (_SlideshowRunner.$Index == slideIndex)
|
1332
|
+
slideshowProcessor = _SlideshowRunner.$GetProcessor();
|
1333
|
+
else
|
1334
|
+
_SlideshowRunner.$Clear();
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
EnsureCaptionSliderVersion();
|
1338
|
+
|
1339
|
+
_Processor = new Processor(slideElmt, slideIndex, slideshowProcessor, _SelfSlideItem.$GetCaptionSliderIn(), _SelfSlideItem.$GetCaptionSliderOut());
|
1340
|
+
_Processor.$SetPlayer(_PlayerInstance);
|
1341
|
+
}
|
1342
|
+
|
1343
|
+
!_Processor.$IsPlaying() && _Processor.$Replay();
|
1344
|
+
}
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
function ParkEventHandler(currentIndex, previousIndex, manualActivate) {
|
1348
|
+
if (currentIndex == slideIndex) {
|
1349
|
+
|
1350
|
+
if (currentIndex != previousIndex)
|
1351
|
+
_SlideItems[previousIndex] && _SlideItems[previousIndex].$ParkOut();
|
1352
|
+
else
|
1353
|
+
!manualActivate && _Processor && _Processor.$AdjustIdleOnPark();
|
1354
|
+
|
1355
|
+
_PlayerInstance && _PlayerInstance.$Enable();
|
1356
|
+
|
1357
|
+
//park in
|
1358
|
+
var loadingTicket = _LoadingTicket = $Jssor$.$GetNow();
|
1359
|
+
_SelfSlideItem.$LoadImage($Jssor$.$CreateCallback(null, SlideReadyEventHandler, loadingTicket));
|
1360
|
+
}
|
1361
|
+
else {
|
1362
|
+
var distance = Math.abs(slideIndex - currentIndex);
|
1363
|
+
var loadRange = _DisplayPieces + _Options.$LazyLoading - 1;
|
1364
|
+
if (!_ImageLazyLoading || distance <= loadRange) {
|
1365
|
+
_SelfSlideItem.$LoadImage();
|
1366
|
+
}
|
1367
|
+
}
|
1368
|
+
}
|
1369
|
+
|
1370
|
+
function SwipeStartEventHandler() {
|
1371
|
+
if (_CurrentSlideIndex == slideIndex && _Processor) {
|
1372
|
+
_Processor.$Stop();
|
1373
|
+
_PlayerInstance && _PlayerInstance.$Quit();
|
1374
|
+
_PlayerInstance && _PlayerInstance.$Disable();
|
1375
|
+
_Processor.$OpenSlideshowPanel();
|
1376
|
+
}
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
function FreezeEventHandler() {
|
1380
|
+
if (_CurrentSlideIndex == slideIndex && _Processor) {
|
1381
|
+
_Processor.$Stop();
|
1382
|
+
}
|
1383
|
+
}
|
1384
|
+
|
1385
|
+
function ContentClickEventHandler(event) {
|
1386
|
+
if (_LastDragSucceded) {
|
1387
|
+
$Jssor$.$StopEvent(event);
|
1388
|
+
|
1389
|
+
var checkElement = $Jssor$.$EvtSrc(event);
|
1390
|
+
while (checkElement && slideElmt !== checkElement) {
|
1391
|
+
if (checkElement.tagName == "A") {
|
1392
|
+
$Jssor$.$CancelEvent(event);
|
1393
|
+
}
|
1394
|
+
try {
|
1395
|
+
checkElement = checkElement.parentNode;
|
1396
|
+
} catch (e) {
|
1397
|
+
// Firefox sometimes fires events for XUL elements, which throws
|
1398
|
+
// a "permission denied" error. so this is not a child.
|
1399
|
+
break;
|
1400
|
+
}
|
1401
|
+
}
|
1402
|
+
}
|
1403
|
+
}
|
1404
|
+
|
1405
|
+
function SlideClickEventHandler(event) {
|
1406
|
+
if (!_LastDragSucceded) {
|
1407
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_CLICK, slideIndex, event);
|
1408
|
+
}
|
1409
|
+
}
|
1410
|
+
|
1411
|
+
function PlayerAvailableEventHandler() {
|
1412
|
+
_PlayerInstance = _PlayerInstanceElement.pInstance;
|
1413
|
+
_Processor && _Processor.$SetPlayer(_PlayerInstance);
|
1414
|
+
}
|
1415
|
+
|
1416
|
+
_SelfSlideItem.$LoadImage = function (completeCallback, loadingScreen) {
|
1417
|
+
loadingScreen = loadingScreen || _LoadingScreen;
|
1418
|
+
|
1419
|
+
if (_ImageElmts.length && !_ImageLoaded) {
|
1420
|
+
|
1421
|
+
$Jssor$.$ShowElement(loadingScreen);
|
1422
|
+
|
1423
|
+
if (!_ImageLoading) {
|
1424
|
+
_ImageLoading = true;
|
1425
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_LOAD_START, slideIndex);
|
1426
|
+
|
1427
|
+
$Jssor$.$Each(_ImageElmts, function (imageElmt) {
|
1428
|
+
|
1429
|
+
if (!$Jssor$.$Attribute(imageElmt, "src")) {
|
1430
|
+
imageElmt.src = $Jssor$.$AttributeEx(imageElmt, "src2");
|
1431
|
+
$Jssor$.$CssDisplay(imageElmt, imageElmt["display-origin"]);
|
1432
|
+
}
|
1433
|
+
});
|
1434
|
+
}
|
1435
|
+
$Jssor$.$LoadImages(_ImageElmts, _ImageItem, $Jssor$.$CreateCallback(null, LoadImageCompleteEventHandler, completeCallback, loadingScreen));
|
1436
|
+
}
|
1437
|
+
else {
|
1438
|
+
LoadImageCompleteEventHandler(completeCallback, loadingScreen);
|
1439
|
+
}
|
1440
|
+
};
|
1441
|
+
|
1442
|
+
_SelfSlideItem.$GoForNextSlide = function () {
|
1443
|
+
|
1444
|
+
var index = slideIndex;
|
1445
|
+
if (_Options.$AutoPlaySteps < 0)
|
1446
|
+
index -= _SlideCount;
|
1447
|
+
|
1448
|
+
var nextIndex = index + _Options.$AutoPlaySteps * _PlayReverse;
|
1449
|
+
|
1450
|
+
if (_Loop & 2) {
|
1451
|
+
//Rewind
|
1452
|
+
nextIndex = GetRealIndex(nextIndex);
|
1453
|
+
}
|
1454
|
+
if (!(_Loop & 1)) {
|
1455
|
+
//Stop at threshold
|
1456
|
+
nextIndex = Math.max(0, Math.min(nextIndex, _SlideCount - _DisplayPieces));
|
1457
|
+
}
|
1458
|
+
|
1459
|
+
if (nextIndex != slideIndex) {
|
1460
|
+
if (_SlideshowRunner) {
|
1461
|
+
var slideshowTransition = _SlideshowRunner.$GetTransition(_SlideCount);
|
1462
|
+
|
1463
|
+
if (slideshowTransition) {
|
1464
|
+
var loadingTicket = _LoadingTicket = $Jssor$.$GetNow();
|
1465
|
+
|
1466
|
+
var nextItem = _SlideItems[GetRealIndex(nextIndex)];
|
1467
|
+
return nextItem.$LoadImage($Jssor$.$CreateCallback(null, LoadSlideshowImageCompleteEventHandler, nextIndex, nextItem, slideshowTransition, loadingTicket), _LoadingScreen);
|
1468
|
+
}
|
1469
|
+
}
|
1470
|
+
|
1471
|
+
PlayTo(nextIndex);
|
1472
|
+
}
|
1473
|
+
};
|
1474
|
+
|
1475
|
+
_SelfSlideItem.$TryActivate = function () {
|
1476
|
+
ParkEventHandler(slideIndex, slideIndex, true);
|
1477
|
+
};
|
1478
|
+
|
1479
|
+
_SelfSlideItem.$ParkOut = function () {
|
1480
|
+
//park out
|
1481
|
+
_PlayerInstance && _PlayerInstance.$Quit();
|
1482
|
+
_PlayerInstance && _PlayerInstance.$Disable();
|
1483
|
+
_SelfSlideItem.$UnhideContentForSlideshow();
|
1484
|
+
_Processor && _Processor.$Abort();
|
1485
|
+
_Processor = null;
|
1486
|
+
ResetCaptionSlider();
|
1487
|
+
};
|
1488
|
+
|
1489
|
+
//for debug only
|
1490
|
+
_SelfSlideItem.$StampSlideItemElements = function (stamp) {
|
1491
|
+
stamp = _SequenceNumber + "_" + stamp;
|
1492
|
+
|
1493
|
+
$JssorDebug$.$Execute(function () {
|
1494
|
+
if (_ImageItem)
|
1495
|
+
$Jssor$.$Attribute(_ImageItem, "debug-id", stamp + "_slide_item_image_id");
|
1496
|
+
|
1497
|
+
$Jssor$.$Attribute(slideElmt, "debug-id", stamp + "_slide_item_item_id");
|
1498
|
+
});
|
1499
|
+
|
1500
|
+
$JssorDebug$.$Execute(function () {
|
1501
|
+
$Jssor$.$Attribute(_Wrapper, "debug-id", stamp + "_slide_item_wrapper_id");
|
1502
|
+
});
|
1503
|
+
|
1504
|
+
$JssorDebug$.$Execute(function () {
|
1505
|
+
$Jssor$.$Attribute(_LoadingScreen, "debug-id", stamp + "_loading_container_id");
|
1506
|
+
});
|
1507
|
+
};
|
1508
|
+
|
1509
|
+
_SelfSlideItem.$HideContentForSlideshow = function () {
|
1510
|
+
$Jssor$.$HideElement(slideElmt);
|
1511
|
+
};
|
1512
|
+
|
1513
|
+
_SelfSlideItem.$UnhideContentForSlideshow = function () {
|
1514
|
+
$Jssor$.$ShowElement(slideElmt);
|
1515
|
+
};
|
1516
|
+
|
1517
|
+
_SelfSlideItem.$EnablePlayer = function () {
|
1518
|
+
_PlayerInstance && _PlayerInstance.$Enable();
|
1519
|
+
};
|
1520
|
+
|
1521
|
+
function RefreshContent(elmt, fresh, level) {
|
1522
|
+
$JssorDebug$.$Execute(function () {
|
1523
|
+
if ($Jssor$.$Attribute(elmt, "jssor-slider"))
|
1524
|
+
$JssorDebug$.$Log("Child slider found.");
|
1525
|
+
});
|
1526
|
+
|
1527
|
+
if ($Jssor$.$Attribute(elmt, "jssor-slider"))
|
1528
|
+
return;
|
1529
|
+
|
1530
|
+
level = level || 0;
|
1531
|
+
|
1532
|
+
if (!_ContentRefreshed) {
|
1533
|
+
if (elmt.tagName == "IMG") {
|
1534
|
+
_ImageElmts.push(elmt);
|
1535
|
+
|
1536
|
+
if (!$Jssor$.$Attribute(elmt, "src")) {
|
1537
|
+
_ImageLazyLoading = true;
|
1538
|
+
elmt["display-origin"] = $Jssor$.$CssDisplay(elmt);
|
1539
|
+
$Jssor$.$HideElement(elmt);
|
1540
|
+
}
|
1541
|
+
}
|
1542
|
+
if ($Jssor$.$IsBrowserIe9Earlier()) {
|
1543
|
+
$Jssor$.$CssZIndex(elmt, ($Jssor$.$CssZIndex(elmt) || 0) + 1);
|
1544
|
+
}
|
1545
|
+
if (_Options.$HWA && $Jssor$.$WebKitVersion()) {
|
1546
|
+
if ($Jssor$.$WebKitVersion() < 534 || (!_SlideshowEnabled && !$Jssor$.$IsBrowserChrome())) {
|
1547
|
+
$Jssor$.$EnableHWA(elmt);
|
1548
|
+
}
|
1549
|
+
}
|
1550
|
+
}
|
1551
|
+
|
1552
|
+
var childElements = $Jssor$.$Children(elmt);
|
1553
|
+
|
1554
|
+
$Jssor$.$Each(childElements, function (childElement, i) {
|
1555
|
+
|
1556
|
+
var childTagName = childElement.tagName;
|
1557
|
+
var uAttribute = $Jssor$.$AttributeEx(childElement, "u");
|
1558
|
+
if (uAttribute == "player" && !_PlayerInstanceElement) {
|
1559
|
+
_PlayerInstanceElement = childElement;
|
1560
|
+
if (_PlayerInstanceElement.pInstance) {
|
1561
|
+
PlayerAvailableEventHandler();
|
1562
|
+
}
|
1563
|
+
else {
|
1564
|
+
$Jssor$.$AddEvent(_PlayerInstanceElement, "dataavailable", PlayerAvailableEventHandler);
|
1565
|
+
}
|
1566
|
+
}
|
1567
|
+
|
1568
|
+
if (uAttribute == "caption") {
|
1569
|
+
if (!$Jssor$.$IsBrowserIE() && !fresh) {
|
1570
|
+
|
1571
|
+
//if (childTagName == "A") {
|
1572
|
+
// $Jssor$.$RemoveEvent(childElement, "click", ContentClickEventHandler);
|
1573
|
+
// $Jssor$.$Attribute(childElement, "jssor-content", null);
|
1574
|
+
//}
|
1575
|
+
|
1576
|
+
var captionElement = $Jssor$.$CloneNode(childElement, false, true);
|
1577
|
+
$Jssor$.$InsertBefore(captionElement, childElement, elmt);
|
1578
|
+
$Jssor$.$RemoveElement(childElement, elmt);
|
1579
|
+
childElement = captionElement;
|
1580
|
+
|
1581
|
+
fresh = true;
|
1582
|
+
}
|
1583
|
+
}
|
1584
|
+
else if (!_ContentRefreshed && !level && !_ImageItem) {
|
1585
|
+
|
1586
|
+
if (childTagName == "A") {
|
1587
|
+
if ($Jssor$.$AttributeEx(childElement, "u") == "image") {
|
1588
|
+
_ImageItem = $Jssor$.$FindChildByTag(childElement, "IMG");
|
1589
|
+
|
1590
|
+
$JssorDebug$.$Execute(function () {
|
1591
|
+
if (!_ImageItem) {
|
1592
|
+
$JssorDebug$.$Error("slide html code definition error, no 'IMG' found in a 'image with link' slide.\r\n" + elmt.outerHTML);
|
1593
|
+
}
|
1594
|
+
});
|
1595
|
+
}
|
1596
|
+
else {
|
1597
|
+
_ImageItem = $Jssor$.$FindChild(childElement, "image", true);
|
1598
|
+
}
|
1599
|
+
|
1600
|
+
if (_ImageItem) {
|
1601
|
+
_LinkItemOrigin = childElement;
|
1602
|
+
$Jssor$.$SetStyles(_LinkItemOrigin, _StyleDef);
|
1603
|
+
|
1604
|
+
_LinkItem = $Jssor$.$CloneNode(_LinkItemOrigin, true);
|
1605
|
+
//$Jssor$.$AddEvent(_LinkItem, "click", ContentClickEventHandler);
|
1606
|
+
|
1607
|
+
$Jssor$.$CssDisplay(_LinkItem, "block");
|
1608
|
+
$Jssor$.$SetStyles(_LinkItem, _StyleDef);
|
1609
|
+
$Jssor$.$CssOpacity(_LinkItem, 0);
|
1610
|
+
$Jssor$.$Css(_LinkItem, "backgroundColor", "#000");
|
1611
|
+
}
|
1612
|
+
}
|
1613
|
+
else if (childTagName == "IMG" && $Jssor$.$AttributeEx(childElement, "u") == "image") {
|
1614
|
+
_ImageItem = childElement;
|
1615
|
+
}
|
1616
|
+
|
1617
|
+
if (_ImageItem) {
|
1618
|
+
_ImageItem.border = 0;
|
1619
|
+
$Jssor$.$SetStyles(_ImageItem, _StyleDef);
|
1620
|
+
}
|
1621
|
+
}
|
1622
|
+
|
1623
|
+
//if (!$Jssor$.$Attribute(childElement, "jssor-content")) {
|
1624
|
+
// //cancel click event on <A> element when a drag of slide succeeded
|
1625
|
+
// $Jssor$.$AddEvent(childElement, "click", ContentClickEventHandler);
|
1626
|
+
// $Jssor$.$Attribute(childElement, "jssor-content", true);
|
1627
|
+
//}
|
1628
|
+
|
1629
|
+
RefreshContent(childElement, fresh, level +1);
|
1630
|
+
});
|
1631
|
+
}
|
1632
|
+
|
1633
|
+
_SelfSlideItem.$OnInnerOffsetChange = function (oldOffset, newOffset) {
|
1634
|
+
var slidePosition = _DisplayPieces - newOffset;
|
1635
|
+
|
1636
|
+
SetPosition(_Wrapper, slidePosition);
|
1637
|
+
|
1638
|
+
//following lines are for future usage, not ready yet
|
1639
|
+
//if (!_IsDragging || !_IsCaptionSliderPlayingWhenDragStart) {
|
1640
|
+
// var _DealWithParallax;
|
1641
|
+
// if (IsCurrentSlideIndex(slideIndex)) {
|
1642
|
+
// if (_CaptionSliderOptions.$PlayOutMode == 2)
|
1643
|
+
// _DealWithParallax = true;
|
1644
|
+
// }
|
1645
|
+
// else {
|
1646
|
+
// if (!_CaptionSliderOptions.$PlayInMode) {
|
1647
|
+
// //PlayInMode: 0 none
|
1648
|
+
// _CaptionSliderIn.$GoToEnd();
|
1649
|
+
// }
|
1650
|
+
// //else if (_CaptionSliderOptions.$PlayInMode == 1) {
|
1651
|
+
// // //PlayInMode: 1 chain
|
1652
|
+
// // _CaptionSliderIn.$GoToPosition(0);
|
1653
|
+
// //}
|
1654
|
+
// else if (_CaptionSliderOptions.$PlayInMode == 2) {
|
1655
|
+
// //PlayInMode: 2 parallel
|
1656
|
+
// _DealWithParallax = true;
|
1657
|
+
// }
|
1658
|
+
// }
|
1659
|
+
|
1660
|
+
// if (_DealWithParallax) {
|
1661
|
+
// _CaptionSliderIn.$GoToPosition((_CaptionSliderIn.$GetPosition_OuterEnd() - _CaptionSliderIn.$GetPosition_OuterBegin()) * Math.abs(newOffset - 1) * .8 + _CaptionSliderIn.$GetPosition_OuterBegin());
|
1662
|
+
// }
|
1663
|
+
//}
|
1664
|
+
};
|
1665
|
+
|
1666
|
+
_SelfSlideItem.$GetCaptionSliderIn = function () {
|
1667
|
+
return _CaptionSliderIn;
|
1668
|
+
};
|
1669
|
+
|
1670
|
+
_SelfSlideItem.$GetCaptionSliderOut = function () {
|
1671
|
+
return _CaptionSliderOut;
|
1672
|
+
};
|
1673
|
+
|
1674
|
+
_SelfSlideItem.$Index = slideIndex;
|
1675
|
+
|
1676
|
+
$JssorObject$.call(_SelfSlideItem);
|
1677
|
+
|
1678
|
+
//SlideItem Constructor
|
1679
|
+
{
|
1680
|
+
|
1681
|
+
var thumb = $Jssor$.$FindChild(slideElmt, "thumb", true);
|
1682
|
+
if (thumb) {
|
1683
|
+
_SelfSlideItem.$Thumb = $Jssor$.$CloneNode(thumb);
|
1684
|
+
$Jssor$.$RemoveAttribute(thumb, "id");
|
1685
|
+
$Jssor$.$HideElement(thumb);
|
1686
|
+
}
|
1687
|
+
$Jssor$.$ShowElement(slideElmt);
|
1688
|
+
|
1689
|
+
_LoadingScreen = $Jssor$.$CloneNode(_LoadingContainer);
|
1690
|
+
$Jssor$.$CssZIndex(_LoadingScreen, 1000);
|
1691
|
+
|
1692
|
+
//cancel click event on <A> element when a drag of slide succeeded
|
1693
|
+
$Jssor$.$AddEvent(slideElmt, "click", SlideClickEventHandler);
|
1694
|
+
|
1695
|
+
ResetCaptionSlider(true);
|
1696
|
+
|
1697
|
+
_SelfSlideItem.$Image = _ImageItem;
|
1698
|
+
_SelfSlideItem.$Link = _LinkItem;
|
1699
|
+
|
1700
|
+
_SelfSlideItem.$Item = slideElmt;
|
1701
|
+
|
1702
|
+
_SelfSlideItem.$Wrapper = _Wrapper = slideElmt;
|
1703
|
+
$Jssor$.$AppendChild(_Wrapper, _LoadingScreen);
|
1704
|
+
|
1705
|
+
_SelfSlider.$On(203, ParkEventHandler);
|
1706
|
+
_SelfSlider.$On(28, FreezeEventHandler);
|
1707
|
+
_SelfSlider.$On(24, SwipeStartEventHandler);
|
1708
|
+
|
1709
|
+
$JssorDebug$.$Execute(function () {
|
1710
|
+
_SequenceNumber = _SlideItemCreatedCount++;
|
1711
|
+
});
|
1712
|
+
|
1713
|
+
$JssorDebug$.$Execute(function () {
|
1714
|
+
$Jssor$.$Attribute(_Wrapper, "debug-id", "slide-" + slideIndex);
|
1715
|
+
});
|
1716
|
+
}
|
1717
|
+
}
|
1718
|
+
//SlideItem
|
1719
|
+
|
1720
|
+
//Processor
|
1721
|
+
function Processor(slideElmt, slideIndex, slideshowProcessor, captionSliderIn, captionSliderOut) {
|
1722
|
+
|
1723
|
+
var _SelfProcessor = this;
|
1724
|
+
|
1725
|
+
var _ProgressBegin = 0;
|
1726
|
+
var _SlideshowBegin = 0;
|
1727
|
+
var _SlideshowEnd;
|
1728
|
+
var _CaptionInBegin;
|
1729
|
+
var _IdleBegin;
|
1730
|
+
var _IdleEnd;
|
1731
|
+
var _ProgressEnd;
|
1732
|
+
|
1733
|
+
var _IsSlideshowRunning;
|
1734
|
+
var _IsRollingBack;
|
1735
|
+
|
1736
|
+
var _PlayerInstance;
|
1737
|
+
var _IsPlayerOnService;
|
1738
|
+
|
1739
|
+
var slideItem = _SlideItems[slideIndex];
|
1740
|
+
|
1741
|
+
$JssorAnimator$.call(_SelfProcessor, 0, 0);
|
1742
|
+
|
1743
|
+
function UpdateLink() {
|
1744
|
+
|
1745
|
+
$Jssor$.$Empty(_LinkContainer);
|
1746
|
+
|
1747
|
+
if (_ShowLink && _IsSlideshowRunning && slideItem.$Link) {
|
1748
|
+
$Jssor$.$AppendChild(_LinkContainer, slideItem.$Link);
|
1749
|
+
}
|
1750
|
+
|
1751
|
+
$Jssor$.$ShowElement(_LinkContainer, !_IsSlideshowRunning && slideItem.$Image);
|
1752
|
+
}
|
1753
|
+
|
1754
|
+
function ProcessCompleteEventHandler() {
|
1755
|
+
|
1756
|
+
if (_IsRollingBack) {
|
1757
|
+
_IsRollingBack = false;
|
1758
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_ROLLBACK_END, slideIndex, _IdleEnd, _ProgressBegin, _IdleBegin, _IdleEnd, _ProgressEnd);
|
1759
|
+
_SelfProcessor.$GoToPosition(_IdleBegin);
|
1760
|
+
}
|
1761
|
+
|
1762
|
+
_SelfProcessor.$Replay();
|
1763
|
+
}
|
1764
|
+
|
1765
|
+
function PlayerSwitchEventHandler(isOnService) {
|
1766
|
+
_IsPlayerOnService = isOnService;
|
1767
|
+
|
1768
|
+
_SelfProcessor.$Stop();
|
1769
|
+
_SelfProcessor.$Replay();
|
1770
|
+
}
|
1771
|
+
|
1772
|
+
_SelfProcessor.$Replay = function () {
|
1773
|
+
|
1774
|
+
var currentPosition = _SelfProcessor.$GetPosition_Display();
|
1775
|
+
|
1776
|
+
if (!_IsDragging && !_IsSliding && !_IsPlayerOnService && _CurrentSlideIndex == slideIndex) {
|
1777
|
+
|
1778
|
+
if (!currentPosition) {
|
1779
|
+
if (_SlideshowEnd && !_IsSlideshowRunning) {
|
1780
|
+
_IsSlideshowRunning = true;
|
1781
|
+
|
1782
|
+
_SelfProcessor.$OpenSlideshowPanel(true);
|
1783
|
+
|
1784
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_SLIDESHOW_START, slideIndex, _ProgressBegin, _SlideshowBegin, _SlideshowEnd, _ProgressEnd);
|
1785
|
+
}
|
1786
|
+
|
1787
|
+
UpdateLink();
|
1788
|
+
}
|
1789
|
+
|
1790
|
+
var toPosition;
|
1791
|
+
var stateEvent = $JssorSlider$.$EVT_STATE_CHANGE;
|
1792
|
+
|
1793
|
+
if (currentPosition != _ProgressEnd) {
|
1794
|
+
if (currentPosition == _IdleEnd) {
|
1795
|
+
toPosition = _ProgressEnd;
|
1796
|
+
}
|
1797
|
+
else if (currentPosition == _IdleBegin) {
|
1798
|
+
toPosition = _IdleEnd;
|
1799
|
+
}
|
1800
|
+
else if (!currentPosition) {
|
1801
|
+
toPosition = _IdleBegin;
|
1802
|
+
}
|
1803
|
+
else if (currentPosition > _IdleEnd) {
|
1804
|
+
_IsRollingBack = true;
|
1805
|
+
toPosition = _IdleEnd;
|
1806
|
+
stateEvent = $JssorSlider$.$EVT_ROLLBACK_START;
|
1807
|
+
}
|
1808
|
+
else {
|
1809
|
+
//continue from break (by drag or lock)
|
1810
|
+
toPosition = _SelfProcessor.$GetPlayToPosition();
|
1811
|
+
}
|
1812
|
+
}
|
1813
|
+
|
1814
|
+
_SelfSlider.$TriggerEvent(stateEvent, slideIndex, currentPosition, _ProgressBegin, _IdleBegin, _IdleEnd, _ProgressEnd);
|
1815
|
+
|
1816
|
+
var allowAutoPlay = _AutoPlay && (!_HoverToPause || _NotOnHover);
|
1817
|
+
|
1818
|
+
if (currentPosition == _ProgressEnd) {
|
1819
|
+
(_IdleEnd != _ProgressEnd && !(_HoverToPause & 12) || allowAutoPlay) && slideItem.$GoForNextSlide();
|
1820
|
+
}
|
1821
|
+
else if (allowAutoPlay || currentPosition != _IdleEnd) {
|
1822
|
+
_SelfProcessor.$PlayToPosition(toPosition, ProcessCompleteEventHandler);
|
1823
|
+
}
|
1824
|
+
}
|
1825
|
+
};
|
1826
|
+
|
1827
|
+
_SelfProcessor.$AdjustIdleOnPark = function () {
|
1828
|
+
if (_IdleEnd == _ProgressEnd && _IdleEnd == _SelfProcessor.$GetPosition_Display())
|
1829
|
+
_SelfProcessor.$GoToPosition(_IdleBegin);
|
1830
|
+
};
|
1831
|
+
|
1832
|
+
_SelfProcessor.$Abort = function () {
|
1833
|
+
_SlideshowRunner && _SlideshowRunner.$Index == slideIndex && _SlideshowRunner.$Clear();
|
1834
|
+
|
1835
|
+
var currentPosition = _SelfProcessor.$GetPosition_Display();
|
1836
|
+
if (currentPosition < _ProgressEnd) {
|
1837
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_STATE_CHANGE, slideIndex, -currentPosition - 1, _ProgressBegin, _IdleBegin, _IdleEnd, _ProgressEnd);
|
1838
|
+
}
|
1839
|
+
};
|
1840
|
+
|
1841
|
+
_SelfProcessor.$OpenSlideshowPanel = function (open) {
|
1842
|
+
if (slideshowProcessor) {
|
1843
|
+
$Jssor$.$CssOverflow(_SlideshowPanel, open && slideshowProcessor.$Transition.$Outside ? "" : "hidden");
|
1844
|
+
}
|
1845
|
+
};
|
1846
|
+
|
1847
|
+
_SelfProcessor.$OnInnerOffsetChange = function (oldPosition, newPosition) {
|
1848
|
+
|
1849
|
+
if (_IsSlideshowRunning && newPosition >= _SlideshowEnd) {
|
1850
|
+
_IsSlideshowRunning = false;
|
1851
|
+
UpdateLink();
|
1852
|
+
slideItem.$UnhideContentForSlideshow();
|
1853
|
+
_SlideshowRunner.$Clear();
|
1854
|
+
|
1855
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_SLIDESHOW_END, slideIndex, _ProgressBegin, _SlideshowBegin, _SlideshowEnd, _ProgressEnd);
|
1856
|
+
}
|
1857
|
+
|
1858
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_PROGRESS_CHANGE, slideIndex, newPosition, _ProgressBegin, _IdleBegin, _IdleEnd, _ProgressEnd);
|
1859
|
+
};
|
1860
|
+
|
1861
|
+
_SelfProcessor.$SetPlayer = function (playerInstance) {
|
1862
|
+
if (playerInstance && !_PlayerInstance) {
|
1863
|
+
_PlayerInstance = playerInstance;
|
1864
|
+
|
1865
|
+
playerInstance.$On($JssorPlayer$.$EVT_SWITCH, PlayerSwitchEventHandler);
|
1866
|
+
}
|
1867
|
+
};
|
1868
|
+
|
1869
|
+
//Processor Constructor
|
1870
|
+
{
|
1871
|
+
if (slideshowProcessor) {
|
1872
|
+
_SelfProcessor.$Chain(slideshowProcessor);
|
1873
|
+
}
|
1874
|
+
|
1875
|
+
_SlideshowEnd = _SelfProcessor.$GetPosition_OuterEnd();
|
1876
|
+
_CaptionInBegin = _SelfProcessor.$GetPosition_OuterEnd();
|
1877
|
+
_SelfProcessor.$Chain(captionSliderIn);
|
1878
|
+
_IdleBegin = captionSliderIn.$GetPosition_OuterEnd();
|
1879
|
+
_IdleEnd = _IdleBegin + ($Jssor$.$ParseFloat($Jssor$.$AttributeEx(slideElmt, "idle")) || _AutoPlayInterval);
|
1880
|
+
|
1881
|
+
captionSliderOut.$Shift(_IdleEnd);
|
1882
|
+
_SelfProcessor.$Combine(captionSliderOut);
|
1883
|
+
_ProgressEnd = _SelfProcessor.$GetPosition_OuterEnd();
|
1884
|
+
}
|
1885
|
+
}
|
1886
|
+
//Processor
|
1887
|
+
//#endregion
|
1888
|
+
|
1889
|
+
function SetPosition(elmt, position) {
|
1890
|
+
var orientation = _DragOrientation > 0 ? _DragOrientation : _PlayOrientation;
|
1891
|
+
var x = _StepLengthX * position * (orientation & 1);
|
1892
|
+
var y = _StepLengthY * position * ((orientation >> 1) & 1);
|
1893
|
+
|
1894
|
+
x = Math.round(x);
|
1895
|
+
y = Math.round(y);
|
1896
|
+
|
1897
|
+
$Jssor$.$CssLeft(elmt, x);
|
1898
|
+
$Jssor$.$CssTop(elmt, y);
|
1899
|
+
}
|
1900
|
+
|
1901
|
+
//#region Event handling begin
|
1902
|
+
|
1903
|
+
function RecordFreezePoint() {
|
1904
|
+
_CarouselPlaying_OnFreeze = _IsSliding;
|
1905
|
+
_PlayToPosition_OnFreeze = _CarouselPlayer.$GetPlayToPosition();
|
1906
|
+
_Position_OnFreeze = _Conveyor.$GetPosition();
|
1907
|
+
}
|
1908
|
+
|
1909
|
+
function Freeze() {
|
1910
|
+
RecordFreezePoint();
|
1911
|
+
|
1912
|
+
if (_IsDragging || !_NotOnHover && (_HoverToPause & 12)) {
|
1913
|
+
_CarouselPlayer.$Stop();
|
1914
|
+
|
1915
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_FREEZE);
|
1916
|
+
}
|
1917
|
+
}
|
1918
|
+
|
1919
|
+
function Unfreeze(byDrag) {
|
1920
|
+
|
1921
|
+
if (!_IsDragging && (_NotOnHover || !(_HoverToPause & 12)) && !_CarouselPlayer.$IsPlaying()) {
|
1922
|
+
|
1923
|
+
var currentPosition = _Conveyor.$GetPosition();
|
1924
|
+
var toPosition = Math.ceil(_Position_OnFreeze);
|
1925
|
+
|
1926
|
+
if (byDrag && Math.abs(_DragOffsetTotal) >= _Options.$MinDragOffsetToSlide) {
|
1927
|
+
toPosition = Math.ceil(currentPosition);
|
1928
|
+
toPosition += _DragIndexAdjust;
|
1929
|
+
}
|
1930
|
+
|
1931
|
+
if (!(_Loop & 1)) {
|
1932
|
+
toPosition = Math.min(_SlideCount - _DisplayPieces, Math.max(toPosition, 0));
|
1933
|
+
}
|
1934
|
+
|
1935
|
+
var t = Math.abs(toPosition - currentPosition);
|
1936
|
+
t = 1 - Math.pow(1 - t, 5);
|
1937
|
+
|
1938
|
+
if (!_LastDragSucceded && _CarouselPlaying_OnFreeze) {
|
1939
|
+
_CarouselPlayer.$Continue(_PlayToPosition_OnFreeze);
|
1940
|
+
}
|
1941
|
+
else if (currentPosition == toPosition) {
|
1942
|
+
_CurrentSlideItem.$EnablePlayer();
|
1943
|
+
_CurrentSlideItem.$TryActivate();
|
1944
|
+
}
|
1945
|
+
else {
|
1946
|
+
|
1947
|
+
_CarouselPlayer.$PlayCarousel(currentPosition, toPosition, t * _SlideDuration);
|
1948
|
+
}
|
1949
|
+
}
|
1950
|
+
}
|
1951
|
+
|
1952
|
+
function PreventDragSelectionEvent(event) {
|
1953
|
+
if (!$Jssor$.$AttributeEx($Jssor$.$EvtSrc(event), "nodrag")) {
|
1954
|
+
$Jssor$.$CancelEvent(event);
|
1955
|
+
}
|
1956
|
+
}
|
1957
|
+
|
1958
|
+
function OnTouchStart(event) {
|
1959
|
+
OnDragStart(event, 1);
|
1960
|
+
}
|
1961
|
+
|
1962
|
+
function OnDragStart(event, touch) {
|
1963
|
+
event = $Jssor$.$GetEvent(event);
|
1964
|
+
var eventSrc = $Jssor$.$EvtSrc(event);
|
1965
|
+
|
1966
|
+
if (!_DragOrientationRegistered && !$Jssor$.$AttributeEx(eventSrc, "nodrag") && RegisterDrag() && (!touch || event.touches.length == 1)) {
|
1967
|
+
_IsDragging = true;
|
1968
|
+
_DragInvalid = false;
|
1969
|
+
_LoadingTicket = null;
|
1970
|
+
|
1971
|
+
$Jssor$.$AddEvent(document, touch ? "touchmove" : "mousemove", OnDragMove);
|
1972
|
+
|
1973
|
+
_LastTimeMoveByDrag = $Jssor$.$GetNow() - 50;
|
1974
|
+
|
1975
|
+
_LastDragSucceded = 0;
|
1976
|
+
Freeze();
|
1977
|
+
|
1978
|
+
if (!_CarouselPlaying_OnFreeze)
|
1979
|
+
_DragOrientation = 0;
|
1980
|
+
|
1981
|
+
if (touch) {
|
1982
|
+
var touchPoint = event.touches[0];
|
1983
|
+
_DragStartMouseX = touchPoint.clientX;
|
1984
|
+
_DragStartMouseY = touchPoint.clientY;
|
1985
|
+
}
|
1986
|
+
else {
|
1987
|
+
var mousePoint = $Jssor$.$MousePosition(event);
|
1988
|
+
|
1989
|
+
_DragStartMouseX = mousePoint.x;
|
1990
|
+
_DragStartMouseY = mousePoint.y;
|
1991
|
+
}
|
1992
|
+
|
1993
|
+
_DragOffsetTotal = 0;
|
1994
|
+
_DragOffsetLastTime = 0;
|
1995
|
+
_DragIndexAdjust = 0;
|
1996
|
+
|
1997
|
+
//Trigger EVT_DRAGSTART
|
1998
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_DRAG_START, GetRealIndex(_Position_OnFreeze), _Position_OnFreeze, event);
|
1999
|
+
}
|
2000
|
+
}
|
2001
|
+
|
2002
|
+
function OnDragMove(event) {
|
2003
|
+
if (_IsDragging) {
|
2004
|
+
event = $Jssor$.$GetEvent(event);
|
2005
|
+
|
2006
|
+
var actionPoint;
|
2007
|
+
|
2008
|
+
if (event.type != "mousemove") {
|
2009
|
+
var touch = event.touches[0];
|
2010
|
+
actionPoint = { x: touch.clientX, y: touch.clientY };
|
2011
|
+
}
|
2012
|
+
else {
|
2013
|
+
actionPoint = $Jssor$.$MousePosition(event);
|
2014
|
+
}
|
2015
|
+
|
2016
|
+
if (actionPoint) {
|
2017
|
+
var distanceX = actionPoint.x - _DragStartMouseX;
|
2018
|
+
var distanceY = actionPoint.y - _DragStartMouseY;
|
2019
|
+
|
2020
|
+
|
2021
|
+
if (Math.floor(_Position_OnFreeze) != _Position_OnFreeze)
|
2022
|
+
_DragOrientation = _DragOrientation || (_PlayOrientation & _DragOrientationRegistered);
|
2023
|
+
|
2024
|
+
if ((distanceX || distanceY) && !_DragOrientation) {
|
2025
|
+
if (_DragOrientationRegistered == 3) {
|
2026
|
+
if (Math.abs(distanceY) > Math.abs(distanceX)) {
|
2027
|
+
_DragOrientation = 2;
|
2028
|
+
}
|
2029
|
+
else
|
2030
|
+
_DragOrientation = 1;
|
2031
|
+
}
|
2032
|
+
else {
|
2033
|
+
_DragOrientation = _DragOrientationRegistered;
|
2034
|
+
}
|
2035
|
+
|
2036
|
+
if (_IsTouchDevice && _DragOrientation == 1 && Math.abs(distanceY) - Math.abs(distanceX) > 3) {
|
2037
|
+
_DragInvalid = true;
|
2038
|
+
}
|
2039
|
+
}
|
2040
|
+
|
2041
|
+
if (_DragOrientation) {
|
2042
|
+
var distance = distanceY;
|
2043
|
+
var stepLength = _StepLengthY;
|
2044
|
+
|
2045
|
+
if (_DragOrientation == 1) {
|
2046
|
+
distance = distanceX;
|
2047
|
+
stepLength = _StepLengthX;
|
2048
|
+
}
|
2049
|
+
|
2050
|
+
if (!(_Loop & 1)) {
|
2051
|
+
if (distance > 0) {
|
2052
|
+
var normalDistance = stepLength * _CurrentSlideIndex;
|
2053
|
+
var sqrtDistance = distance - normalDistance;
|
2054
|
+
if (sqrtDistance > 0) {
|
2055
|
+
distance = normalDistance + Math.sqrt(sqrtDistance) * 5;
|
2056
|
+
}
|
2057
|
+
}
|
2058
|
+
|
2059
|
+
if (distance < 0) {
|
2060
|
+
var normalDistance = stepLength * (_SlideCount - _DisplayPieces - _CurrentSlideIndex);
|
2061
|
+
var sqrtDistance = -distance - normalDistance;
|
2062
|
+
|
2063
|
+
if (sqrtDistance > 0) {
|
2064
|
+
distance = -normalDistance - Math.sqrt(sqrtDistance) * 5;
|
2065
|
+
}
|
2066
|
+
}
|
2067
|
+
}
|
2068
|
+
|
2069
|
+
if (_DragOffsetTotal - _DragOffsetLastTime < -2) {
|
2070
|
+
_DragIndexAdjust = 0;
|
2071
|
+
}
|
2072
|
+
else if (_DragOffsetTotal - _DragOffsetLastTime > 2) {
|
2073
|
+
_DragIndexAdjust = -1;
|
2074
|
+
}
|
2075
|
+
|
2076
|
+
_DragOffsetLastTime = _DragOffsetTotal;
|
2077
|
+
_DragOffsetTotal = distance;
|
2078
|
+
_PositionToGoByDrag = _Position_OnFreeze - _DragOffsetTotal / stepLength / (_ScaleRatio || 1);
|
2079
|
+
|
2080
|
+
if (_DragOffsetTotal && _DragOrientation && !_DragInvalid) {
|
2081
|
+
$Jssor$.$CancelEvent(event);
|
2082
|
+
if (!_IsSliding) {
|
2083
|
+
_CarouselPlayer.$StandBy(_PositionToGoByDrag);
|
2084
|
+
}
|
2085
|
+
else
|
2086
|
+
_CarouselPlayer.$SetStandByPosition(_PositionToGoByDrag);
|
2087
|
+
}
|
2088
|
+
}
|
2089
|
+
}
|
2090
|
+
}
|
2091
|
+
}
|
2092
|
+
|
2093
|
+
function OnDragEnd() {
|
2094
|
+
UnregisterDrag();
|
2095
|
+
|
2096
|
+
if (_IsDragging) {
|
2097
|
+
|
2098
|
+
_IsDragging = false;
|
2099
|
+
|
2100
|
+
_LastTimeMoveByDrag = $Jssor$.$GetNow();
|
2101
|
+
|
2102
|
+
$Jssor$.$RemoveEvent(document, "mousemove", OnDragMove);
|
2103
|
+
$Jssor$.$RemoveEvent(document, "touchmove", OnDragMove);
|
2104
|
+
|
2105
|
+
_LastDragSucceded = _DragOffsetTotal;
|
2106
|
+
|
2107
|
+
_CarouselPlayer.$Stop();
|
2108
|
+
|
2109
|
+
var currentPosition = _Conveyor.$GetPosition();
|
2110
|
+
|
2111
|
+
//Trigger EVT_DRAG_END
|
2112
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_DRAG_END, GetRealIndex(currentPosition), currentPosition, GetRealIndex(_Position_OnFreeze), _Position_OnFreeze);
|
2113
|
+
|
2114
|
+
(_HoverToPause & 12) && RecordFreezePoint();
|
2115
|
+
|
2116
|
+
Unfreeze(true);
|
2117
|
+
}
|
2118
|
+
}
|
2119
|
+
|
2120
|
+
function SlidesClickEventHandler(event) {
|
2121
|
+
if (_LastDragSucceded) {
|
2122
|
+
$Jssor$.$StopEvent(event);
|
2123
|
+
|
2124
|
+
var checkElement = $Jssor$.$EvtSrc(event);
|
2125
|
+
while (checkElement && _SlidesContainer !== checkElement) {
|
2126
|
+
if (checkElement.tagName == "A") {
|
2127
|
+
$Jssor$.$CancelEvent(event);
|
2128
|
+
}
|
2129
|
+
try {
|
2130
|
+
checkElement = checkElement.parentNode;
|
2131
|
+
} catch (e) {
|
2132
|
+
// Firefox sometimes fires events for XUL elements, which throws
|
2133
|
+
// a "permission denied" error. so this is not a child.
|
2134
|
+
break;
|
2135
|
+
}
|
2136
|
+
}
|
2137
|
+
}
|
2138
|
+
}
|
2139
|
+
//#endregion
|
2140
|
+
|
2141
|
+
function SetCurrentSlideIndex(index) {
|
2142
|
+
_PrevSlideItem = _SlideItems[_CurrentSlideIndex];
|
2143
|
+
_PreviousSlideIndex = _CurrentSlideIndex;
|
2144
|
+
_CurrentSlideIndex = GetRealIndex(index);
|
2145
|
+
_CurrentSlideItem = _SlideItems[_CurrentSlideIndex];
|
2146
|
+
ResetNavigator(index);
|
2147
|
+
return _CurrentSlideIndex;
|
2148
|
+
}
|
2149
|
+
|
2150
|
+
function OnPark(slideIndex, prevIndex) {
|
2151
|
+
_DragOrientation = 0;
|
2152
|
+
|
2153
|
+
SetCurrentSlideIndex(slideIndex);
|
2154
|
+
|
2155
|
+
//Trigger EVT_PARK
|
2156
|
+
_SelfSlider.$TriggerEvent($JssorSlider$.$EVT_PARK, GetRealIndex(slideIndex), prevIndex);
|
2157
|
+
}
|
2158
|
+
|
2159
|
+
function ResetNavigator(index, temp) {
|
2160
|
+
_TempSlideIndex = index;
|
2161
|
+
$Jssor$.$Each(_Navigators, function (navigator) {
|
2162
|
+
navigator.$SetCurrentIndex(GetRealIndex(index), index, temp);
|
2163
|
+
});
|
2164
|
+
}
|
2165
|
+
|
2166
|
+
function RegisterDrag() {
|
2167
|
+
var dragRegistry = $JssorSlider$.$DragRegistry || 0;
|
2168
|
+
var dragOrientation = _DragEnabled;
|
2169
|
+
if (_IsTouchDevice)
|
2170
|
+
(dragOrientation & 1) && (dragOrientation &= 1);
|
2171
|
+
$JssorSlider$.$DragRegistry |= dragOrientation;
|
2172
|
+
|
2173
|
+
return (_DragOrientationRegistered = dragOrientation & ~dragRegistry);
|
2174
|
+
}
|
2175
|
+
|
2176
|
+
function UnregisterDrag() {
|
2177
|
+
if (_DragOrientationRegistered) {
|
2178
|
+
$JssorSlider$.$DragRegistry &= ~_DragEnabled;
|
2179
|
+
_DragOrientationRegistered = 0;
|
2180
|
+
}
|
2181
|
+
}
|
2182
|
+
|
2183
|
+
function CreatePanel() {
|
2184
|
+
var div = $Jssor$.$CreateDiv();
|
2185
|
+
|
2186
|
+
$Jssor$.$SetStyles(div, _StyleDef);
|
2187
|
+
$Jssor$.$CssPosition(div, "absolute");
|
2188
|
+
|
2189
|
+
return div;
|
2190
|
+
}
|
2191
|
+
|
2192
|
+
function GetRealIndex(index) {
|
2193
|
+
return (index % _SlideCount + _SlideCount) % _SlideCount;
|
2194
|
+
}
|
2195
|
+
|
2196
|
+
function IsCurrentSlideIndex(index) {
|
2197
|
+
return GetRealIndex(index) == _CurrentSlideIndex;
|
2198
|
+
}
|
2199
|
+
|
2200
|
+
function IsPreviousSlideIndex(index) {
|
2201
|
+
return GetRealIndex(index) == _PreviousSlideIndex;
|
2202
|
+
}
|
2203
|
+
|
2204
|
+
//Navigation Request Handler
|
2205
|
+
function NavigationClickHandler(index, relative) {
|
2206
|
+
if (relative) {
|
2207
|
+
if (!_Loop) {
|
2208
|
+
//Stop at threshold
|
2209
|
+
index = Math.min(Math.max(index + _TempSlideIndex, 0), _SlideCount - _DisplayPieces);
|
2210
|
+
relative = false;
|
2211
|
+
}
|
2212
|
+
else if (_Loop & 2) {
|
2213
|
+
//Rewind
|
2214
|
+
index = GetRealIndex(index + _TempSlideIndex);
|
2215
|
+
relative = false;
|
2216
|
+
}
|
2217
|
+
}
|
2218
|
+
PlayTo(index, _Options.$SlideDuration, relative);
|
2219
|
+
}
|
2220
|
+
|
2221
|
+
function ShowNavigators() {
|
2222
|
+
$Jssor$.$Each(_Navigators, function (navigator) {
|
2223
|
+
navigator.$Show(navigator.$Options.$ChanceToShow <= _NotOnHover);
|
2224
|
+
});
|
2225
|
+
}
|
2226
|
+
|
2227
|
+
function MainContainerMouseLeaveEventHandler() {
|
2228
|
+
if (!_NotOnHover) {
|
2229
|
+
|
2230
|
+
//$JssorDebug$.$Log("mouseleave");
|
2231
|
+
|
2232
|
+
_NotOnHover = 1;
|
2233
|
+
|
2234
|
+
ShowNavigators();
|
2235
|
+
|
2236
|
+
if (!_IsDragging) {
|
2237
|
+
(_HoverToPause & 12) && Unfreeze();
|
2238
|
+
(_HoverToPause & 3) && _SlideItems[_CurrentSlideIndex].$TryActivate();
|
2239
|
+
}
|
2240
|
+
}
|
2241
|
+
}
|
2242
|
+
|
2243
|
+
function MainContainerMouseEnterEventHandler() {
|
2244
|
+
|
2245
|
+
if (_NotOnHover) {
|
2246
|
+
|
2247
|
+
//$JssorDebug$.$Log("mouseenter");
|
2248
|
+
|
2249
|
+
_NotOnHover = 0;
|
2250
|
+
|
2251
|
+
ShowNavigators();
|
2252
|
+
|
2253
|
+
_IsDragging || !(_HoverToPause & 12) || Freeze();
|
2254
|
+
}
|
2255
|
+
}
|
2256
|
+
|
2257
|
+
function AdjustSlidesContainerSize() {
|
2258
|
+
_StyleDef = { $Width: _SlideWidth, $Height: _SlideHeight, $Top: 0, $Left: 0 };
|
2259
|
+
|
2260
|
+
$Jssor$.$Each(_SlideElmts, function (slideElmt, i) {
|
2261
|
+
|
2262
|
+
$Jssor$.$SetStyles(slideElmt, _StyleDef);
|
2263
|
+
$Jssor$.$CssPosition(slideElmt, "absolute");
|
2264
|
+
$Jssor$.$CssOverflow(slideElmt, "hidden");
|
2265
|
+
|
2266
|
+
$Jssor$.$HideElement(slideElmt);
|
2267
|
+
});
|
2268
|
+
|
2269
|
+
$Jssor$.$SetStyles(_LoadingContainer, _StyleDef);
|
2270
|
+
}
|
2271
|
+
|
2272
|
+
function PlayToOffset(offset, slideDuration) {
|
2273
|
+
PlayTo(offset, slideDuration, true);
|
2274
|
+
}
|
2275
|
+
|
2276
|
+
function PlayTo(slideIndex, slideDuration, relative) {
|
2277
|
+
/// <summary>
|
2278
|
+
/// PlayTo( slideIndex [, slideDuration] ); //Play slider to position 'slideIndex' within a period calculated base on 'slideDuration'.
|
2279
|
+
/// </summary>
|
2280
|
+
/// <param name="slideIndex" type="Number">
|
2281
|
+
/// slide slideIndex or position will be playing to
|
2282
|
+
/// </param>
|
2283
|
+
/// <param name="slideDuration" type="Number" optional="true">
|
2284
|
+
/// base slide duration in milliseconds to calculate the whole duration to complete this play request.
|
2285
|
+
/// default value is '$SlideDuration' value which is specified when initialize the slider.
|
2286
|
+
/// </param>
|
2287
|
+
/// http://msdn.microsoft.com/en-us/library/vstudio/bb385682.aspx
|
2288
|
+
/// http://msdn.microsoft.com/en-us/library/vstudio/hh542720.aspx
|
2289
|
+
if (_CarouselEnabled && (!_IsDragging || _Options.$NaviQuitDrag)) {
|
2290
|
+
_IsSliding = true;
|
2291
|
+
_IsDragging = false;
|
2292
|
+
_CarouselPlayer.$Stop();
|
2293
|
+
|
2294
|
+
{
|
2295
|
+
//Slide Duration
|
2296
|
+
if (slideDuration == undefined)
|
2297
|
+
slideDuration = _SlideDuration;
|
2298
|
+
|
2299
|
+
var positionDisplay = _Carousel.$GetPosition_Display();
|
2300
|
+
var positionTo = slideIndex;
|
2301
|
+
if (relative) {
|
2302
|
+
positionTo = positionDisplay + slideIndex;
|
2303
|
+
if (slideIndex > 0)
|
2304
|
+
positionTo = Math.ceil(positionTo);
|
2305
|
+
else
|
2306
|
+
positionTo = Math.floor(positionTo);
|
2307
|
+
}
|
2308
|
+
|
2309
|
+
if (_Loop & 2) {
|
2310
|
+
//Rewind
|
2311
|
+
positionTo = GetRealIndex(positionTo);
|
2312
|
+
}
|
2313
|
+
if (!(_Loop & 1)) {
|
2314
|
+
//Stop at threshold
|
2315
|
+
positionTo = Math.max(0, Math.min(positionTo, _SlideCount - _DisplayPieces));
|
2316
|
+
}
|
2317
|
+
|
2318
|
+
var positionOffset = (positionTo - positionDisplay) % _SlideCount;
|
2319
|
+
positionTo = positionDisplay + positionOffset;
|
2320
|
+
|
2321
|
+
var duration = positionDisplay == positionTo ? 0 : slideDuration * Math.abs(positionOffset);
|
2322
|
+
duration = Math.min(duration, slideDuration * _DisplayPieces * 1.5);
|
2323
|
+
|
2324
|
+
_CarouselPlayer.$PlayCarousel(positionDisplay, positionTo, duration || 1);
|
2325
|
+
}
|
2326
|
+
}
|
2327
|
+
}
|
2328
|
+
|
2329
|
+
//private functions
|
2330
|
+
|
2331
|
+
//member functions
|
2332
|
+
|
2333
|
+
_SelfSlider.$PlayTo = PlayTo;
|
2334
|
+
|
2335
|
+
_SelfSlider.$GoTo = function (slideIndex) {
|
2336
|
+
/// <summary>
|
2337
|
+
/// instance.$GoTo( slideIndex ); //Go to the specifed slide immediately with no play.
|
2338
|
+
/// </summary>
|
2339
|
+
PlayTo(slideIndex, 1);
|
2340
|
+
};
|
2341
|
+
|
2342
|
+
_SelfSlider.$Next = function () {
|
2343
|
+
/// <summary>
|
2344
|
+
/// instance.$Next(); //Play the slider to next slide.
|
2345
|
+
/// </summary>
|
2346
|
+
PlayToOffset(1);
|
2347
|
+
};
|
2348
|
+
|
2349
|
+
_SelfSlider.$Prev = function () {
|
2350
|
+
/// <summary>
|
2351
|
+
/// instance.$Prev(); //Play the slider to previous slide.
|
2352
|
+
/// </summary>
|
2353
|
+
PlayToOffset(-1);
|
2354
|
+
};
|
2355
|
+
|
2356
|
+
_SelfSlider.$Pause = function () {
|
2357
|
+
/// <summary>
|
2358
|
+
/// instance.$Pause(); //Pause the slider, prevent it from auto playing.
|
2359
|
+
/// </summary>
|
2360
|
+
_AutoPlay = false;
|
2361
|
+
};
|
2362
|
+
|
2363
|
+
_SelfSlider.$Play = function () {
|
2364
|
+
/// <summary>
|
2365
|
+
/// instance.$Play(); //Start auto play if the slider is currently paused.
|
2366
|
+
/// </summary>
|
2367
|
+
if (!_AutoPlay) {
|
2368
|
+
_AutoPlay = true;
|
2369
|
+
_SlideItems[_CurrentSlideIndex] && _SlideItems[_CurrentSlideIndex].$TryActivate();
|
2370
|
+
}
|
2371
|
+
};
|
2372
|
+
|
2373
|
+
_SelfSlider.$SetSlideshowTransitions = function (transitions) {
|
2374
|
+
/// <summary>
|
2375
|
+
/// instance.$SetSlideshowTransitions( transitions ); //Reset slideshow transitions for the slider.
|
2376
|
+
/// </summary>
|
2377
|
+
$JssorDebug$.$Execute(function () {
|
2378
|
+
if (!transitions || !transitions.length) {
|
2379
|
+
$JssorDebug$.$Error("Can not set slideshow transitions, no transitions specified.");
|
2380
|
+
}
|
2381
|
+
});
|
2382
|
+
|
2383
|
+
//$Jssor$.$TranslateTransitions(transitions); //for old transition compatibility
|
2384
|
+
_Options.$SlideshowOptions.$Transitions = transitions;
|
2385
|
+
};
|
2386
|
+
|
2387
|
+
_SelfSlider.$SetCaptionTransitions = function (transitions) {
|
2388
|
+
/// <summary>
|
2389
|
+
/// instance.$SetCaptionTransitions( transitions ); //Reset caption transitions for the slider.
|
2390
|
+
/// </summary>
|
2391
|
+
$JssorDebug$.$Execute(function () {
|
2392
|
+
if (!transitions || !transitions.length) {
|
2393
|
+
$JssorDebug$.$Error("Can not set caption transitions, no transitions specified");
|
2394
|
+
}
|
2395
|
+
});
|
2396
|
+
|
2397
|
+
//$Jssor$.$TranslateTransitions(transitions); //for old transition compatibility
|
2398
|
+
_CaptionSliderOptions.$CaptionTransitions = transitions;
|
2399
|
+
_CaptionSliderOptions.$Version = $Jssor$.$GetNow();
|
2400
|
+
};
|
2401
|
+
|
2402
|
+
_SelfSlider.$SlidesCount = function () {
|
2403
|
+
/// <summary>
|
2404
|
+
/// instance.$SlidesCount(); //Retrieve slides count of the slider.
|
2405
|
+
/// </summary>
|
2406
|
+
return _SlideElmts.length;
|
2407
|
+
};
|
2408
|
+
|
2409
|
+
_SelfSlider.$CurrentIndex = function () {
|
2410
|
+
/// <summary>
|
2411
|
+
/// instance.$CurrentIndex(); //Retrieve current slide index of the slider.
|
2412
|
+
/// </summary>
|
2413
|
+
return _CurrentSlideIndex;
|
2414
|
+
};
|
2415
|
+
|
2416
|
+
_SelfSlider.$IsAutoPlaying = function () {
|
2417
|
+
/// <summary>
|
2418
|
+
/// instance.$IsAutoPlaying(); //Retrieve auto play status of the slider.
|
2419
|
+
/// </summary>
|
2420
|
+
return _AutoPlay;
|
2421
|
+
};
|
2422
|
+
|
2423
|
+
_SelfSlider.$IsDragging = function () {
|
2424
|
+
/// <summary>
|
2425
|
+
/// instance.$IsDragging(); //Retrieve drag status of the slider.
|
2426
|
+
/// </summary>
|
2427
|
+
return _IsDragging;
|
2428
|
+
};
|
2429
|
+
|
2430
|
+
_SelfSlider.$IsSliding = function () {
|
2431
|
+
/// <summary>
|
2432
|
+
/// instance.$IsSliding(); //Retrieve right<-->left sliding status of the slider.
|
2433
|
+
/// </summary>
|
2434
|
+
return _IsSliding;
|
2435
|
+
};
|
2436
|
+
|
2437
|
+
_SelfSlider.$IsMouseOver = function () {
|
2438
|
+
/// <summary>
|
2439
|
+
/// instance.$IsMouseOver(); //Retrieve mouse over status of the slider.
|
2440
|
+
/// </summary>
|
2441
|
+
return !_NotOnHover;
|
2442
|
+
};
|
2443
|
+
|
2444
|
+
_SelfSlider.$LastDragSucceded = function () {
|
2445
|
+
/// <summary>
|
2446
|
+
/// instance.$IsLastDragSucceded(); //Retrieve last drag succeded status, returns 0 if failed, returns drag offset if succeded
|
2447
|
+
/// </summary>
|
2448
|
+
return _LastDragSucceded;
|
2449
|
+
};
|
2450
|
+
|
2451
|
+
function OriginalWidth() {
|
2452
|
+
/// <summary>
|
2453
|
+
/// instance.$OriginalWidth(); //Retrieve original width of the slider.
|
2454
|
+
/// </summary>
|
2455
|
+
return $Jssor$.$CssWidth(_ScaleWrapper || elmt);
|
2456
|
+
}
|
2457
|
+
|
2458
|
+
function OriginalHeight() {
|
2459
|
+
/// <summary>
|
2460
|
+
/// instance.$OriginalHeight(); //Retrieve original height of the slider.
|
2461
|
+
/// </summary>
|
2462
|
+
return $Jssor$.$CssHeight(_ScaleWrapper || elmt);
|
2463
|
+
}
|
2464
|
+
|
2465
|
+
_SelfSlider.$OriginalWidth = _SelfSlider.$GetOriginalWidth = OriginalWidth;
|
2466
|
+
|
2467
|
+
_SelfSlider.$OriginalHeight = _SelfSlider.$GetOriginalHeight = OriginalHeight;
|
2468
|
+
|
2469
|
+
function Scale(dimension, isHeight) {
|
2470
|
+
/// <summary>
|
2471
|
+
/// instance.$ScaleWidth(); //Retrieve scaled dimension the slider currently displays.
|
2472
|
+
/// instance.$ScaleWidth( dimension ); //Scale the slider to new width and keep aspect ratio.
|
2473
|
+
/// </summary>
|
2474
|
+
|
2475
|
+
if (dimension == undefined)
|
2476
|
+
return $Jssor$.$CssWidth(elmt);
|
2477
|
+
|
2478
|
+
if (!_ScaleWrapper) {
|
2479
|
+
$JssorDebug$.$Execute(function () {
|
2480
|
+
var originalWidthStr = $Jssor$.$Css(elmt, "width");
|
2481
|
+
var originalHeightStr = $Jssor$.$Css(elmt, "height");
|
2482
|
+
var originalWidth = $Jssor$.$CssP(elmt, "width");
|
2483
|
+
var originalHeight = $Jssor$.$CssP(elmt, "height");
|
2484
|
+
|
2485
|
+
if (!originalWidthStr || originalWidthStr.indexOf("px") == -1) {
|
2486
|
+
$JssorDebug$.$Fail("Cannot scale jssor slider, 'width' of 'outer container' not specified. Please specify 'width' in pixel. e.g. 'width: 600px;'");
|
2487
|
+
}
|
2488
|
+
|
2489
|
+
if (!originalHeightStr || originalHeightStr.indexOf("px") == -1) {
|
2490
|
+
$JssorDebug$.$Fail("Cannot scale jssor slider, 'height' of 'outer container' not specified. Please specify 'height' in pixel. e.g. 'height: 300px;'");
|
2491
|
+
}
|
2492
|
+
|
2493
|
+
if (originalWidthStr.indexOf('%') != -1) {
|
2494
|
+
$JssorDebug$.$Fail("Cannot scale jssor slider, 'width' of 'outer container' not valid. Please specify 'width' in pixel. e.g. 'width: 600px;'");
|
2495
|
+
}
|
2496
|
+
|
2497
|
+
if (originalHeightStr.indexOf('%') != -1) {
|
2498
|
+
$JssorDebug$.$Fail("Cannot scale jssor slider, 'height' of 'outer container' not valid. Please specify 'height' in pixel. e.g. 'height: 300px;'");
|
2499
|
+
}
|
2500
|
+
|
2501
|
+
if (!originalWidth) {
|
2502
|
+
$JssorDebug$.$Fail("Cannot scale jssor slider, 'width' of 'outer container' not valid. 'width' of 'outer container' should be positive number. e.g. 'width: 600px;'");
|
2503
|
+
}
|
2504
|
+
|
2505
|
+
if (!originalHeight) {
|
2506
|
+
$JssorDebug$.$Fail("Cannot scale jssor slider, 'height' of 'outer container' not valid. 'height' of 'outer container' should be positive number. e.g. 'height: 300px;'");
|
2507
|
+
}
|
2508
|
+
});
|
2509
|
+
|
2510
|
+
var innerWrapper = $Jssor$.$CreateDiv(document);
|
2511
|
+
$Jssor$.$ClassName(innerWrapper, $Jssor$.$ClassName(elmt));
|
2512
|
+
$Jssor$.$CssCssText(innerWrapper, $Jssor$.$CssCssText(elmt));
|
2513
|
+
$Jssor$.$CssDisplay(innerWrapper, "block");
|
2514
|
+
|
2515
|
+
$Jssor$.$CssPosition(innerWrapper, "relative");
|
2516
|
+
$Jssor$.$CssTop(innerWrapper, 0);
|
2517
|
+
$Jssor$.$CssLeft(innerWrapper, 0);
|
2518
|
+
$Jssor$.$CssOverflow(innerWrapper, "visible");
|
2519
|
+
|
2520
|
+
_ScaleWrapper = $Jssor$.$CreateDiv(document);
|
2521
|
+
|
2522
|
+
$Jssor$.$CssPosition(_ScaleWrapper, "absolute");
|
2523
|
+
$Jssor$.$CssTop(_ScaleWrapper, 0);
|
2524
|
+
$Jssor$.$CssLeft(_ScaleWrapper, 0);
|
2525
|
+
$Jssor$.$CssWidth(_ScaleWrapper, $Jssor$.$CssWidth(elmt));
|
2526
|
+
$Jssor$.$CssHeight(_ScaleWrapper, $Jssor$.$CssHeight(elmt));
|
2527
|
+
$Jssor$.$SetStyleTransformOrigin(_ScaleWrapper, "0 0");
|
2528
|
+
|
2529
|
+
$Jssor$.$AppendChild(_ScaleWrapper, innerWrapper);
|
2530
|
+
|
2531
|
+
var children = $Jssor$.$Children(elmt);
|
2532
|
+
$Jssor$.$AppendChild(elmt, _ScaleWrapper);
|
2533
|
+
|
2534
|
+
$Jssor$.$Css(elmt, "backgroundImage", "");
|
2535
|
+
|
2536
|
+
//var noMoveElmts = {
|
2537
|
+
// "navigator": _BulletNavigatorOptions && _BulletNavigatorOptions.$Scale == false,
|
2538
|
+
// "arrowleft": _ArrowNavigatorOptions && _ArrowNavigatorOptions.$Scale == false,
|
2539
|
+
// "arrowright": _ArrowNavigatorOptions && _ArrowNavigatorOptions.$Scale == false,
|
2540
|
+
// "thumbnavigator": _ThumbnailNavigatorOptions && _ThumbnailNavigatorOptions.$Scale == false,
|
2541
|
+
// "thumbwrapper": _ThumbnailNavigatorOptions && _ThumbnailNavigatorOptions.$Scale == false
|
2542
|
+
//};
|
2543
|
+
|
2544
|
+
$Jssor$.$Each(children, function (child) {
|
2545
|
+
$Jssor$.$AppendChild($Jssor$.$AttributeEx(child, "noscale") ? elmt : innerWrapper, child);
|
2546
|
+
//$Jssor$.$AppendChild(noMoveElmts[$Jssor$.$AttributeEx(child, "u")] ? elmt : innerWrapper, child);
|
2547
|
+
});
|
2548
|
+
}
|
2549
|
+
|
2550
|
+
$JssorDebug$.$Execute(function () {
|
2551
|
+
if (!dimension || dimension < 0) {
|
2552
|
+
$JssorDebug$.$Fail("'$ScaleWidth' error, 'dimension' should be positive value.");
|
2553
|
+
}
|
2554
|
+
});
|
2555
|
+
|
2556
|
+
$JssorDebug$.$Execute(function () {
|
2557
|
+
if (!_InitialScrollWidth) {
|
2558
|
+
_InitialScrollWidth = _SelfSlider.$Elmt.scrollWidth;
|
2559
|
+
}
|
2560
|
+
});
|
2561
|
+
|
2562
|
+
_ScaleRatio = dimension / (isHeight ? $Jssor$.$CssHeight : $Jssor$.$CssWidth)(_ScaleWrapper);
|
2563
|
+
$Jssor$.$CssScale(_ScaleWrapper, _ScaleRatio);
|
2564
|
+
|
2565
|
+
var scaleWidth = isHeight ? (_ScaleRatio * OriginalWidth()) : dimension;
|
2566
|
+
var scaleHeight = isHeight ? dimension : (_ScaleRatio * OriginalHeight());
|
2567
|
+
|
2568
|
+
$Jssor$.$CssWidth(elmt, scaleWidth);
|
2569
|
+
$Jssor$.$CssHeight(elmt, scaleHeight);
|
2570
|
+
|
2571
|
+
$Jssor$.$Each(_Navigators, function (navigator) {
|
2572
|
+
navigator.$Relocate(scaleWidth, scaleHeight);
|
2573
|
+
});
|
2574
|
+
}
|
2575
|
+
|
2576
|
+
_SelfSlider.$ScaleHeight = _SelfSlider.$GetScaleHeight = function (height) {
|
2577
|
+
/// <summary>
|
2578
|
+
/// instance.$ScaleHeight(); //Retrieve scaled height the slider currently displays.
|
2579
|
+
/// instance.$ScaleHeight( dimension ); //Scale the slider to new height and keep aspect ratio.
|
2580
|
+
/// </summary>
|
2581
|
+
|
2582
|
+
if (height == undefined)
|
2583
|
+
return $Jssor$.$CssHeight(elmt);
|
2584
|
+
|
2585
|
+
Scale(height, true);
|
2586
|
+
};
|
2587
|
+
|
2588
|
+
_SelfSlider.$ScaleWidth = _SelfSlider.$SetScaleWidth = _SelfSlider.$GetScaleWidth = Scale;
|
2589
|
+
|
2590
|
+
_SelfSlider.$GetVirtualIndex = function (index) {
|
2591
|
+
var parkingIndex = Math.ceil(GetRealIndex(_ParkingPosition / _StepLength));
|
2592
|
+
var displayIndex = GetRealIndex(index - _CurrentSlideIndex + parkingIndex);
|
2593
|
+
|
2594
|
+
if (displayIndex > _DisplayPieces) {
|
2595
|
+
if (index - _CurrentSlideIndex > _SlideCount / 2)
|
2596
|
+
index -= _SlideCount;
|
2597
|
+
else if (index - _CurrentSlideIndex <= -_SlideCount / 2)
|
2598
|
+
index += _SlideCount;
|
2599
|
+
}
|
2600
|
+
else {
|
2601
|
+
index = _CurrentSlideIndex + displayIndex - parkingIndex;
|
2602
|
+
}
|
2603
|
+
|
2604
|
+
return index;
|
2605
|
+
};
|
2606
|
+
|
2607
|
+
//member functions
|
2608
|
+
|
2609
|
+
$JssorObject$.call(_SelfSlider);
|
2610
|
+
|
2611
|
+
$JssorDebug$.$Execute(function () {
|
2612
|
+
var outerContainerElmt = $Jssor$.$GetElement(elmt);
|
2613
|
+
if (!outerContainerElmt)
|
2614
|
+
$JssorDebug$.$Fail("Outer container '" + elmt + "' not found.");
|
2615
|
+
});
|
2616
|
+
|
2617
|
+
//initialize member variables
|
2618
|
+
_SelfSlider.$Elmt = elmt = $Jssor$.$GetElement(elmt);
|
2619
|
+
//initialize member variables
|
2620
|
+
|
2621
|
+
var _InitialScrollWidth; //for debug only
|
2622
|
+
var _CaptionSliderCount = 1; //for debug only
|
2623
|
+
|
2624
|
+
var _Options = $Jssor$.$Extend({
|
2625
|
+
$FillMode: 0, //[Optional] The way to fill image in slide, 0 stretch, 1 contain (keep aspect ratio and put all inside slide), 2 cover (keep aspect ratio and cover whole slide), 4 actual size, 5 contain for large image, actual size for small image, default value is 0
|
2626
|
+
$LazyLoading: 1, //[Optional] For image with lazy loading format (<IMG src2="url" .../>), by default it will be loaded only when the slide comes.
|
2627
|
+
//But an integer value (maybe 0, 1, 2 or 3) indicates that how far of nearby slides should be loaded immediately as well, default value is 1.
|
2628
|
+
$StartIndex: 0, //[Optional] Index of slide to display when initialize, default value is 0
|
2629
|
+
$AutoPlay: false, //[Optional] Whether to auto play, default value is false
|
2630
|
+
$Loop: 1, //[Optional] Enable loop(circular) of carousel or not, 0: stop, 1: loop, 2 rewind, default value is 1
|
2631
|
+
$HWA: true, //[Optional] Enable hardware acceleration or not, default value is true
|
2632
|
+
$NaviQuitDrag: true,
|
2633
|
+
$AutoPlaySteps: 1, //[Optional] Steps to go of every play (this options applys only when slideshow disabled), default value is 1
|
2634
|
+
$AutoPlayInterval: 3000, //[Optional] Interval to play next slide since the previous stopped if a slideshow is auto playing, default value is 3000
|
2635
|
+
$PauseOnHover: 1, //[Optional] Whether to pause when mouse over if a slider is auto playing, 0 no pause, 1 pause for desktop, 2 pause for touch device, 3 pause for desktop and touch device, 4 freeze for desktop, 8 freeze for touch device, 12 freeze for desktop and touch device, default value is 1
|
2636
|
+
|
2637
|
+
$SlideDuration: 500, //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 400
|
2638
|
+
$SlideEasing: $JssorEasing$.$EaseOutQuad, //[Optional] Specifies easing for right to left animation, default value is $JssorEasing$.$EaseOutQuad
|
2639
|
+
$MinDragOffsetToSlide: 20, //[Optional] Minimum drag offset that trigger slide, default value is 20
|
2640
|
+
$SlideSpacing: 0, //[Optional] Space between each slide in pixels, default value is 0
|
2641
|
+
$DisplayPieces: 1, //[Optional] Number of pieces to display (the slideshow would be disabled if the value is set to greater than 1), default value is 1
|
2642
|
+
$ParkingPosition: 0, //[Optional] The offset position to park slide (this options applys only when slideshow disabled), default value is 0.
|
2643
|
+
$UISearchMode: 1, //[Optional] The way (0 parellel, 1 recursive, default value is recursive) to search UI components (slides container, loading screen, navigator container, arrow navigator container, thumbnail navigator container etc.
|
2644
|
+
$PlayOrientation: 1, //[Optional] Orientation to play slide (for auto play, navigation), 1 horizental, 2 vertical, 5 horizental reverse, 6 vertical reverse, default value is 1
|
2645
|
+
$DragOrientation: 1 //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 both, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $DisplayPieces is greater than 1, or parking position is not 0)
|
2646
|
+
|
2647
|
+
}, options);
|
2648
|
+
|
2649
|
+
//going to use $Idle instead of $AutoPlayInterval
|
2650
|
+
if (_Options.$Idle != undefined)
|
2651
|
+
_Options.$AutoPlayInterval = _Options.$Idle;
|
2652
|
+
|
2653
|
+
//going to use $Cols instead of $DisplayPieces
|
2654
|
+
if (_Options.$Cols != undefined)
|
2655
|
+
_Options.$DisplayPieces = _Options.$Cols;
|
2656
|
+
|
2657
|
+
//Sodo statement for development time intellisence only
|
2658
|
+
$JssorDebug$.$Execute(function () {
|
2659
|
+
_Options = $Jssor$.$Extend({
|
2660
|
+
$ArrowKeyNavigation: undefined,
|
2661
|
+
$SlideWidth: undefined,
|
2662
|
+
$SlideHeight: undefined,
|
2663
|
+
$SlideshowOptions: undefined,
|
2664
|
+
$CaptionSliderOptions: undefined,
|
2665
|
+
$BulletNavigatorOptions: undefined,
|
2666
|
+
$ArrowNavigatorOptions: undefined,
|
2667
|
+
$ThumbnailNavigatorOptions: undefined
|
2668
|
+
},
|
2669
|
+
_Options);
|
2670
|
+
});
|
2671
|
+
|
2672
|
+
var _PlayOrientation = _Options.$PlayOrientation & 3;
|
2673
|
+
var _PlayReverse = (_Options.$PlayOrientation & 4) / -4 || 1;
|
2674
|
+
|
2675
|
+
var _SlideshowOptions = _Options.$SlideshowOptions;
|
2676
|
+
var _CaptionSliderOptions = $Jssor$.$Extend({ $Class: $JssorCaptionSliderBase$, $PlayInMode: 1, $PlayOutMode: 1 }, _Options.$CaptionSliderOptions);
|
2677
|
+
//$Jssor$.$TranslateTransitions(_CaptionSliderOptions.$CaptionTransitions); //for old transition compatibility
|
2678
|
+
var _BulletNavigatorOptions = _Options.$BulletNavigatorOptions;
|
2679
|
+
var _ArrowNavigatorOptions = _Options.$ArrowNavigatorOptions;
|
2680
|
+
var _ThumbnailNavigatorOptions = _Options.$ThumbnailNavigatorOptions;
|
2681
|
+
|
2682
|
+
$JssorDebug$.$Execute(function () {
|
2683
|
+
if (_SlideshowOptions && !_SlideshowOptions.$Class) {
|
2684
|
+
$JssorDebug$.$Fail("Option $SlideshowOptions error, class not specified.");
|
2685
|
+
}
|
2686
|
+
});
|
2687
|
+
|
2688
|
+
$JssorDebug$.$Execute(function () {
|
2689
|
+
if (_Options.$CaptionSliderOptions && !_Options.$CaptionSliderOptions.$Class) {
|
2690
|
+
$JssorDebug$.$Fail("Option $CaptionSliderOptions error, class not specified.");
|
2691
|
+
}
|
2692
|
+
});
|
2693
|
+
|
2694
|
+
$JssorDebug$.$Execute(function () {
|
2695
|
+
if (_BulletNavigatorOptions && !_BulletNavigatorOptions.$Class) {
|
2696
|
+
$JssorDebug$.$Fail("Option $BulletNavigatorOptions error, class not specified.");
|
2697
|
+
}
|
2698
|
+
});
|
2699
|
+
|
2700
|
+
$JssorDebug$.$Execute(function () {
|
2701
|
+
if (_ArrowNavigatorOptions && !_ArrowNavigatorOptions.$Class) {
|
2702
|
+
$JssorDebug$.$Fail("Option $ArrowNavigatorOptions error, class not specified.");
|
2703
|
+
}
|
2704
|
+
});
|
2705
|
+
|
2706
|
+
$JssorDebug$.$Execute(function () {
|
2707
|
+
if (_ThumbnailNavigatorOptions && !_ThumbnailNavigatorOptions.$Class) {
|
2708
|
+
$JssorDebug$.$Fail("Option $ThumbnailNavigatorOptions error, class not specified.");
|
2709
|
+
}
|
2710
|
+
});
|
2711
|
+
|
2712
|
+
var _UISearchNoDeep = !_Options.$UISearchMode;
|
2713
|
+
var _ScaleWrapper;
|
2714
|
+
var _SlidesContainer = $Jssor$.$FindChild(elmt, "slides", _UISearchNoDeep);
|
2715
|
+
var _LoadingContainer = $Jssor$.$FindChild(elmt, "loading", _UISearchNoDeep) || $Jssor$.$CreateDiv(document);
|
2716
|
+
|
2717
|
+
var _BulletNavigatorContainer = $Jssor$.$FindChild(elmt, "navigator", _UISearchNoDeep);
|
2718
|
+
|
2719
|
+
var _ArrowLeft = $Jssor$.$FindChild(elmt, "arrowleft", _UISearchNoDeep);
|
2720
|
+
var _ArrowRight = $Jssor$.$FindChild(elmt, "arrowright", _UISearchNoDeep);
|
2721
|
+
|
2722
|
+
var _ThumbnailNavigatorContainer = $Jssor$.$FindChild(elmt, "thumbnavigator", _UISearchNoDeep);
|
2723
|
+
|
2724
|
+
$JssorDebug$.$Execute(function () {
|
2725
|
+
//if (_BulletNavigatorOptions && !_BulletNavigatorContainer) {
|
2726
|
+
// throw new Error("$BulletNavigatorOptions specified but bullet navigator container (<div u=\"navigator\" ...) not defined.");
|
2727
|
+
//}
|
2728
|
+
if (_BulletNavigatorContainer && !_BulletNavigatorOptions) {
|
2729
|
+
throw new Error("Bullet navigator container defined but $BulletNavigatorOptions not specified.");
|
2730
|
+
}
|
2731
|
+
|
2732
|
+
//if (_ArrowNavigatorOptions) {
|
2733
|
+
// if (!_ArrowLeft) {
|
2734
|
+
// throw new Error("$ArrowNavigatorOptions specified, but arrowleft (<span u=\"arrowleft\" ...) not defined.");
|
2735
|
+
// }
|
2736
|
+
|
2737
|
+
// if (!_ArrowRight) {
|
2738
|
+
// throw new Error("$ArrowNavigatorOptions specified, but arrowright (<span u=\"arrowright\" ...) not defined.");
|
2739
|
+
// }
|
2740
|
+
//}
|
2741
|
+
|
2742
|
+
if ((_ArrowLeft || _ArrowRight) && !_ArrowNavigatorOptions) {
|
2743
|
+
throw new Error("arrowleft or arrowright defined, but $ArrowNavigatorOptions not specified.");
|
2744
|
+
}
|
2745
|
+
|
2746
|
+
//if (_ThumbnailNavigatorOptions && !_ThumbnailNavigatorContainer) {
|
2747
|
+
// throw new Error("$ThumbnailNavigatorOptions specified, but thumbnail navigator container (<div u=\"thumbnavigator\" ...) not defined.");
|
2748
|
+
//}
|
2749
|
+
|
2750
|
+
if (_ThumbnailNavigatorContainer && !_ThumbnailNavigatorOptions) {
|
2751
|
+
throw new Error("Thumbnail navigator container defined, but $ThumbnailNavigatorOptions not specified.");
|
2752
|
+
}
|
2753
|
+
});
|
2754
|
+
|
2755
|
+
var _SlidesContainerWidth = $Jssor$.$CssWidth(_SlidesContainer);
|
2756
|
+
var _SlidesContainerHeight = $Jssor$.$CssHeight(_SlidesContainer);
|
2757
|
+
|
2758
|
+
$JssorDebug$.$Execute(function () {
|
2759
|
+
if (isNaN(_SlidesContainerWidth))
|
2760
|
+
$JssorDebug$.$Fail("Width of slides container wrong specification, it should be specified in pixel (like style='width: 600px;').");
|
2761
|
+
|
2762
|
+
if (_SlidesContainerWidth == undefined)
|
2763
|
+
$JssorDebug$.$Fail("Width of slides container not specified, it should be specified in pixel (like style='width: 600px;').");
|
2764
|
+
|
2765
|
+
if (isNaN(_SlidesContainerHeight))
|
2766
|
+
$JssorDebug$.$Fail("Height of slides container wrong specification, it should be specified in pixel (like style='height: 300px;').");
|
2767
|
+
|
2768
|
+
if (_SlidesContainerHeight == undefined)
|
2769
|
+
$JssorDebug$.$Fail("Height of slides container not specified, it should be specified in pixel (like style='height: 300px;').");
|
2770
|
+
|
2771
|
+
var slidesContainerOverflow = $Jssor$.$CssOverflow(_SlidesContainer);
|
2772
|
+
var slidesContainerOverflowX = $Jssor$.$Css(_SlidesContainer, "overflowX");
|
2773
|
+
var slidesContainerOverflowY = $Jssor$.$Css(_SlidesContainer, "overflowY");
|
2774
|
+
if (slidesContainerOverflow != "hidden" && (slidesContainerOverflowX != "hidden" || slidesContainerOverflowY != "hidden"))
|
2775
|
+
$JssorDebug$.$Fail("Overflow of slides container wrong specification, it should be specified as 'hidden' (style='overflow:hidden;').");
|
2776
|
+
});
|
2777
|
+
|
2778
|
+
$JssorDebug$.$Execute(function () {
|
2779
|
+
if (!$Jssor$.$IsNumeric(_Options.$DisplayPieces))
|
2780
|
+
$JssorDebug$.$Fail("Option $DisplayPieces error, it should be a numeric value and greater than or equal to 1.");
|
2781
|
+
|
2782
|
+
if (_Options.$DisplayPieces < 1)
|
2783
|
+
$JssorDebug$.$Fail("Option $DisplayPieces error, it should be greater than or equal to 1.");
|
2784
|
+
|
2785
|
+
if (_Options.$DisplayPieces > 1 && _Options.$DragOrientation && _Options.$DragOrientation != _PlayOrientation)
|
2786
|
+
$JssorDebug$.$Fail("Option $DragOrientation error, it should be 0 or the same of $PlayOrientation when $DisplayPieces is greater than 1.");
|
2787
|
+
|
2788
|
+
if (!$Jssor$.$IsNumeric(_Options.$ParkingPosition))
|
2789
|
+
$JssorDebug$.$Fail("Option $ParkingPosition error, it should be a numeric value.");
|
2790
|
+
|
2791
|
+
if (_Options.$ParkingPosition && _Options.$DragOrientation && _Options.$DragOrientation != _PlayOrientation)
|
2792
|
+
$JssorDebug$.$Fail("Option $DragOrientation error, it should be 0 or the same of $PlayOrientation when $ParkingPosition is not equal to 0.");
|
2793
|
+
});
|
2794
|
+
|
2795
|
+
var _StyleDef;
|
2796
|
+
|
2797
|
+
var _SlideElmts = [];
|
2798
|
+
|
2799
|
+
{
|
2800
|
+
var slideElmts = $Jssor$.$Children(_SlidesContainer);
|
2801
|
+
$Jssor$.$Each(slideElmts, function (slideElmt) {
|
2802
|
+
if (slideElmt.tagName == "DIV" && !$Jssor$.$AttributeEx(slideElmt, "u")) {
|
2803
|
+
_SlideElmts.push(slideElmt);
|
2804
|
+
}
|
2805
|
+
else if ($Jssor$.$IsBrowserIe9Earlier()) {
|
2806
|
+
$Jssor$.$CssZIndex(slideElmt, ($Jssor$.$CssZIndex(slideElmt) || 0) + 1);
|
2807
|
+
}
|
2808
|
+
});
|
2809
|
+
}
|
2810
|
+
|
2811
|
+
$JssorDebug$.$Execute(function () {
|
2812
|
+
if (_SlideElmts.length < 1) {
|
2813
|
+
$JssorDebug$.$Error("Slides html code definition error, there must be at least 1 slide to initialize a slider.");
|
2814
|
+
}
|
2815
|
+
});
|
2816
|
+
|
2817
|
+
var _SlideItemCreatedCount = 0; //for debug only
|
2818
|
+
var _SlideItemReleasedCount = 0; //for debug only
|
2819
|
+
|
2820
|
+
var _PreviousSlideIndex;
|
2821
|
+
var _CurrentSlideIndex = -1;
|
2822
|
+
var _TempSlideIndex;
|
2823
|
+
var _PrevSlideItem;
|
2824
|
+
var _CurrentSlideItem;
|
2825
|
+
var _SlideCount = _SlideElmts.length;
|
2826
|
+
|
2827
|
+
var _SlideWidth = _Options.$SlideWidth || _SlidesContainerWidth;
|
2828
|
+
var _SlideHeight = _Options.$SlideHeight || _SlidesContainerHeight;
|
2829
|
+
|
2830
|
+
var _SlideSpacing = _Options.$SlideSpacing;
|
2831
|
+
var _StepLengthX = _SlideWidth + _SlideSpacing;
|
2832
|
+
var _StepLengthY = _SlideHeight + _SlideSpacing;
|
2833
|
+
var _StepLength = (_PlayOrientation & 1) ? _StepLengthX : _StepLengthY;
|
2834
|
+
var _DisplayPieces = Math.min(_Options.$DisplayPieces, _SlideCount);
|
2835
|
+
|
2836
|
+
var _SlideshowPanel;
|
2837
|
+
var _CurrentBoardIndex = 0;
|
2838
|
+
var _DragOrientation;
|
2839
|
+
var _DragOrientationRegistered;
|
2840
|
+
var _DragInvalid;
|
2841
|
+
|
2842
|
+
var _Navigators = [];
|
2843
|
+
var _BulletNavigator;
|
2844
|
+
var _ArrowNavigator;
|
2845
|
+
var _ThumbnailNavigator;
|
2846
|
+
|
2847
|
+
var _ShowLink;
|
2848
|
+
|
2849
|
+
var _Frozen;
|
2850
|
+
var _AutoPlay;
|
2851
|
+
var _AutoPlaySteps = _Options.$AutoPlaySteps;
|
2852
|
+
var _HoverToPause = _Options.$PauseOnHover;
|
2853
|
+
var _AutoPlayInterval = _Options.$AutoPlayInterval;
|
2854
|
+
var _SlideDuration = _Options.$SlideDuration;
|
2855
|
+
|
2856
|
+
var _SlideshowRunnerClass;
|
2857
|
+
var _TransitionsOrder;
|
2858
|
+
|
2859
|
+
var _SlideshowEnabled;
|
2860
|
+
var _ParkingPosition;
|
2861
|
+
var _CarouselEnabled = _DisplayPieces < _SlideCount;
|
2862
|
+
var _Loop = _CarouselEnabled ? _Options.$Loop : 0;
|
2863
|
+
|
2864
|
+
var _DragEnabled;
|
2865
|
+
var _LastDragSucceded;
|
2866
|
+
|
2867
|
+
var _NotOnHover = 1; //0 Hovering, 1 Not hovering
|
2868
|
+
|
2869
|
+
//Variable Definition
|
2870
|
+
var _IsSliding;
|
2871
|
+
var _IsDragging;
|
2872
|
+
var _LoadingTicket;
|
2873
|
+
|
2874
|
+
//The X position of mouse/touch when a drag start
|
2875
|
+
var _DragStartMouseX = 0;
|
2876
|
+
//The Y position of mouse/touch when a drag start
|
2877
|
+
var _DragStartMouseY = 0;
|
2878
|
+
var _DragOffsetTotal;
|
2879
|
+
var _DragOffsetLastTime;
|
2880
|
+
var _DragIndexAdjust;
|
2881
|
+
|
2882
|
+
var _Carousel;
|
2883
|
+
var _Conveyor;
|
2884
|
+
var _Slideshow;
|
2885
|
+
var _CarouselPlayer;
|
2886
|
+
var _SlideContainer = new SlideContainer();
|
2887
|
+
var _ScaleRatio;
|
2888
|
+
|
2889
|
+
//$JssorSlider$ Constructor
|
2890
|
+
{
|
2891
|
+
_AutoPlay = _Options.$AutoPlay;
|
2892
|
+
_SelfSlider.$Options = options;
|
2893
|
+
|
2894
|
+
AdjustSlidesContainerSize();
|
2895
|
+
|
2896
|
+
$Jssor$.$Attribute(elmt, "jssor-slider", true);
|
2897
|
+
|
2898
|
+
$Jssor$.$CssZIndex(_SlidesContainer, $Jssor$.$CssZIndex(_SlidesContainer) || 0);
|
2899
|
+
$Jssor$.$CssPosition(_SlidesContainer, "absolute");
|
2900
|
+
_SlideshowPanel = $Jssor$.$CloneNode(_SlidesContainer, true);
|
2901
|
+
$Jssor$.$InsertBefore(_SlideshowPanel, _SlidesContainer);
|
2902
|
+
|
2903
|
+
if (_SlideshowOptions) {
|
2904
|
+
_ShowLink = _SlideshowOptions.$ShowLink;
|
2905
|
+
_SlideshowRunnerClass = _SlideshowOptions.$Class;
|
2906
|
+
|
2907
|
+
$JssorDebug$.$Execute(function () {
|
2908
|
+
if (!_SlideshowOptions.$Transitions || !_SlideshowOptions.$Transitions.length) {
|
2909
|
+
$JssorDebug$.$Error("Invalid '$SlideshowOptions', no '$Transitions' specified.");
|
2910
|
+
}
|
2911
|
+
});
|
2912
|
+
|
2913
|
+
_SlideshowEnabled = _DisplayPieces == 1 && _SlideCount > 1 && _SlideshowRunnerClass && (!$Jssor$.$IsBrowserIE() || $Jssor$.$BrowserVersion() >= 8);
|
2914
|
+
}
|
2915
|
+
|
2916
|
+
_ParkingPosition = (_SlideshowEnabled || _DisplayPieces >= _SlideCount || !(_Loop & 1)) ? 0 : _Options.$ParkingPosition;
|
2917
|
+
|
2918
|
+
_DragEnabled = ((_DisplayPieces > 1 || _ParkingPosition) ? _PlayOrientation : -1) & _Options.$DragOrientation;
|
2919
|
+
|
2920
|
+
//SlideBoard
|
2921
|
+
var _SlideboardElmt = _SlidesContainer;
|
2922
|
+
var _SlideItems = [];
|
2923
|
+
|
2924
|
+
var _SlideshowRunner;
|
2925
|
+
var _LinkContainer;
|
2926
|
+
|
2927
|
+
var _Device = $Jssor$.$Device();
|
2928
|
+
var _IsTouchDevice = _Device.$Touchable;
|
2929
|
+
|
2930
|
+
var _LastTimeMoveByDrag;
|
2931
|
+
var _Position_OnFreeze;
|
2932
|
+
var _CarouselPlaying_OnFreeze;
|
2933
|
+
var _PlayToPosition_OnFreeze;
|
2934
|
+
var _PositionToGoByDrag;
|
2935
|
+
|
2936
|
+
//SlideBoard Constructor
|
2937
|
+
{
|
2938
|
+
if (_Device.$TouchActionAttr) {
|
2939
|
+
$Jssor$.$Css(_SlideboardElmt, _Device.$TouchActionAttr, [null, "pan-y", "pan-x", "none"][_DragEnabled] || "");
|
2940
|
+
}
|
2941
|
+
|
2942
|
+
_Slideshow = new Slideshow();
|
2943
|
+
|
2944
|
+
if (_SlideshowEnabled)
|
2945
|
+
_SlideshowRunner = new _SlideshowRunnerClass(_SlideContainer, _SlideWidth, _SlideHeight, _SlideshowOptions, _IsTouchDevice);
|
2946
|
+
|
2947
|
+
$Jssor$.$AppendChild(_SlideshowPanel, _Slideshow.$Wrapper);
|
2948
|
+
$Jssor$.$CssOverflow(_SlidesContainer, "hidden");
|
2949
|
+
|
2950
|
+
//link container
|
2951
|
+
{
|
2952
|
+
_LinkContainer = CreatePanel();
|
2953
|
+
$Jssor$.$Css(_LinkContainer, "backgroundColor", "#000");
|
2954
|
+
$Jssor$.$CssOpacity(_LinkContainer, 0);
|
2955
|
+
$Jssor$.$InsertBefore(_LinkContainer, _SlideboardElmt.firstChild, _SlideboardElmt);
|
2956
|
+
}
|
2957
|
+
|
2958
|
+
for (var i = 0; i < _SlideElmts.length; i++) {
|
2959
|
+
var slideElmt = _SlideElmts[i];
|
2960
|
+
var slideItem = new SlideItem(slideElmt, i);
|
2961
|
+
_SlideItems.push(slideItem);
|
2962
|
+
}
|
2963
|
+
|
2964
|
+
$Jssor$.$HideElement(_LoadingContainer);
|
2965
|
+
|
2966
|
+
$JssorDebug$.$Execute(function () {
|
2967
|
+
$Jssor$.$Attribute(_LoadingContainer, "debug-id", "loading-container");
|
2968
|
+
});
|
2969
|
+
|
2970
|
+
_Carousel = new Carousel();
|
2971
|
+
_CarouselPlayer = new CarouselPlayer(_Carousel, _Slideshow);
|
2972
|
+
|
2973
|
+
$JssorDebug$.$Execute(function () {
|
2974
|
+
$Jssor$.$Attribute(_SlideboardElmt, "debug-id", "slide-board");
|
2975
|
+
});
|
2976
|
+
|
2977
|
+
if (_DragEnabled) {
|
2978
|
+
$Jssor$.$AddEvent(_SlidesContainer, "mousedown", OnDragStart);
|
2979
|
+
$Jssor$.$AddEvent(_SlidesContainer, "touchstart", OnTouchStart);
|
2980
|
+
$Jssor$.$AddEvent(_SlidesContainer, "dragstart", PreventDragSelectionEvent);
|
2981
|
+
$Jssor$.$AddEvent(_SlidesContainer, "selectstart", PreventDragSelectionEvent);
|
2982
|
+
$Jssor$.$AddEvent(document, "mouseup", OnDragEnd);
|
2983
|
+
$Jssor$.$AddEvent(document, "touchend", OnDragEnd);
|
2984
|
+
$Jssor$.$AddEvent(document, "touchcancel", OnDragEnd);
|
2985
|
+
$Jssor$.$AddEvent(window, "blur", OnDragEnd);
|
2986
|
+
}
|
2987
|
+
}
|
2988
|
+
//SlideBoard
|
2989
|
+
|
2990
|
+
_HoverToPause &= (_IsTouchDevice ? 10 : 5);
|
2991
|
+
|
2992
|
+
//Bullet Navigator
|
2993
|
+
if (_BulletNavigatorContainer && _BulletNavigatorOptions) {
|
2994
|
+
_BulletNavigator = new _BulletNavigatorOptions.$Class(_BulletNavigatorContainer, _BulletNavigatorOptions, OriginalWidth(), OriginalHeight());
|
2995
|
+
_Navigators.push(_BulletNavigator);
|
2996
|
+
}
|
2997
|
+
|
2998
|
+
//Arrow Navigator
|
2999
|
+
if (_ArrowNavigatorOptions && _ArrowLeft && _ArrowRight) {
|
3000
|
+
_ArrowNavigatorOptions.$Loop = _Loop;
|
3001
|
+
_ArrowNavigatorOptions.$DisplayPieces = _DisplayPieces;
|
3002
|
+
_ArrowNavigator = new _ArrowNavigatorOptions.$Class(_ArrowLeft, _ArrowRight, _ArrowNavigatorOptions, OriginalWidth(), OriginalHeight());
|
3003
|
+
_Navigators.push(_ArrowNavigator);
|
3004
|
+
}
|
3005
|
+
|
3006
|
+
//Thumbnail Navigator
|
3007
|
+
if (_ThumbnailNavigatorContainer && _ThumbnailNavigatorOptions) {
|
3008
|
+
_ThumbnailNavigatorOptions.$StartIndex = _Options.$StartIndex;
|
3009
|
+
_ThumbnailNavigator = new _ThumbnailNavigatorOptions.$Class(_ThumbnailNavigatorContainer, _ThumbnailNavigatorOptions);
|
3010
|
+
_Navigators.push(_ThumbnailNavigator);
|
3011
|
+
}
|
3012
|
+
|
3013
|
+
$Jssor$.$Each(_Navigators, function (navigator) {
|
3014
|
+
navigator.$Reset(_SlideCount, _SlideItems, _LoadingContainer);
|
3015
|
+
navigator.$On($JssorNavigatorEvents$.$NAVIGATIONREQUEST, NavigationClickHandler);
|
3016
|
+
});
|
3017
|
+
|
3018
|
+
Scale(OriginalWidth());
|
3019
|
+
|
3020
|
+
$Jssor$.$AddEvent(_SlidesContainer, "click", SlidesClickEventHandler);
|
3021
|
+
$Jssor$.$AddEvent(elmt, "mouseout", $Jssor$.$MouseOverOutFilter(MainContainerMouseLeaveEventHandler, elmt));
|
3022
|
+
$Jssor$.$AddEvent(elmt, "mouseover", $Jssor$.$MouseOverOutFilter(MainContainerMouseEnterEventHandler, elmt));
|
3023
|
+
|
3024
|
+
ShowNavigators();
|
3025
|
+
|
3026
|
+
//Keyboard Navigation
|
3027
|
+
if (_Options.$ArrowKeyNavigation) {
|
3028
|
+
$Jssor$.$AddEvent(document, "keydown", function (e) {
|
3029
|
+
if (e.keyCode == 37/*$JssorKeyCode$.$LEFT*/) {
|
3030
|
+
//Arrow Left
|
3031
|
+
PlayToOffset(-1);
|
3032
|
+
}
|
3033
|
+
else if (e.keyCode == 39/*$JssorKeyCode$.$RIGHT*/) {
|
3034
|
+
//Arrow Right
|
3035
|
+
PlayToOffset(1);
|
3036
|
+
}
|
3037
|
+
});
|
3038
|
+
}
|
3039
|
+
|
3040
|
+
var startPosition = _Options.$StartIndex;
|
3041
|
+
if (!(_Loop & 1)) {
|
3042
|
+
startPosition = Math.max(0, Math.min(startPosition, _SlideCount - _DisplayPieces));
|
3043
|
+
}
|
3044
|
+
_CarouselPlayer.$PlayCarousel(startPosition, startPosition, 0);
|
3045
|
+
}
|
3046
|
+
};
|
3047
|
+
var $JssorSlideo$ = window.$JssorSlideo$ = $JssorSlider$;
|
3048
|
+
|
3049
|
+
$JssorSlider$.$EVT_CLICK = 21;
|
3050
|
+
$JssorSlider$.$EVT_DRAG_START = 22;
|
3051
|
+
$JssorSlider$.$EVT_DRAG_END = 23;
|
3052
|
+
$JssorSlider$.$EVT_SWIPE_START = 24;
|
3053
|
+
$JssorSlider$.$EVT_SWIPE_END = 25;
|
3054
|
+
|
3055
|
+
$JssorSlider$.$EVT_LOAD_START = 26;
|
3056
|
+
$JssorSlider$.$EVT_LOAD_END = 27;
|
3057
|
+
$JssorSlider$.$EVT_FREEZE = 28;
|
3058
|
+
|
3059
|
+
$JssorSlider$.$EVT_POSITION_CHANGE = 202;
|
3060
|
+
$JssorSlider$.$EVT_PARK = 203;
|
3061
|
+
|
3062
|
+
$JssorSlider$.$EVT_SLIDESHOW_START = 206;
|
3063
|
+
$JssorSlider$.$EVT_SLIDESHOW_END = 207;
|
3064
|
+
|
3065
|
+
$JssorSlider$.$EVT_PROGRESS_CHANGE = 208;
|
3066
|
+
$JssorSlider$.$EVT_STATE_CHANGE = 209;
|
3067
|
+
$JssorSlider$.$EVT_ROLLBACK_START = 210;
|
3068
|
+
$JssorSlider$.$EVT_ROLLBACK_END = 211;
|
3069
|
+
|
3070
|
+
//(function ($) {
|
3071
|
+
// jQuery.fn.jssorSlider = function (options) {
|
3072
|
+
// return this.each(function () {
|
3073
|
+
// return $(this).data('jssorSlider') || $(this).data('jssorSlider', new $JssorSlider$(this, options));
|
3074
|
+
// });
|
3075
|
+
// };
|
3076
|
+
//})(jQuery);
|
3077
|
+
|
3078
|
+
//window.jQuery && (jQuery.fn.jssorSlider = function (options) {
|
3079
|
+
// return this.each(function () {
|
3080
|
+
// return jQuery(this).data('jssorSlider') || jQuery(this).data('jssorSlider', new $JssorSlider$(this, options));
|
3081
|
+
// });
|
3082
|
+
//});
|
3083
|
+
|
3084
|
+
//$JssorBulletNavigator$
|
3085
|
+
var $JssorNavigatorEvents$ = {
|
3086
|
+
$NAVIGATIONREQUEST: 1,
|
3087
|
+
$INDEXCHANGE: 2,
|
3088
|
+
$RESET: 3
|
3089
|
+
};
|
3090
|
+
|
3091
|
+
var $JssorBulletNavigator$ = window.$JssorBulletNavigator$ = function (elmt, options, containerWidth, containerHeight) {
|
3092
|
+
var self = this;
|
3093
|
+
$JssorObject$.call(self);
|
3094
|
+
|
3095
|
+
elmt = $Jssor$.$GetElement(elmt);
|
3096
|
+
|
3097
|
+
var _Count;
|
3098
|
+
var _Length;
|
3099
|
+
var _Width;
|
3100
|
+
var _Height;
|
3101
|
+
var _CurrentIndex;
|
3102
|
+
var _CurrentInnerIndex = 0;
|
3103
|
+
var _Options;
|
3104
|
+
var _Steps;
|
3105
|
+
var _Lanes;
|
3106
|
+
var _SpacingX;
|
3107
|
+
var _SpacingY;
|
3108
|
+
var _Orientation;
|
3109
|
+
var _ItemPrototype;
|
3110
|
+
var _PrototypeWidth;
|
3111
|
+
var _PrototypeHeight;
|
3112
|
+
|
3113
|
+
var _ButtonElements = [];
|
3114
|
+
var _Buttons = [];
|
3115
|
+
|
3116
|
+
function Highlight(index) {
|
3117
|
+
if (index != -1)
|
3118
|
+
_Buttons[index].$Selected(index == _CurrentInnerIndex);
|
3119
|
+
}
|
3120
|
+
|
3121
|
+
function OnNavigationRequest(index) {
|
3122
|
+
self.$TriggerEvent($JssorNavigatorEvents$.$NAVIGATIONREQUEST, index * _Steps);
|
3123
|
+
}
|
3124
|
+
|
3125
|
+
self.$Elmt = elmt;
|
3126
|
+
self.$GetCurrentIndex = function () {
|
3127
|
+
return _CurrentIndex;
|
3128
|
+
};
|
3129
|
+
|
3130
|
+
self.$SetCurrentIndex = function (index) {
|
3131
|
+
if (index != _CurrentIndex) {
|
3132
|
+
var lastInnerIndex = _CurrentInnerIndex;
|
3133
|
+
var innerIndex = Math.floor(index / _Steps);
|
3134
|
+
_CurrentInnerIndex = innerIndex;
|
3135
|
+
_CurrentIndex = index;
|
3136
|
+
|
3137
|
+
Highlight(lastInnerIndex);
|
3138
|
+
Highlight(innerIndex);
|
3139
|
+
|
3140
|
+
//self.$TriggerEvent($JssorNavigatorEvents$.$INDEXCHANGE, index);
|
3141
|
+
}
|
3142
|
+
};
|
3143
|
+
|
3144
|
+
self.$Show = function (hide) {
|
3145
|
+
$Jssor$.$ShowElement(elmt, hide);
|
3146
|
+
};
|
3147
|
+
|
3148
|
+
var _Located;
|
3149
|
+
self.$Relocate = function (containerWidth, containerHeight) {
|
3150
|
+
if (!_Located || _Options.$Scale == false) {
|
3151
|
+
var containerWidth = $Jssor$.$ParentNode(elmt).clientWidth;
|
3152
|
+
var containerHeight = $Jssor$.$ParentNode(elmt).clientHeight;
|
3153
|
+
|
3154
|
+
if (_Options.$AutoCenter & 1) {
|
3155
|
+
$Jssor$.$CssLeft(elmt, (containerWidth - _Width) / 2);
|
3156
|
+
}
|
3157
|
+
if (_Options.$AutoCenter & 2) {
|
3158
|
+
$Jssor$.$CssTop(elmt, (containerHeight - _Height) / 2);
|
3159
|
+
}
|
3160
|
+
|
3161
|
+
_Located = true;
|
3162
|
+
}
|
3163
|
+
};
|
3164
|
+
|
3165
|
+
var _Initialized;
|
3166
|
+
self.$Reset = function (length) {
|
3167
|
+
if (!_Initialized) {
|
3168
|
+
_Length = length;
|
3169
|
+
_Count = Math.ceil(length / _Steps);
|
3170
|
+
_CurrentInnerIndex = 0;
|
3171
|
+
|
3172
|
+
var itemOffsetX = _PrototypeWidth + _SpacingX;
|
3173
|
+
var itemOffsetY = _PrototypeHeight + _SpacingY;
|
3174
|
+
|
3175
|
+
var maxIndex = Math.ceil(_Count / _Lanes) - 1;
|
3176
|
+
|
3177
|
+
_Width = _PrototypeWidth + itemOffsetX * (!_Orientation ? maxIndex : _Lanes - 1);
|
3178
|
+
_Height = _PrototypeHeight + itemOffsetY * (_Orientation ? maxIndex : _Lanes - 1);
|
3179
|
+
|
3180
|
+
$Jssor$.$CssWidth(elmt, _Width);
|
3181
|
+
$Jssor$.$CssHeight(elmt, _Height);
|
3182
|
+
|
3183
|
+
for (var buttonIndex = 0; buttonIndex < _Count; buttonIndex++) {
|
3184
|
+
|
3185
|
+
var numberDiv = $Jssor$.$CreateSpan();
|
3186
|
+
$Jssor$.$InnerText(numberDiv, buttonIndex + 1);
|
3187
|
+
|
3188
|
+
var div = $Jssor$.$BuildElement(_ItemPrototype, "numbertemplate", numberDiv, true);
|
3189
|
+
$Jssor$.$CssPosition(div, "absolute");
|
3190
|
+
|
3191
|
+
var columnIndex = buttonIndex % (maxIndex + 1);
|
3192
|
+
$Jssor$.$CssLeft(div, !_Orientation ? itemOffsetX * columnIndex : buttonIndex % _Lanes * itemOffsetX);
|
3193
|
+
$Jssor$.$CssTop(div, _Orientation ? itemOffsetY * columnIndex : Math.floor(buttonIndex / (maxIndex + 1)) * itemOffsetY);
|
3194
|
+
|
3195
|
+
$Jssor$.$AppendChild(elmt, div);
|
3196
|
+
_ButtonElements[buttonIndex] = div;
|
3197
|
+
|
3198
|
+
if (_Options.$ActionMode & 1)
|
3199
|
+
$Jssor$.$AddEvent(div, "click", $Jssor$.$CreateCallback(null, OnNavigationRequest, buttonIndex));
|
3200
|
+
|
3201
|
+
if (_Options.$ActionMode & 2)
|
3202
|
+
$Jssor$.$AddEvent(div, "mouseover", $Jssor$.$MouseOverOutFilter($Jssor$.$CreateCallback(null, OnNavigationRequest, buttonIndex), div));
|
3203
|
+
|
3204
|
+
_Buttons[buttonIndex] = $Jssor$.$Buttonize(div);
|
3205
|
+
}
|
3206
|
+
|
3207
|
+
//self.$TriggerEvent($JssorNavigatorEvents$.$RESET);
|
3208
|
+
_Initialized = true;
|
3209
|
+
}
|
3210
|
+
};
|
3211
|
+
|
3212
|
+
//JssorBulletNavigator Constructor
|
3213
|
+
{
|
3214
|
+
self.$Options = _Options = $Jssor$.$Extend({
|
3215
|
+
$SpacingX: 0,
|
3216
|
+
$SpacingY: 0,
|
3217
|
+
$Orientation: 1,
|
3218
|
+
$ActionMode: 1
|
3219
|
+
}, options);
|
3220
|
+
|
3221
|
+
//Sodo statement for development time intellisence only
|
3222
|
+
$JssorDebug$.$Execute(function () {
|
3223
|
+
_Options = $Jssor$.$Extend({
|
3224
|
+
$Steps: undefined,
|
3225
|
+
$Lanes: undefined
|
3226
|
+
}, _Options);
|
3227
|
+
});
|
3228
|
+
|
3229
|
+
_ItemPrototype = $Jssor$.$FindChild(elmt, "prototype");
|
3230
|
+
|
3231
|
+
$JssorDebug$.$Execute(function () {
|
3232
|
+
if (!_ItemPrototype)
|
3233
|
+
$JssorDebug$.$Fail("Navigator item prototype not defined.");
|
3234
|
+
|
3235
|
+
if (isNaN($Jssor$.$CssWidth(_ItemPrototype))) {
|
3236
|
+
$JssorDebug$.$Fail("Width of 'navigator item prototype' not specified.");
|
3237
|
+
}
|
3238
|
+
|
3239
|
+
if (isNaN($Jssor$.$CssHeight(_ItemPrototype))) {
|
3240
|
+
$JssorDebug$.$Fail("Height of 'navigator item prototype' not specified.");
|
3241
|
+
}
|
3242
|
+
});
|
3243
|
+
|
3244
|
+
_PrototypeWidth = $Jssor$.$CssWidth(_ItemPrototype);
|
3245
|
+
_PrototypeHeight = $Jssor$.$CssHeight(_ItemPrototype);
|
3246
|
+
|
3247
|
+
$Jssor$.$RemoveElement(_ItemPrototype, elmt);
|
3248
|
+
|
3249
|
+
_Steps = _Options.$Steps || 1;
|
3250
|
+
_Lanes = _Options.$Lanes || 1;
|
3251
|
+
_SpacingX = _Options.$SpacingX;
|
3252
|
+
_SpacingY = _Options.$SpacingY;
|
3253
|
+
_Orientation = _Options.$Orientation - 1;
|
3254
|
+
|
3255
|
+
if (_Options.$Scale == false) {
|
3256
|
+
$Jssor$.$Attribute(elmt, "noscale", true);
|
3257
|
+
}
|
3258
|
+
}
|
3259
|
+
};
|
3260
|
+
|
3261
|
+
var $JssorArrowNavigator$ = window.$JssorArrowNavigator$ = function (arrowLeft, arrowRight, options, containerWidth, containerHeight) {
|
3262
|
+
var self = this;
|
3263
|
+
$JssorObject$.call(self);
|
3264
|
+
|
3265
|
+
$JssorDebug$.$Execute(function () {
|
3266
|
+
|
3267
|
+
if (!arrowLeft)
|
3268
|
+
$JssorDebug$.$Fail("Option '$ArrowNavigatorOptions' spepcified, but UI 'arrowleft' not defined. Define 'arrowleft' to enable direct navigation, or remove option '$ArrowNavigatorOptions' to disable direct navigation.");
|
3269
|
+
|
3270
|
+
if (!arrowRight)
|
3271
|
+
$JssorDebug$.$Fail("Option '$ArrowNavigatorOptions' spepcified, but UI 'arrowright' not defined. Define 'arrowright' to enable direct navigation, or remove option '$ArrowNavigatorOptions' to disable direct navigation.");
|
3272
|
+
|
3273
|
+
if (isNaN($Jssor$.$CssWidth(arrowLeft))) {
|
3274
|
+
$JssorDebug$.$Fail("Width of 'arrow left' not specified.");
|
3275
|
+
}
|
3276
|
+
|
3277
|
+
if (isNaN($Jssor$.$CssWidth(arrowRight))) {
|
3278
|
+
$JssorDebug$.$Fail("Width of 'arrow right' not specified.");
|
3279
|
+
}
|
3280
|
+
|
3281
|
+
if (isNaN($Jssor$.$CssHeight(arrowLeft))) {
|
3282
|
+
$JssorDebug$.$Fail("Height of 'arrow left' not specified.");
|
3283
|
+
}
|
3284
|
+
|
3285
|
+
if (isNaN($Jssor$.$CssHeight(arrowRight))) {
|
3286
|
+
$JssorDebug$.$Fail("Height of 'arrow right' not specified.");
|
3287
|
+
}
|
3288
|
+
});
|
3289
|
+
|
3290
|
+
var _Hide;
|
3291
|
+
var _Length;
|
3292
|
+
var _CurrentIndex;
|
3293
|
+
var _Options;
|
3294
|
+
var _Steps;
|
3295
|
+
var _ArrowWidth = $Jssor$.$CssWidth(arrowLeft);
|
3296
|
+
var _ArrowHeight = $Jssor$.$CssHeight(arrowLeft);
|
3297
|
+
|
3298
|
+
function OnNavigationRequest(steps) {
|
3299
|
+
self.$TriggerEvent($JssorNavigatorEvents$.$NAVIGATIONREQUEST, steps, true);
|
3300
|
+
}
|
3301
|
+
|
3302
|
+
function ShowArrows(hide) {
|
3303
|
+
$Jssor$.$ShowElement(arrowLeft, hide || !options.$Loop && _CurrentIndex == 0);
|
3304
|
+
$Jssor$.$ShowElement(arrowRight, hide || !options.$Loop && _CurrentIndex >= _Length - options.$DisplayPieces);
|
3305
|
+
|
3306
|
+
_Hide = hide;
|
3307
|
+
}
|
3308
|
+
|
3309
|
+
self.$GetCurrentIndex = function () {
|
3310
|
+
return _CurrentIndex;
|
3311
|
+
};
|
3312
|
+
|
3313
|
+
self.$SetCurrentIndex = function (index, virtualIndex, temp) {
|
3314
|
+
if (temp) {
|
3315
|
+
_CurrentIndex = virtualIndex;
|
3316
|
+
}
|
3317
|
+
else {
|
3318
|
+
_CurrentIndex = index;
|
3319
|
+
|
3320
|
+
ShowArrows(_Hide);
|
3321
|
+
}
|
3322
|
+
//self.$TriggerEvent($JssorNavigatorEvents$.$INDEXCHANGE, index);
|
3323
|
+
};
|
3324
|
+
|
3325
|
+
self.$Show = ShowArrows;
|
3326
|
+
|
3327
|
+
var _Located;
|
3328
|
+
self.$Relocate = function (conainerWidth, containerHeight) {
|
3329
|
+
if (!_Located || _Options.$Scale == false) {
|
3330
|
+
|
3331
|
+
var containerWidth = $Jssor$.$ParentNode(arrowLeft).clientWidth;
|
3332
|
+
var containerHeight = $Jssor$.$ParentNode(arrowLeft).clientHeight;
|
3333
|
+
|
3334
|
+
if (_Options.$AutoCenter & 1) {
|
3335
|
+
$Jssor$.$CssLeft(arrowLeft, (containerWidth - _ArrowWidth) / 2);
|
3336
|
+
$Jssor$.$CssLeft(arrowRight, (containerWidth - _ArrowWidth) / 2);
|
3337
|
+
}
|
3338
|
+
|
3339
|
+
if (_Options.$AutoCenter & 2) {
|
3340
|
+
$Jssor$.$CssTop(arrowLeft, (containerHeight - _ArrowHeight) / 2);
|
3341
|
+
$Jssor$.$CssTop(arrowRight, (containerHeight - _ArrowHeight) / 2);
|
3342
|
+
}
|
3343
|
+
|
3344
|
+
_Located = true;
|
3345
|
+
}
|
3346
|
+
};
|
3347
|
+
|
3348
|
+
var _Initialized;
|
3349
|
+
self.$Reset = function (length) {
|
3350
|
+
_Length = length;
|
3351
|
+
_CurrentIndex = 0;
|
3352
|
+
|
3353
|
+
if (!_Initialized) {
|
3354
|
+
|
3355
|
+
$Jssor$.$AddEvent(arrowLeft, "click", $Jssor$.$CreateCallback(null, OnNavigationRequest, -_Steps));
|
3356
|
+
$Jssor$.$AddEvent(arrowRight, "click", $Jssor$.$CreateCallback(null, OnNavigationRequest, _Steps));
|
3357
|
+
|
3358
|
+
$Jssor$.$Buttonize(arrowLeft);
|
3359
|
+
$Jssor$.$Buttonize(arrowRight);
|
3360
|
+
|
3361
|
+
_Initialized = true;
|
3362
|
+
}
|
3363
|
+
|
3364
|
+
//self.$TriggerEvent($JssorNavigatorEvents$.$RESET);
|
3365
|
+
};
|
3366
|
+
|
3367
|
+
//JssorArrowNavigator Constructor
|
3368
|
+
{
|
3369
|
+
self.$Options = _Options = $Jssor$.$Extend({
|
3370
|
+
$Steps: 1
|
3371
|
+
}, options);
|
3372
|
+
|
3373
|
+
_Steps = _Options.$Steps;
|
3374
|
+
|
3375
|
+
if (_Options.$Scale == false) {
|
3376
|
+
$Jssor$.$Attribute(arrowLeft, "noscale", true);
|
3377
|
+
$Jssor$.$Attribute(arrowRight, "noscale", true);
|
3378
|
+
}
|
3379
|
+
}
|
3380
|
+
};
|
3381
|
+
|
3382
|
+
//$JssorThumbnailNavigator$
|
3383
|
+
var $JssorThumbnailNavigator$ = window.$JssorThumbnailNavigator$ = function (elmt, options) {
|
3384
|
+
var _Self = this;
|
3385
|
+
var _Length;
|
3386
|
+
var _Count;
|
3387
|
+
var _CurrentIndex;
|
3388
|
+
var _Options;
|
3389
|
+
var _NavigationItems = [];
|
3390
|
+
|
3391
|
+
var _Width;
|
3392
|
+
var _Height;
|
3393
|
+
var _Lanes;
|
3394
|
+
var _SpacingX;
|
3395
|
+
var _SpacingY;
|
3396
|
+
var _PrototypeWidth;
|
3397
|
+
var _PrototypeHeight;
|
3398
|
+
var _DisplayPieces;
|
3399
|
+
|
3400
|
+
var _Slider;
|
3401
|
+
var _CurrentMouseOverIndex = -1;
|
3402
|
+
|
3403
|
+
var _SlidesContainer;
|
3404
|
+
var _ThumbnailPrototype;
|
3405
|
+
|
3406
|
+
$JssorObject$.call(_Self);
|
3407
|
+
elmt = $Jssor$.$GetElement(elmt);
|
3408
|
+
|
3409
|
+
function NavigationItem(item, index) {
|
3410
|
+
var self = this;
|
3411
|
+
var _Wrapper;
|
3412
|
+
var _Button;
|
3413
|
+
var _Thumbnail;
|
3414
|
+
|
3415
|
+
function Highlight(mouseStatus) {
|
3416
|
+
_Button.$Selected(_CurrentIndex == index);
|
3417
|
+
}
|
3418
|
+
|
3419
|
+
function OnNavigationRequest(event) {
|
3420
|
+
if (!_Slider.$LastDragSucceded()) {
|
3421
|
+
var tail = _Lanes - index % _Lanes;
|
3422
|
+
var slideVirtualIndex = _Slider.$GetVirtualIndex((index + tail) / _Lanes - 1);
|
3423
|
+
var itemVirtualIndex = slideVirtualIndex * _Lanes + _Lanes - tail;
|
3424
|
+
_Self.$TriggerEvent($JssorNavigatorEvents$.$NAVIGATIONREQUEST, itemVirtualIndex);
|
3425
|
+
}
|
3426
|
+
|
3427
|
+
//$JssorDebug$.$Log("navigation request");
|
3428
|
+
}
|
3429
|
+
|
3430
|
+
$JssorDebug$.$Execute(function () {
|
3431
|
+
self.$Wrapper = undefined;
|
3432
|
+
});
|
3433
|
+
|
3434
|
+
self.$Index = index;
|
3435
|
+
|
3436
|
+
self.$Highlight = Highlight;
|
3437
|
+
|
3438
|
+
//NavigationItem Constructor
|
3439
|
+
{
|
3440
|
+
_Thumbnail = item.$Thumb || item.$Image || $Jssor$.$CreateDiv();
|
3441
|
+
self.$Wrapper = _Wrapper = $Jssor$.$BuildElement(_ThumbnailPrototype, "thumbnailtemplate", _Thumbnail, true);
|
3442
|
+
|
3443
|
+
_Button = $Jssor$.$Buttonize(_Wrapper);
|
3444
|
+
if (_Options.$ActionMode & 1)
|
3445
|
+
$Jssor$.$AddEvent(_Wrapper, "click", OnNavigationRequest);
|
3446
|
+
if (_Options.$ActionMode & 2)
|
3447
|
+
$Jssor$.$AddEvent(_Wrapper, "mouseover", $Jssor$.$MouseOverOutFilter(OnNavigationRequest, _Wrapper));
|
3448
|
+
}
|
3449
|
+
}
|
3450
|
+
|
3451
|
+
_Self.$GetCurrentIndex = function () {
|
3452
|
+
return _CurrentIndex;
|
3453
|
+
};
|
3454
|
+
|
3455
|
+
_Self.$SetCurrentIndex = function (index, virtualIndex, temp) {
|
3456
|
+
var oldIndex = _CurrentIndex;
|
3457
|
+
_CurrentIndex = index;
|
3458
|
+
if (oldIndex != -1)
|
3459
|
+
_NavigationItems[oldIndex].$Highlight();
|
3460
|
+
_NavigationItems[index].$Highlight();
|
3461
|
+
|
3462
|
+
if (!temp) {
|
3463
|
+
_Slider.$PlayTo(_Slider.$GetVirtualIndex(Math.floor(virtualIndex / _Lanes)));
|
3464
|
+
}
|
3465
|
+
};
|
3466
|
+
|
3467
|
+
_Self.$Show = function (hide) {
|
3468
|
+
$Jssor$.$ShowElement(elmt, hide);
|
3469
|
+
};
|
3470
|
+
|
3471
|
+
_Self.$Relocate = $Jssor$.$EmptyFunction;
|
3472
|
+
|
3473
|
+
var _Initialized;
|
3474
|
+
_Self.$Reset = function (length, items, loadingContainer) {
|
3475
|
+
if (!_Initialized) {
|
3476
|
+
_Length = length;
|
3477
|
+
_Count = Math.ceil(_Length / _Lanes);
|
3478
|
+
_CurrentIndex = -1;
|
3479
|
+
_DisplayPieces = Math.min(_DisplayPieces, items.length);
|
3480
|
+
|
3481
|
+
var horizontal = _Options.$Orientation & 1;
|
3482
|
+
|
3483
|
+
var slideWidth = _PrototypeWidth + (_PrototypeWidth + _SpacingX) * (_Lanes - 1) * (1 - horizontal);
|
3484
|
+
var slideHeight = _PrototypeHeight + (_PrototypeHeight + _SpacingY) * (_Lanes - 1) * horizontal;
|
3485
|
+
|
3486
|
+
var slidesContainerWidth = slideWidth + (slideWidth + _SpacingX) * (_DisplayPieces - 1) * horizontal;
|
3487
|
+
var slidesContainerHeight = slideHeight + (slideHeight + _SpacingY) * (_DisplayPieces - 1) * (1 - horizontal);
|
3488
|
+
|
3489
|
+
$Jssor$.$CssPosition(_SlidesContainer, "absolute");
|
3490
|
+
$Jssor$.$CssOverflow(_SlidesContainer, "hidden");
|
3491
|
+
if (_Options.$AutoCenter & 1) {
|
3492
|
+
$Jssor$.$CssLeft(_SlidesContainer, (_Width - slidesContainerWidth) / 2);
|
3493
|
+
}
|
3494
|
+
if (_Options.$AutoCenter & 2) {
|
3495
|
+
$Jssor$.$CssTop(_SlidesContainer, (_Height - slidesContainerHeight) / 2);
|
3496
|
+
}
|
3497
|
+
//$JssorDebug$.$Execute(function () {
|
3498
|
+
// if (!_Options.$AutoCenter) {
|
3499
|
+
// var slidesContainerTop = $Jssor$.$CssTop(_SlidesContainer);
|
3500
|
+
// var slidesContainerLeft = $Jssor$.$CssLeft(_SlidesContainer);
|
3501
|
+
|
3502
|
+
// if (isNaN(slidesContainerTop)) {
|
3503
|
+
// $JssorDebug$.$Fail("Position 'top' wrong specification of thumbnail navigator slides container (<div u=\"thumbnavigator\">...<div u=\"slides\">), \r\nwhen option $ThumbnailNavigatorOptions.$AutoCenter set to 0, it should be specified in pixel (like <div u=\"slides\" style=\"top: 0px;\">)");
|
3504
|
+
// }
|
3505
|
+
|
3506
|
+
// if (isNaN(slidesContainerLeft)) {
|
3507
|
+
// $JssorDebug$.$Fail("Position 'left' wrong specification of thumbnail navigator slides container (<div u=\"thumbnavigator\">...<div u=\"slides\">), \r\nwhen option $ThumbnailNavigatorOptions.$AutoCenter set to 0, it should be specified in pixel (like <div u=\"slides\" style=\"left: 0px;\">)");
|
3508
|
+
// }
|
3509
|
+
// }
|
3510
|
+
//});
|
3511
|
+
$Jssor$.$CssWidth(_SlidesContainer, slidesContainerWidth);
|
3512
|
+
$Jssor$.$CssHeight(_SlidesContainer, slidesContainerHeight);
|
3513
|
+
|
3514
|
+
var slideItemElmts = [];
|
3515
|
+
$Jssor$.$Each(items, function (item, index) {
|
3516
|
+
var navigationItem = new NavigationItem(item, index);
|
3517
|
+
var navigationItemWrapper = navigationItem.$Wrapper;
|
3518
|
+
|
3519
|
+
var columnIndex = Math.floor(index / _Lanes);
|
3520
|
+
var laneIndex = index % _Lanes;
|
3521
|
+
|
3522
|
+
$Jssor$.$CssLeft(navigationItemWrapper, (_PrototypeWidth + _SpacingX) * laneIndex * (1 - horizontal));
|
3523
|
+
$Jssor$.$CssTop(navigationItemWrapper, (_PrototypeHeight + _SpacingY) * laneIndex * horizontal);
|
3524
|
+
|
3525
|
+
if (!slideItemElmts[columnIndex]) {
|
3526
|
+
slideItemElmts[columnIndex] = $Jssor$.$CreateDiv();
|
3527
|
+
$Jssor$.$AppendChild(_SlidesContainer, slideItemElmts[columnIndex]);
|
3528
|
+
}
|
3529
|
+
|
3530
|
+
$Jssor$.$AppendChild(slideItemElmts[columnIndex], navigationItemWrapper);
|
3531
|
+
|
3532
|
+
_NavigationItems.push(navigationItem);
|
3533
|
+
});
|
3534
|
+
|
3535
|
+
var thumbnailSliderOptions = $Jssor$.$Extend({
|
3536
|
+
$HWA: false,
|
3537
|
+
$AutoPlay: false,
|
3538
|
+
$NaviQuitDrag: false,
|
3539
|
+
$SlideWidth: slideWidth,
|
3540
|
+
$SlideHeight: slideHeight,
|
3541
|
+
$SlideSpacing: _SpacingX * horizontal + _SpacingY * (1 - horizontal),
|
3542
|
+
$MinDragOffsetToSlide: 12,
|
3543
|
+
$SlideDuration: 200,
|
3544
|
+
$PauseOnHover: 1,
|
3545
|
+
$PlayOrientation: _Options.$Orientation,
|
3546
|
+
$DragOrientation: _Options.$DisableDrag ? 0 : _Options.$Orientation
|
3547
|
+
}, _Options);
|
3548
|
+
|
3549
|
+
_Slider = new $JssorSlider$(elmt, thumbnailSliderOptions);
|
3550
|
+
|
3551
|
+
_Initialized = true;
|
3552
|
+
}
|
3553
|
+
|
3554
|
+
//_Self.$TriggerEvent($JssorNavigatorEvents$.$RESET);
|
3555
|
+
};
|
3556
|
+
|
3557
|
+
//JssorThumbnailNavigator Constructor
|
3558
|
+
{
|
3559
|
+
_Self.$Options = _Options = $Jssor$.$Extend({
|
3560
|
+
$SpacingX: 3,
|
3561
|
+
$SpacingY: 3,
|
3562
|
+
$DisplayPieces: 1,
|
3563
|
+
$Orientation: 1,
|
3564
|
+
$AutoCenter: 3,
|
3565
|
+
$ActionMode: 1
|
3566
|
+
}, options);
|
3567
|
+
|
3568
|
+
//going to use $Rows instead of $Lanes
|
3569
|
+
if (_Options.$Rows != undefined)
|
3570
|
+
_Options.$Lanes = _Options.$Rows;
|
3571
|
+
|
3572
|
+
//Sodo statement for development time intellisence only
|
3573
|
+
$JssorDebug$.$Execute(function () {
|
3574
|
+
_Options = $Jssor$.$Extend({
|
3575
|
+
$Lanes: undefined,
|
3576
|
+
$Width: undefined,
|
3577
|
+
$Height: undefined
|
3578
|
+
}, _Options);
|
3579
|
+
});
|
3580
|
+
|
3581
|
+
_Width = $Jssor$.$CssWidth(elmt);
|
3582
|
+
_Height = $Jssor$.$CssHeight(elmt);
|
3583
|
+
|
3584
|
+
$JssorDebug$.$Execute(function () {
|
3585
|
+
if (!_Width)
|
3586
|
+
$JssorDebug$.$Fail("width of 'thumbnavigator' container not specified.");
|
3587
|
+
if (!_Height)
|
3588
|
+
$JssorDebug$.$Fail("height of 'thumbnavigator' container not specified.");
|
3589
|
+
});
|
3590
|
+
|
3591
|
+
_SlidesContainer = $Jssor$.$FindChild(elmt, "slides", true);
|
3592
|
+
_ThumbnailPrototype = $Jssor$.$FindChild(_SlidesContainer, "prototype");
|
3593
|
+
|
3594
|
+
$JssorDebug$.$Execute(function () {
|
3595
|
+
if (!_ThumbnailPrototype)
|
3596
|
+
$JssorDebug$.$Fail("prototype of 'thumbnavigator' not defined.");
|
3597
|
+
});
|
3598
|
+
|
3599
|
+
_PrototypeWidth = $Jssor$.$CssWidth(_ThumbnailPrototype);
|
3600
|
+
_PrototypeHeight = $Jssor$.$CssHeight(_ThumbnailPrototype);
|
3601
|
+
|
3602
|
+
$Jssor$.$RemoveElement(_ThumbnailPrototype, _SlidesContainer);
|
3603
|
+
|
3604
|
+
_Lanes = _Options.$Lanes || 1;
|
3605
|
+
_SpacingX = _Options.$SpacingX;
|
3606
|
+
_SpacingY = _Options.$SpacingY;
|
3607
|
+
_DisplayPieces = _Options.$DisplayPieces;
|
3608
|
+
|
3609
|
+
if (_Options.$Scale == false) {
|
3610
|
+
$Jssor$.$Attribute(elmt, "noscale", true);
|
3611
|
+
}
|
3612
|
+
}
|
3613
|
+
};
|
3614
|
+
|
3615
|
+
//$JssorCaptionSliderBase$
|
3616
|
+
function $JssorCaptionSliderBase$() {
|
3617
|
+
$JssorAnimator$.call(this, 0, 0);
|
3618
|
+
this.$Revert = $Jssor$.$EmptyFunction;
|
3619
|
+
}
|
3620
|
+
|
3621
|
+
var $JssorCaptionSlider$ = window.$JssorCaptionSlider$ = function (container, captionSlideOptions, playIn) {
|
3622
|
+
$JssorDebug$.$Execute(function () {
|
3623
|
+
if (!captionSlideOptions.$CaptionTransitions) {
|
3624
|
+
$JssorDebug$.$Error("'$CaptionSliderOptions' option error, '$CaptionSliderOptions.$CaptionTransitions' not specified.");
|
3625
|
+
}
|
3626
|
+
});
|
3627
|
+
|
3628
|
+
var _Self = this;
|
3629
|
+
var _ImmediateOutCaptionHanger;
|
3630
|
+
var _PlayMode = playIn ? captionSlideOptions.$PlayInMode : captionSlideOptions.$PlayOutMode;
|
3631
|
+
|
3632
|
+
var _CaptionTransitions = captionSlideOptions.$CaptionTransitions;
|
3633
|
+
var _CaptionTuningFetcher = { $Transition: "t", $Delay: "d", $Duration: "du", x: "x", y: "y", $Rotate: "r", $Zoom: "z", $Opacity: "f", $BeginTime: "b" };
|
3634
|
+
var _CaptionTuningTransfer = {
|
3635
|
+
$Default: function (value, tuningValue) {
|
3636
|
+
if (!isNaN(tuningValue.$Value))
|
3637
|
+
value = tuningValue.$Value;
|
3638
|
+
else
|
3639
|
+
value *= tuningValue.$Percent;
|
3640
|
+
|
3641
|
+
return value;
|
3642
|
+
},
|
3643
|
+
$Opacity: function (value, tuningValue) {
|
3644
|
+
return this.$Default(value - 1, tuningValue);
|
3645
|
+
}
|
3646
|
+
};
|
3647
|
+
_CaptionTuningTransfer.$Zoom = _CaptionTuningTransfer.$Opacity;
|
3648
|
+
|
3649
|
+
$JssorAnimator$.call(_Self, 0, 0);
|
3650
|
+
|
3651
|
+
function GetCaptionItems(element, level) {
|
3652
|
+
|
3653
|
+
var itemsToPlay = [];
|
3654
|
+
var lastTransitionName;
|
3655
|
+
var namedTransitions = [];
|
3656
|
+
var namedTransitionOrders = [];
|
3657
|
+
|
3658
|
+
function FetchRawTransition(captionElmt, index) {
|
3659
|
+
var rawTransition = {};
|
3660
|
+
|
3661
|
+
$Jssor$.$Each(_CaptionTuningFetcher, function (fetchAttribute, fetchProperty) {
|
3662
|
+
var attributeValue = $Jssor$.$AttributeEx(captionElmt, fetchAttribute + (index || ""));
|
3663
|
+
if (attributeValue) {
|
3664
|
+
var propertyValue = {};
|
3665
|
+
|
3666
|
+
if (fetchAttribute == "t") {
|
3667
|
+
propertyValue.$Value = attributeValue;
|
3668
|
+
}
|
3669
|
+
else if (attributeValue.indexOf("%") + 1)
|
3670
|
+
propertyValue.$Percent = $Jssor$.$ParseFloat(attributeValue) / 100;
|
3671
|
+
else
|
3672
|
+
propertyValue.$Value = $Jssor$.$ParseFloat(attributeValue);
|
3673
|
+
|
3674
|
+
rawTransition[fetchProperty] = propertyValue;
|
3675
|
+
}
|
3676
|
+
});
|
3677
|
+
|
3678
|
+
return rawTransition;
|
3679
|
+
}
|
3680
|
+
|
3681
|
+
function GetRandomTransition() {
|
3682
|
+
return _CaptionTransitions[Math.floor(Math.random() * _CaptionTransitions.length)];
|
3683
|
+
}
|
3684
|
+
|
3685
|
+
function EvaluateCaptionTransition(transitionName) {
|
3686
|
+
|
3687
|
+
var transition;
|
3688
|
+
|
3689
|
+
if (transitionName == "*") {
|
3690
|
+
transition = GetRandomTransition();
|
3691
|
+
}
|
3692
|
+
else if (transitionName) {
|
3693
|
+
|
3694
|
+
//indexed transition allowed, just the same as named transition
|
3695
|
+
var tempTransition = _CaptionTransitions[$Jssor$.$ParseInt(transitionName)] || _CaptionTransitions[transitionName];
|
3696
|
+
|
3697
|
+
if ($Jssor$.$IsArray(tempTransition)) {
|
3698
|
+
if (transitionName != lastTransitionName) {
|
3699
|
+
lastTransitionName = transitionName;
|
3700
|
+
namedTransitionOrders[transitionName] = 0;
|
3701
|
+
|
3702
|
+
namedTransitions[transitionName] = tempTransition[Math.floor(Math.random() * tempTransition.length)];
|
3703
|
+
}
|
3704
|
+
else {
|
3705
|
+
namedTransitionOrders[transitionName]++;
|
3706
|
+
}
|
3707
|
+
|
3708
|
+
tempTransition = namedTransitions[transitionName];
|
3709
|
+
|
3710
|
+
if ($Jssor$.$IsArray(tempTransition)) {
|
3711
|
+
tempTransition = tempTransition.length && tempTransition[namedTransitionOrders[transitionName] % tempTransition.length];
|
3712
|
+
|
3713
|
+
if ($Jssor$.$IsArray(tempTransition)) {
|
3714
|
+
//got transition from array level 3, random for all captions
|
3715
|
+
tempTransition = tempTransition[Math.floor(Math.random() * tempTransition.length)];
|
3716
|
+
}
|
3717
|
+
//else {
|
3718
|
+
// //got transition from array level 2, in sequence for all adjacent captions with same name specified
|
3719
|
+
// transition = tempTransition;
|
3720
|
+
//}
|
3721
|
+
}
|
3722
|
+
//else {
|
3723
|
+
// //got transition from array level 1, random but same for all adjacent captions with same name specified
|
3724
|
+
// transition = tempTransition;
|
3725
|
+
//}
|
3726
|
+
}
|
3727
|
+
//else {
|
3728
|
+
// //got transition directly from a simple transition object
|
3729
|
+
// transition = tempTransition;
|
3730
|
+
//}
|
3731
|
+
|
3732
|
+
transition = tempTransition;
|
3733
|
+
|
3734
|
+
if ($Jssor$.$IsString(transition))
|
3735
|
+
transition = EvaluateCaptionTransition(transition);
|
3736
|
+
}
|
3737
|
+
|
3738
|
+
return transition;
|
3739
|
+
}
|
3740
|
+
|
3741
|
+
var captionElmts = $Jssor$.$Children(element);
|
3742
|
+
$Jssor$.$Each(captionElmts, function (captionElmt, i) {
|
3743
|
+
|
3744
|
+
var transitionsWithTuning = [];
|
3745
|
+
transitionsWithTuning.$Elmt = captionElmt;
|
3746
|
+
var isCaption = $Jssor$.$AttributeEx(captionElmt, "u") == "caption";
|
3747
|
+
|
3748
|
+
$Jssor$.$Each(playIn ? [0, 3] : [2], function (j, k) {
|
3749
|
+
|
3750
|
+
if (isCaption) {
|
3751
|
+
var transition;
|
3752
|
+
var rawTransition;
|
3753
|
+
|
3754
|
+
if (j != 2 || !$Jssor$.$AttributeEx(captionElmt, "t3")) {
|
3755
|
+
rawTransition = FetchRawTransition(captionElmt, j);
|
3756
|
+
|
3757
|
+
if (j == 2 && !rawTransition.$Transition) {
|
3758
|
+
rawTransition.$Delay = rawTransition.$Delay || { $Value: 0 };
|
3759
|
+
rawTransition = $Jssor$.$Extend(FetchRawTransition(captionElmt, 0), rawTransition);
|
3760
|
+
}
|
3761
|
+
}
|
3762
|
+
|
3763
|
+
if (rawTransition && rawTransition.$Transition) {
|
3764
|
+
|
3765
|
+
transition = EvaluateCaptionTransition(rawTransition.$Transition.$Value);
|
3766
|
+
|
3767
|
+
if (transition) {
|
3768
|
+
|
3769
|
+
//var transitionWithTuning = $Jssor$.$Extend({ $Delay: 0, $ScaleHorizontal: 1, $ScaleVertical: 1 }, transition);
|
3770
|
+
var transitionWithTuning = $Jssor$.$Extend({ $Delay: 0 }, transition);
|
3771
|
+
|
3772
|
+
$Jssor$.$Each(rawTransition, function (rawPropertyValue, propertyName) {
|
3773
|
+
var tuningPropertyValue = (_CaptionTuningTransfer[propertyName] || _CaptionTuningTransfer.$Default).apply(_CaptionTuningTransfer, [transitionWithTuning[propertyName], rawTransition[propertyName]]);
|
3774
|
+
if (!isNaN(tuningPropertyValue))
|
3775
|
+
transitionWithTuning[propertyName] = tuningPropertyValue;
|
3776
|
+
});
|
3777
|
+
|
3778
|
+
if (!k) {
|
3779
|
+
if (rawTransition.$BeginTime)
|
3780
|
+
transitionWithTuning.$BeginTime = rawTransition.$BeginTime.$Value || 0;
|
3781
|
+
else if ((_PlayMode) & 2)
|
3782
|
+
transitionWithTuning.$BeginTime = 0;
|
3783
|
+
}
|
3784
|
+
}
|
3785
|
+
}
|
3786
|
+
|
3787
|
+
transitionsWithTuning.push(transitionWithTuning);
|
3788
|
+
}
|
3789
|
+
|
3790
|
+
if ((level % 2) && !k) {
|
3791
|
+
transitionsWithTuning.$Children = GetCaptionItems(captionElmt, level + 1);
|
3792
|
+
}
|
3793
|
+
});
|
3794
|
+
|
3795
|
+
itemsToPlay.push(transitionsWithTuning);
|
3796
|
+
});
|
3797
|
+
|
3798
|
+
return itemsToPlay;
|
3799
|
+
}
|
3800
|
+
|
3801
|
+
function CreateAnimator(item, transition, immediateOut) {
|
3802
|
+
|
3803
|
+
var animatorOptions = {
|
3804
|
+
$Easing: transition.$Easing,
|
3805
|
+
$Round: transition.$Round,
|
3806
|
+
$During: transition.$During,
|
3807
|
+
$Reverse: playIn && !immediateOut
|
3808
|
+
};
|
3809
|
+
|
3810
|
+
$JssorDebug$.$Execute(function () {
|
3811
|
+
animatorOptions.$CaptionAnimator = true;
|
3812
|
+
});
|
3813
|
+
|
3814
|
+
var captionItem = item;
|
3815
|
+
var captionParent = $Jssor$.$ParentNode(item);
|
3816
|
+
|
3817
|
+
var captionItemWidth = $Jssor$.$CssWidth(captionItem);
|
3818
|
+
var captionItemHeight = $Jssor$.$CssHeight(captionItem);
|
3819
|
+
var captionParentWidth = $Jssor$.$CssWidth(captionParent);
|
3820
|
+
var captionParentHeight = $Jssor$.$CssHeight(captionParent);
|
3821
|
+
|
3822
|
+
var fromStyles = {};
|
3823
|
+
var difStyles = {};
|
3824
|
+
var scaleClip = transition.$ScaleClip || 1;
|
3825
|
+
|
3826
|
+
//Opacity
|
3827
|
+
if (transition.$Opacity) {
|
3828
|
+
difStyles.$Opacity = 1 - transition.$Opacity;
|
3829
|
+
}
|
3830
|
+
|
3831
|
+
animatorOptions.$OriginalWidth = captionItemWidth;
|
3832
|
+
animatorOptions.$OriginalHeight = captionItemHeight;
|
3833
|
+
|
3834
|
+
//Transform
|
3835
|
+
if (transition.$Zoom || transition.$Rotate) {
|
3836
|
+
difStyles.$Zoom = (transition.$Zoom || 2) - 2;
|
3837
|
+
|
3838
|
+
if ($Jssor$.$IsBrowserIe9Earlier() || $Jssor$.$IsBrowserOpera()) {
|
3839
|
+
difStyles.$Zoom = Math.min(difStyles.$Zoom, 1);
|
3840
|
+
}
|
3841
|
+
|
3842
|
+
fromStyles.$Zoom = 1;
|
3843
|
+
|
3844
|
+
var rotate = transition.$Rotate || 0;
|
3845
|
+
|
3846
|
+
difStyles.$Rotate = rotate * 360;
|
3847
|
+
fromStyles.$Rotate = 0;
|
3848
|
+
}
|
3849
|
+
//Clip
|
3850
|
+
else if (transition.$Clip) {
|
3851
|
+
var fromStyleClip = { $Top: 0, $Right: captionItemWidth, $Bottom: captionItemHeight, $Left: 0 };
|
3852
|
+
var toStyleClip = $Jssor$.$Extend({}, fromStyleClip);
|
3853
|
+
|
3854
|
+
var blockOffset = toStyleClip.$Offset = {};
|
3855
|
+
|
3856
|
+
var topBenchmark = transition.$Clip & 4;
|
3857
|
+
var bottomBenchmark = transition.$Clip & 8;
|
3858
|
+
var leftBenchmark = transition.$Clip & 1;
|
3859
|
+
var rightBenchmark = transition.$Clip & 2;
|
3860
|
+
|
3861
|
+
if (topBenchmark && bottomBenchmark) {
|
3862
|
+
blockOffset.$Top = captionItemHeight / 2 * scaleClip;
|
3863
|
+
blockOffset.$Bottom = -blockOffset.$Top;
|
3864
|
+
}
|
3865
|
+
else if (topBenchmark)
|
3866
|
+
blockOffset.$Bottom = -captionItemHeight * scaleClip;
|
3867
|
+
else if (bottomBenchmark)
|
3868
|
+
blockOffset.$Top = captionItemHeight * scaleClip;
|
3869
|
+
|
3870
|
+
if (leftBenchmark && rightBenchmark) {
|
3871
|
+
blockOffset.$Left = captionItemWidth / 2 * scaleClip;
|
3872
|
+
blockOffset.$Right = -blockOffset.$Left;
|
3873
|
+
}
|
3874
|
+
else if (leftBenchmark)
|
3875
|
+
blockOffset.$Right = -captionItemWidth * scaleClip;
|
3876
|
+
else if (rightBenchmark)
|
3877
|
+
blockOffset.$Left = captionItemWidth * scaleClip;
|
3878
|
+
|
3879
|
+
animatorOptions.$Move = transition.$Move;
|
3880
|
+
difStyles.$Clip = toStyleClip;
|
3881
|
+
fromStyles.$Clip = fromStyleClip;
|
3882
|
+
}
|
3883
|
+
|
3884
|
+
//Fly
|
3885
|
+
{
|
3886
|
+
var toLeft = 0;
|
3887
|
+
var toTop = 0;
|
3888
|
+
|
3889
|
+
if (transition.x)
|
3890
|
+
toLeft -= captionParentWidth * transition.x;
|
3891
|
+
|
3892
|
+
if (transition.y)
|
3893
|
+
toTop -= captionParentHeight * transition.y;
|
3894
|
+
|
3895
|
+
if (toLeft || toTop || animatorOptions.$Move) {
|
3896
|
+
difStyles.$Left = toLeft;
|
3897
|
+
difStyles.$Top = toTop;
|
3898
|
+
}
|
3899
|
+
}
|
3900
|
+
|
3901
|
+
//duration
|
3902
|
+
var duration = transition.$Duration;
|
3903
|
+
|
3904
|
+
fromStyles = $Jssor$.$Extend(fromStyles, $Jssor$.$GetStyles(captionItem, difStyles));
|
3905
|
+
|
3906
|
+
animatorOptions.$Setter = $Jssor$.$StyleSetterEx();
|
3907
|
+
|
3908
|
+
return new $JssorAnimator$(transition.$Delay, duration, animatorOptions, captionItem, fromStyles, difStyles);
|
3909
|
+
}
|
3910
|
+
|
3911
|
+
function CreateAnimators(streamLineLength, captionItems) {
|
3912
|
+
|
3913
|
+
$Jssor$.$Each(captionItems, function (captionItem, i) {
|
3914
|
+
|
3915
|
+
$JssorDebug$.$Execute(function () {
|
3916
|
+
if (captionItem.length) {
|
3917
|
+
var top = $Jssor$.$CssTop(captionItem.$Elmt);
|
3918
|
+
var left = $Jssor$.$CssLeft(captionItem.$Elmt);
|
3919
|
+
var width = $Jssor$.$CssWidth(captionItem.$Elmt);
|
3920
|
+
var height = $Jssor$.$CssHeight(captionItem.$Elmt);
|
3921
|
+
|
3922
|
+
var error = null;
|
3923
|
+
|
3924
|
+
if (isNaN(top))
|
3925
|
+
error = "Style 'top' for caption not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'.";
|
3926
|
+
else if (isNaN(left))
|
3927
|
+
error = "Style 'left' not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'.";
|
3928
|
+
else if (isNaN(width))
|
3929
|
+
error = "Style 'width' not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'.";
|
3930
|
+
else if (isNaN(height))
|
3931
|
+
error = "Style 'height' not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'.";
|
3932
|
+
|
3933
|
+
if (error)
|
3934
|
+
$JssorDebug$.$Error("Caption " + (i + 1) + " definition error, \r\n" + error + "\r\n" + captionItem.$Elmt.outerHTML);
|
3935
|
+
}
|
3936
|
+
});
|
3937
|
+
|
3938
|
+
var animator;
|
3939
|
+
var captionElmt = captionItem.$Elmt;
|
3940
|
+
var transition = captionItem[0];
|
3941
|
+
var transition3 = captionItem[1];
|
3942
|
+
|
3943
|
+
if (transition) {
|
3944
|
+
|
3945
|
+
animator = CreateAnimator(captionElmt, transition);
|
3946
|
+
streamLineLength = animator.$Locate(transition.$BeginTime == undefined ? streamLineLength : transition.$BeginTime, 1);
|
3947
|
+
}
|
3948
|
+
|
3949
|
+
streamLineLength = CreateAnimators(streamLineLength, captionItem.$Children);
|
3950
|
+
|
3951
|
+
if (transition3) {
|
3952
|
+
var animator3 = CreateAnimator(captionElmt, transition3, 1);
|
3953
|
+
animator3.$Locate(streamLineLength, 1);
|
3954
|
+
_Self.$Combine(animator3);
|
3955
|
+
_ImmediateOutCaptionHanger.$Combine(animator3);
|
3956
|
+
}
|
3957
|
+
|
3958
|
+
if (animator)
|
3959
|
+
_Self.$Combine(animator);
|
3960
|
+
});
|
3961
|
+
|
3962
|
+
return streamLineLength;
|
3963
|
+
}
|
3964
|
+
|
3965
|
+
_Self.$Revert = function () {
|
3966
|
+
_Self.$GoToPosition(_Self.$GetPosition_OuterEnd() * (playIn || 0));
|
3967
|
+
_ImmediateOutCaptionHanger.$GoToPosition(0);
|
3968
|
+
};
|
3969
|
+
|
3970
|
+
//Constructor
|
3971
|
+
{
|
3972
|
+
_ImmediateOutCaptionHanger = new $JssorAnimator$(0, 0);
|
3973
|
+
|
3974
|
+
CreateAnimators(0, _PlayMode ? GetCaptionItems(container, 1) : []);
|
3975
|
+
}
|
3976
|
+
};
|
3977
|
+
|
3978
|
+
var $JssorCaptionSlideo$ = function (container, captionSlideoOptions, playIn) {
|
3979
|
+
$JssorDebug$.$Execute(function () {
|
3980
|
+
if (!captionSlideoOptions.$CaptionTransitions) {
|
3981
|
+
$JssorDebug$.$Error("'$CaptionSlideoOptions' option error, '$CaptionSlideoOptions.$CaptionTransitions' not specified.");
|
3982
|
+
}
|
3983
|
+
else if (!$Jssor$.$IsArray(captionSlideoOptions.$CaptionTransitions)) {
|
3984
|
+
$JssorDebug$.$Error("'$CaptionSlideoOptions' option error, '$CaptionSlideoOptions.$CaptionTransitions' is not an array.");
|
3985
|
+
}
|
3986
|
+
});
|
3987
|
+
|
3988
|
+
var _This = this;
|
3989
|
+
|
3990
|
+
var _Easings;
|
3991
|
+
var _TransitionConverter = {};
|
3992
|
+
var _CaptionTransitions = captionSlideoOptions.$CaptionTransitions;
|
3993
|
+
|
3994
|
+
$JssorAnimator$.call(_This, 0, 0);
|
3995
|
+
|
3996
|
+
function ConvertTransition(transition, isEasing) {
|
3997
|
+
$Jssor$.$Each(transition, function (property, name) {
|
3998
|
+
var performName = _TransitionConverter[name];
|
3999
|
+
if (performName) {
|
4000
|
+
if (isEasing || name == "e") {
|
4001
|
+
if ($Jssor$.$IsNumeric(property)) {
|
4002
|
+
property = _Easings[property];
|
4003
|
+
}
|
4004
|
+
else if ($Jssor$.$IsPlainObject(property)) {
|
4005
|
+
ConvertTransition(property, true);
|
4006
|
+
}
|
4007
|
+
}
|
4008
|
+
|
4009
|
+
transition[performName] = property;
|
4010
|
+
delete transition[name];
|
4011
|
+
}
|
4012
|
+
});
|
4013
|
+
}
|
4014
|
+
|
4015
|
+
function GetCaptionItems(element, level) {
|
4016
|
+
|
4017
|
+
var itemsToPlay = [];
|
4018
|
+
|
4019
|
+
var captionElmts = $Jssor$.$Children(element);
|
4020
|
+
$Jssor$.$Each(captionElmts, function (captionElmt, i) {
|
4021
|
+
var isCaption = $Jssor$.$AttributeEx(captionElmt, "u") == "caption";
|
4022
|
+
if (isCaption) {
|
4023
|
+
var transitionName = $Jssor$.$AttributeEx(captionElmt, "t");
|
4024
|
+
var transition = _CaptionTransitions[$Jssor$.$ParseInt(transitionName)] || _CaptionTransitions[transitionName];
|
4025
|
+
|
4026
|
+
var transitionName2 = $Jssor$.$AttributeEx(captionElmt, "t2");
|
4027
|
+
var transition2 = _CaptionTransitions[$Jssor$.$ParseInt(transitionName2)] || _CaptionTransitions[transitionName2];
|
4028
|
+
|
4029
|
+
var itemToPlay = { $Elmt: captionElmt, $Transition: transition, $Transition2: transition2 };
|
4030
|
+
if (level < 3) {
|
4031
|
+
itemsToPlay.concat(GetCaptionItems(captionElmt, level + 1));
|
4032
|
+
}
|
4033
|
+
itemsToPlay.push(itemToPlay);
|
4034
|
+
}
|
4035
|
+
});
|
4036
|
+
|
4037
|
+
return itemsToPlay;
|
4038
|
+
}
|
4039
|
+
|
4040
|
+
function CreateAnimator(captionElmt, transitions, lastStyles, forIn) {
|
4041
|
+
|
4042
|
+
$Jssor$.$Each(transitions, function (transition) {
|
4043
|
+
ConvertTransition(transition);
|
4044
|
+
|
4045
|
+
var animatorOptions = {
|
4046
|
+
$Easing: transition.$Easing,
|
4047
|
+
$Round: transition.$Round,
|
4048
|
+
$During: transition.$During,
|
4049
|
+
$Setter: $Jssor$.$StyleSetterEx()
|
4050
|
+
};
|
4051
|
+
|
4052
|
+
var fromStyles = $Jssor$.$Extend($Jssor$.$GetStyles(captionItem, transition), lastStyles);
|
4053
|
+
|
4054
|
+
var animator = new $JssorAnimator$(transition.b || 0, transition.d, animatorOptions, captionElmt, fromStyles, transition);
|
4055
|
+
|
4056
|
+
!forIn == !playIn && _This.$Combine(animator);
|
4057
|
+
|
4058
|
+
var castOptions;
|
4059
|
+
lastStyles = $Jssor$.$Extend(lastStyles, $Jssor$.$Cast(fromStyles, transition, 1, animatorOptions.$Easing, animatorOptions.$During, animatorOptions.$Round, animatorOptions, castOptions));
|
4060
|
+
});
|
4061
|
+
|
4062
|
+
return lastStyles;
|
4063
|
+
}
|
4064
|
+
|
4065
|
+
function CreateAnimators(captionItems) {
|
4066
|
+
|
4067
|
+
$Jssor$.$Each(captionItems, function (captionItem, i) {
|
4068
|
+
|
4069
|
+
$JssorDebug$.$Execute(function () {
|
4070
|
+
if (captionItem.length) {
|
4071
|
+
var top = $Jssor$.$CssTop(captionItem.$Elmt);
|
4072
|
+
var left = $Jssor$.$CssLeft(captionItem.$Elmt);
|
4073
|
+
var width = $Jssor$.$CssWidth(captionItem.$Elmt);
|
4074
|
+
var height = $Jssor$.$CssHeight(captionItem.$Elmt);
|
4075
|
+
|
4076
|
+
var error = null;
|
4077
|
+
|
4078
|
+
if (isNaN(top))
|
4079
|
+
error = "style 'top' not specified";
|
4080
|
+
else if (isNaN(left))
|
4081
|
+
error = "style 'left' not specified";
|
4082
|
+
else if (isNaN(width))
|
4083
|
+
error = "style 'width' not specified";
|
4084
|
+
else if (isNaN(height))
|
4085
|
+
error = "style 'height' not specified";
|
4086
|
+
|
4087
|
+
if (error)
|
4088
|
+
throw new Error("Caption " + (i + 1) + " definition error, " + error + ".\r\n" + captionItem.$Elmt.outerHTML);
|
4089
|
+
}
|
4090
|
+
});
|
4091
|
+
|
4092
|
+
var captionElmt = captionItem.$Elmt;
|
4093
|
+
|
4094
|
+
var captionItemWidth = $Jssor$.$CssWidth(captionItem);
|
4095
|
+
var captionItemHeight = $Jssor$.$CssHeight(captionItem);
|
4096
|
+
var captionParentWidth = $Jssor$.$CssWidth(captionParent);
|
4097
|
+
var captionParentHeight = $Jssor$.$CssHeight(captionParent);
|
4098
|
+
|
4099
|
+
var lastStyles = { $Zoom: 1, $Rotate: 0, $Clip: { $Top: 0, $Right: captionItemWidth, $Bottom: captionItemHeight, $Left: 0 } };
|
4100
|
+
|
4101
|
+
lastStyles = CreateAnimator(captionElmt, captionItem.$Transition, lastStyles, true);
|
4102
|
+
CreateAnimator(captionElmt, captionItem.$Transition2, lastStyles, false);
|
4103
|
+
});
|
4104
|
+
}
|
4105
|
+
|
4106
|
+
_This.$Revert = function () {
|
4107
|
+
_This.$GoToPosition(-1, true);
|
4108
|
+
}
|
4109
|
+
|
4110
|
+
//Constructor
|
4111
|
+
{
|
4112
|
+
_Easings = [
|
4113
|
+
$JssorEasing$.$EaseSwing,
|
4114
|
+
$JssorEasing$.$EaseLinear,
|
4115
|
+
$JssorEasing$.$EaseInQuad,
|
4116
|
+
$JssorEasing$.$EaseOutQuad,
|
4117
|
+
$JssorEasing$.$EaseInOutQuad,
|
4118
|
+
$JssorEasing$.$EaseInCubic,
|
4119
|
+
$JssorEasing$.$EaseOutCubic,
|
4120
|
+
$JssorEasing$.$EaseInOutCubic,
|
4121
|
+
$JssorEasing$.$EaseInQuart,
|
4122
|
+
$JssorEasing$.$EaseOutQuart,
|
4123
|
+
$JssorEasing$.$EaseInOutQuart,
|
4124
|
+
$JssorEasing$.$EaseInQuint,
|
4125
|
+
$JssorEasing$.$EaseOutQuint,
|
4126
|
+
$JssorEasing$.$EaseInOutQuint,
|
4127
|
+
$JssorEasing$.$EaseInSine,
|
4128
|
+
$JssorEasing$.$EaseOutSine,
|
4129
|
+
$JssorEasing$.$EaseInOutSine,
|
4130
|
+
$JssorEasing$.$EaseInExpo,
|
4131
|
+
$JssorEasing$.$EaseOutExpo,
|
4132
|
+
$JssorEasing$.$EaseInOutExpo,
|
4133
|
+
$JssorEasing$.$EaseInCirc,
|
4134
|
+
$JssorEasing$.$EaseOutCirc,
|
4135
|
+
$JssorEasing$.$EaseInOutCirc,
|
4136
|
+
$JssorEasing$.$EaseInElastic,
|
4137
|
+
$JssorEasing$.$EaseOutElastic,
|
4138
|
+
$JssorEasing$.$EaseInOutElastic,
|
4139
|
+
$JssorEasing$.$EaseInBack,
|
4140
|
+
$JssorEasing$.$EaseOutBack,
|
4141
|
+
$JssorEasing$.$EaseInOutBack,
|
4142
|
+
$JssorEasing$.$EaseInBounce,
|
4143
|
+
$JssorEasing$.$EaseOutBounce,
|
4144
|
+
$JssorEasing$.$EaseInOutBounce//,
|
4145
|
+
//$JssorEasing$.$EaseGoBack,
|
4146
|
+
//$JssorEasing$.$EaseInWave,
|
4147
|
+
//$JssorEasing$.$EaseOutWave,
|
4148
|
+
//$JssorEasing$.$EaseOutJump,
|
4149
|
+
//$JssorEasing$.$EaseInJump
|
4150
|
+
];
|
4151
|
+
|
4152
|
+
var translater = {
|
4153
|
+
$Top: "y", //top
|
4154
|
+
$Left: "x", //left
|
4155
|
+
$Bottom: "m", //bottom
|
4156
|
+
$Right: "t", //right
|
4157
|
+
$Zoom: "s", //zoom/scale
|
4158
|
+
$Rotate: "r", //rotate
|
4159
|
+
$Opacity: "o", //opacity
|
4160
|
+
$Easing: "e", //easing
|
4161
|
+
$ZIndex: "i", //zindex
|
4162
|
+
$Round: "rd", //round
|
4163
|
+
$During: "du", //during
|
4164
|
+
$Duration: "d"//, //duration
|
4165
|
+
//$Begin: "b"
|
4166
|
+
};
|
4167
|
+
|
4168
|
+
$Jssor$.$Each(translater, function (prop, newProp) {
|
4169
|
+
_TransitionConverter[prop] = newProp;
|
4170
|
+
});
|
4171
|
+
|
4172
|
+
CreateAnimators(GetCaptionItems(container, 1));
|
4173
|
+
}
|
4174
|
+
};
|
4175
|
+
|
4176
|
+
//Event Table
|
4177
|
+
|
4178
|
+
//$EVT_CLICK = 21; function(slideIndex[, event])
|
4179
|
+
//$EVT_DRAG_START = 22; function(position[, virtualPosition, event])
|
4180
|
+
//$EVT_DRAG_END = 23; function(position, startPosition[, virtualPosition, virtualStartPosition, event])
|
4181
|
+
//$EVT_SWIPE_START = 24; function(position[, virtualPosition])
|
4182
|
+
//$EVT_SWIPE_END = 25; function(position[, virtualPosition])
|
4183
|
+
|
4184
|
+
//$EVT_LOAD_START = 26; function(slideIndex)
|
4185
|
+
//$EVT_LOAD_END = 27; function(slideIndex)
|
4186
|
+
|
4187
|
+
//$EVT_POSITION_CHANGE = 202; function(position, fromPosition[, virtualPosition, virtualFromPosition])
|
4188
|
+
//$EVT_PARK = 203; function(slideIndex, fromIndex)
|
4189
|
+
|
4190
|
+
//$EVT_PROGRESS_CHANGE = 208; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd])
|
4191
|
+
//$EVT_STATE_CHANGE = 209; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd])
|
4192
|
+
|
4193
|
+
//$EVT_ROLLBACK_START = 210; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd])
|
4194
|
+
//$EVT_ROLLBACK_END = 211; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd])
|
4195
|
+
|
4196
|
+
//$EVT_SLIDESHOW_START = 206; function(slideIndex[, progressBegin, slideshowBegin, slideshowEnd, progressEnd])
|
4197
|
+
//$EVT_SLIDESHOW_END = 207; function(slideIndex[, progressBegin, slideshowBegin, slideshowEnd, progressEnd])
|
4198
|
+
|