1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
(function ($) {
|
11
|
Drupal.behaviors.viewsSlideshowCycle = {
|
12
|
attach: function (context) {
|
13
|
$('.views_slideshow_cycle_main:not(.viewsSlideshowCycle-processed)', context).addClass('viewsSlideshowCycle-processed').each(function() {
|
14
|
var fullId = '#' + $(this).attr('id');
|
15
|
var settings = Drupal.settings.viewsSlideshowCycle[fullId];
|
16
|
settings.targetId = '#' + $(fullId + " :first").attr('id');
|
17
|
|
18
|
settings.slideshowId = settings.targetId.replace('#views_slideshow_cycle_teaser_section_', '');
|
19
|
|
20
|
var pager_after_fn = function(curr, next, opts) {
|
21
|
|
22
|
var slideNum = opts.currSlide;
|
23
|
if (typeof settings.processedAfter == 'undefined' || !settings.processedAfter) {
|
24
|
settings.processedAfter = 1;
|
25
|
slideNum = (typeof settings.opts.startingSlide == 'undefined') ? 0 : settings.opts.startingSlide;
|
26
|
}
|
27
|
Drupal.viewsSlideshow.action({ "action": 'transitionEnd', "slideshowID": settings.slideshowId, "slideNum": slideNum });
|
28
|
}
|
29
|
|
30
|
var pager_before_fn = function(curr, next, opts) {
|
31
|
var slideNum = opts.nextSlide;
|
32
|
|
33
|
|
34
|
if (settings.remember_slide) {
|
35
|
createCookie(settings.vss_id, slideNum, settings.remember_slide_days);
|
36
|
}
|
37
|
|
38
|
|
39
|
if (!settings.fixed_height) {
|
40
|
|
41
|
var $ht = $(next).height();
|
42
|
|
43
|
$(next).parent().animate({height: $ht});
|
44
|
}
|
45
|
|
46
|
|
47
|
if (typeof settings.processedBefore == 'undefined' || !settings.processedBefore) {
|
48
|
settings.processedBefore = 1;
|
49
|
slideNum = (typeof opts.startingSlide == 'undefined') ? 0 : opts.startingSlide;
|
50
|
}
|
51
|
|
52
|
Drupal.viewsSlideshow.action({ "action": 'transitionBegin', "slideshowID": settings.slideshowId, "slideNum": slideNum });
|
53
|
}
|
54
|
settings.loaded = false;
|
55
|
|
56
|
settings.opts = {
|
57
|
speed:settings.speed,
|
58
|
timeout:settings.timeout,
|
59
|
delay:settings.delay,
|
60
|
sync:settings.sync,
|
61
|
random:settings.random,
|
62
|
nowrap:settings.nowrap,
|
63
|
after:pager_after_fn,
|
64
|
before:pager_before_fn,
|
65
|
cleartype:(settings.cleartype)? true : false,
|
66
|
cleartypeNoBg:(settings.cleartypenobg)? true : false
|
67
|
}
|
68
|
|
69
|
|
70
|
if (settings.remember_slide) {
|
71
|
var startSlide = readCookie(settings.vss_id);
|
72
|
if (startSlide == null) {
|
73
|
startSlide = 0;
|
74
|
}
|
75
|
settings.opts.startingSlide = parseInt(startSlide);
|
76
|
}
|
77
|
|
78
|
if (settings.effect == 'none') {
|
79
|
settings.opts.speed = 1;
|
80
|
}
|
81
|
else {
|
82
|
settings.opts.fx = settings.effect;
|
83
|
}
|
84
|
|
85
|
|
86
|
var hash = location.hash;
|
87
|
if (hash) {
|
88
|
var hash = hash.replace('#', '');
|
89
|
var aHash = hash.split(';');
|
90
|
var aHashLen = aHash.length;
|
91
|
|
92
|
|
93
|
for (var i = 0; i < aHashLen; i++) {
|
94
|
|
95
|
|
96
|
var initialInfo = aHash[i].split(':');
|
97
|
|
98
|
|
99
|
|
100
|
if (settings.slideshowId == initialInfo[0] && settings.num_divs > initialInfo[1]) {
|
101
|
settings.opts.startingSlide = parseInt(initialInfo[1]);
|
102
|
}
|
103
|
}
|
104
|
}
|
105
|
|
106
|
|
107
|
if (settings.pause) {
|
108
|
var mouseIn = function() {
|
109
|
Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId });
|
110
|
}
|
111
|
|
112
|
var mouseOut = function() {
|
113
|
Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId });
|
114
|
}
|
115
|
|
116
|
if (jQuery.fn.hoverIntent) {
|
117
|
$('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hoverIntent(mouseIn, mouseOut);
|
118
|
}
|
119
|
else {
|
120
|
$('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hover(mouseIn, mouseOut);
|
121
|
}
|
122
|
}
|
123
|
|
124
|
|
125
|
if (settings.pause_on_click) {
|
126
|
$('#views_slideshow_cycle_teaser_section_' + settings.vss_id).click(function() {
|
127
|
Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId, "force": true });
|
128
|
});
|
129
|
}
|
130
|
|
131
|
if (typeof JSON != 'undefined') {
|
132
|
var advancedOptions = JSON.parse(settings.advanced_options);
|
133
|
for (var option in advancedOptions) {
|
134
|
switch(option) {
|
135
|
|
136
|
|
137
|
case "activePagerClass":
|
138
|
case "allowPagerClickBubble":
|
139
|
case "autostop":
|
140
|
case "autostopCount":
|
141
|
case "backwards":
|
142
|
case "bounce":
|
143
|
case "cleartype":
|
144
|
case "cleartypeNoBg":
|
145
|
case "containerResize":
|
146
|
case "continuous":
|
147
|
case "delay":
|
148
|
case "easeIn":
|
149
|
case "easeOut":
|
150
|
case "easing":
|
151
|
case "fastOnEvent":
|
152
|
case "fit":
|
153
|
case "fx":
|
154
|
case "height":
|
155
|
case "manualTrump":
|
156
|
case "metaAttr":
|
157
|
case "next":
|
158
|
case "nowrap":
|
159
|
case "pager":
|
160
|
case "pagerEvent":
|
161
|
case "pause":
|
162
|
case "pauseOnPagerHover":
|
163
|
case "prev":
|
164
|
case "prevNextEvent":
|
165
|
case "random":
|
166
|
case "randomizeEffects":
|
167
|
case "requeueOnImageNotLoaded":
|
168
|
case "requeueTimeout":
|
169
|
case "rev":
|
170
|
case "slideExpr":
|
171
|
case "slideResize":
|
172
|
case "speed":
|
173
|
case "speedIn":
|
174
|
case "speedOut":
|
175
|
case "startingSlide":
|
176
|
case "sync":
|
177
|
case "timeout":
|
178
|
case "width":
|
179
|
var optionValue = advancedOptions[option];
|
180
|
optionValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(optionValue);
|
181
|
settings.opts[option] = optionValue;
|
182
|
break;
|
183
|
|
184
|
|
185
|
case "animIn":
|
186
|
case "animOut":
|
187
|
case "cssBefore":
|
188
|
case "cssAfter":
|
189
|
case "shuffle":
|
190
|
var cssValue = advancedOptions[option];
|
191
|
cssValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(cssValue);
|
192
|
settings.opts[option] = eval('(' + cssValue + ')');
|
193
|
break;
|
194
|
|
195
|
|
196
|
case "after":
|
197
|
var afterValue = advancedOptions[option];
|
198
|
afterValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(afterValue);
|
199
|
|
200
|
settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
|
201
|
pager_after_fn(currSlideElement, nextSlideElement, options);
|
202
|
eval(afterValue);
|
203
|
}
|
204
|
break;
|
205
|
|
206
|
case "before":
|
207
|
var beforeValue = advancedOptions[option];
|
208
|
beforeValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(beforeValue);
|
209
|
|
210
|
settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
|
211
|
pager_before_fn(currSlideElement, nextSlideElement, options);
|
212
|
eval(beforeValue);
|
213
|
}
|
214
|
break;
|
215
|
|
216
|
case "end":
|
217
|
var endValue = advancedOptions[option];
|
218
|
endValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(endValue);
|
219
|
|
220
|
settings.opts[option] = function(options) {
|
221
|
eval(endValue);
|
222
|
}
|
223
|
break;
|
224
|
|
225
|
case "fxFn":
|
226
|
var fxFnValue = advancedOptions[option];
|
227
|
fxFnValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(fxFnValue);
|
228
|
|
229
|
settings.opts[option] = function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) {
|
230
|
eval(fxFnValue);
|
231
|
}
|
232
|
break;
|
233
|
|
234
|
case "onPagerEvent":
|
235
|
var onPagerEventValue = advancedOptions[option];
|
236
|
onPagerEventValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(onPagerEventValue);
|
237
|
settings.opts[option] = function(zeroBasedSlideIndex, slideElement) {
|
238
|
eval(onPagerEventValue);
|
239
|
}
|
240
|
break;
|
241
|
|
242
|
case "onPrevNextEvent":
|
243
|
var onPrevNextEventValue = advancedOptions[option];
|
244
|
onPrevNextEventValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(onPrevNextEventValue);
|
245
|
settings.opts[option] = function(isNext, zeroBasedSlideIndex, slideElement) {
|
246
|
eval(onPrevNextEventValue);
|
247
|
}
|
248
|
break;
|
249
|
|
250
|
case "pagerAnchorBuilder":
|
251
|
var pagerAnchorBuilderValue = advancedOptions[option];
|
252
|
pagerAnchorBuilderValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pagerAnchorBuilderValue);
|
253
|
|
254
|
settings.opts[option] = function(index, DOMelement) {
|
255
|
var returnVal = '';
|
256
|
eval(pagerAnchorBuilderValue);
|
257
|
return returnVal;
|
258
|
}
|
259
|
break;
|
260
|
|
261
|
case "pagerClick":
|
262
|
var pagerClickValue = advancedOptions[option];
|
263
|
pagerClickValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pagerClickValue);
|
264
|
|
265
|
settings.opts[option] = function(zeroBasedSlideIndex, slideElement) {
|
266
|
eval(pagerClickValue);
|
267
|
}
|
268
|
break;
|
269
|
|
270
|
case "paused":
|
271
|
var pausedValue = advancedOptions[option];
|
272
|
pausedValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pausedValue);
|
273
|
|
274
|
settings.opts[option] = function(cont, opts, byHover) {
|
275
|
eval(pausedValue);
|
276
|
}
|
277
|
break;
|
278
|
|
279
|
case "resumed":
|
280
|
var resumedValue = advancedOptions[option];
|
281
|
resumedValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(resumedValue);
|
282
|
|
283
|
settings.opts[option] = function(cont, opts, byHover) {
|
284
|
eval(resumedValue);
|
285
|
}
|
286
|
break;
|
287
|
|
288
|
case "timeoutFn":
|
289
|
var timeoutFnValue = advancedOptions[option];
|
290
|
timeoutFnValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(timeoutFnValue);
|
291
|
settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
|
292
|
eval(timeoutFnValue);
|
293
|
}
|
294
|
break;
|
295
|
|
296
|
case "updateActivePagerLink":
|
297
|
var updateActivePagerLinkValue = advancedOptions[option];
|
298
|
updateActivePagerLinkValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(updateActivePagerLinkValue);
|
299
|
|
300
|
settings.opts[option] = function(pager, currSlideIndex) {
|
301
|
eval(updateActivePagerLinkValue);
|
302
|
}
|
303
|
break;
|
304
|
}
|
305
|
}
|
306
|
}
|
307
|
|
308
|
|
309
|
|
310
|
if (settings.wait_for_image_load) {
|
311
|
|
312
|
|
313
|
settings.totalImages = $(settings.targetId + ' img').length;
|
314
|
if (settings.totalImages) {
|
315
|
settings.loadedImages = 0;
|
316
|
|
317
|
|
318
|
$(settings.targetId + ' img').each(function() {
|
319
|
var $imageElement = $(this);
|
320
|
$imageElement.bind('load', function () {
|
321
|
Drupal.viewsSlideshowCycle.imageWait(fullId);
|
322
|
});
|
323
|
|
324
|
|
325
|
var imgSrc = $imageElement.attr('src');
|
326
|
$imageElement.attr('src', '');
|
327
|
$imageElement.attr('src', imgSrc);
|
328
|
});
|
329
|
|
330
|
|
331
|
|
332
|
setTimeout("Drupal.viewsSlideshowCycle.load('" + fullId + "')", settings.wait_for_image_load_timeout);
|
333
|
}
|
334
|
else {
|
335
|
Drupal.viewsSlideshowCycle.load(fullId);
|
336
|
}
|
337
|
}
|
338
|
else {
|
339
|
Drupal.viewsSlideshowCycle.load(fullId);
|
340
|
}
|
341
|
});
|
342
|
}
|
343
|
};
|
344
|
|
345
|
Drupal.viewsSlideshowCycle = Drupal.viewsSlideshowCycle || {};
|
346
|
|
347
|
|
348
|
Drupal.viewsSlideshowCycle.advancedOptionCleanup = function(value) {
|
349
|
value = $.trim(value);
|
350
|
value = value.replace(/\n/g, '');
|
351
|
if (!isNaN(parseInt(value))) {
|
352
|
value = parseInt(value);
|
353
|
}
|
354
|
else if (value.toLowerCase() == 'true') {
|
355
|
value = true;
|
356
|
}
|
357
|
else if (value.toLowerCase() == 'false') {
|
358
|
value = false;
|
359
|
}
|
360
|
|
361
|
return value;
|
362
|
}
|
363
|
|
364
|
|
365
|
|
366
|
Drupal.viewsSlideshowCycle.imageWait = function(fullId) {
|
367
|
if (++Drupal.settings.viewsSlideshowCycle[fullId].loadedImages == Drupal.settings.viewsSlideshowCycle[fullId].totalImages) {
|
368
|
Drupal.viewsSlideshowCycle.load(fullId);
|
369
|
}
|
370
|
};
|
371
|
|
372
|
|
373
|
Drupal.viewsSlideshowCycle.load = function (fullId) {
|
374
|
var settings = Drupal.settings.viewsSlideshowCycle[fullId];
|
375
|
|
376
|
|
377
|
if (!settings.loaded) {
|
378
|
$(settings.targetId).cycle(settings.opts);
|
379
|
settings.loaded = true;
|
380
|
|
381
|
|
382
|
if (settings.start_paused) {
|
383
|
Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId, "force": true });
|
384
|
}
|
385
|
|
386
|
|
387
|
if (settings.pause_when_hidden) {
|
388
|
var checkPause = function(settings) {
|
389
|
|
390
|
|
391
|
|
392
|
var visible = viewsSlideshowCycleIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible);
|
393
|
if (visible) {
|
394
|
Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId });
|
395
|
}
|
396
|
else {
|
397
|
Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId });
|
398
|
}
|
399
|
}
|
400
|
|
401
|
|
402
|
$(window).scroll(function() {
|
403
|
checkPause(settings);
|
404
|
});
|
405
|
|
406
|
|
407
|
$(window).resize(function() {
|
408
|
checkPause(settings);
|
409
|
});
|
410
|
}
|
411
|
}
|
412
|
};
|
413
|
|
414
|
Drupal.viewsSlideshowCycle.pause = function (options) {
|
415
|
|
416
|
try{
|
417
|
if (options.pause_in_middle && $.fn.pause) {
|
418
|
$('#views_slideshow_cycle_teaser_section_' + options.slideshowID).pause();
|
419
|
}
|
420
|
else {
|
421
|
$('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('pause');
|
422
|
}
|
423
|
}
|
424
|
catch(e){
|
425
|
if(!e instanceof TypeError){
|
426
|
throw e;
|
427
|
}
|
428
|
}
|
429
|
};
|
430
|
|
431
|
Drupal.viewsSlideshowCycle.play = function (options) {
|
432
|
Drupal.settings.viewsSlideshowCycle['#views_slideshow_cycle_main_' + options.slideshowID].paused = false;
|
433
|
if (options.pause_in_middle && $.fn.resume) {
|
434
|
$('#views_slideshow_cycle_teaser_section_' + options.slideshowID).resume();
|
435
|
}
|
436
|
else {
|
437
|
$('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('resume');
|
438
|
}
|
439
|
};
|
440
|
|
441
|
Drupal.viewsSlideshowCycle.previousSlide = function (options) {
|
442
|
$('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('prev');
|
443
|
};
|
444
|
|
445
|
Drupal.viewsSlideshowCycle.nextSlide = function (options) {
|
446
|
$('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('next');
|
447
|
};
|
448
|
|
449
|
Drupal.viewsSlideshowCycle.goToSlide = function (options) {
|
450
|
$('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle(options.slideNum);
|
451
|
};
|
452
|
|
453
|
|
454
|
function IsNumeric(sText) {
|
455
|
var ValidChars = "0123456789";
|
456
|
var IsNumber=true;
|
457
|
var Char;
|
458
|
|
459
|
for (var i=0; i < sText.length && IsNumber == true; i++) {
|
460
|
Char = sText.charAt(i);
|
461
|
if (ValidChars.indexOf(Char) == -1) {
|
462
|
IsNumber = false;
|
463
|
}
|
464
|
}
|
465
|
return IsNumber;
|
466
|
}
|
467
|
|
468
|
|
469
|
|
470
|
|
471
|
function createCookie(name,value,days) {
|
472
|
if (days) {
|
473
|
var date = new Date();
|
474
|
date.setTime(date.getTime()+(days*24*60*60*1000));
|
475
|
var expires = "; expires="+date.toGMTString();
|
476
|
}
|
477
|
else {
|
478
|
var expires = "";
|
479
|
}
|
480
|
document.cookie = name+"="+value+expires+"; path=/";
|
481
|
}
|
482
|
|
483
|
function readCookie(name) {
|
484
|
var nameEQ = name + "=";
|
485
|
var ca = document.cookie.split(';');
|
486
|
for(var i=0;i < ca.length;i++) {
|
487
|
var c = ca[i];
|
488
|
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
489
|
if (c.indexOf(nameEQ) == 0) {
|
490
|
return c.substring(nameEQ.length,c.length);
|
491
|
}
|
492
|
}
|
493
|
return null;
|
494
|
}
|
495
|
|
496
|
function eraseCookie(name) {
|
497
|
createCookie(name,"",-1);
|
498
|
}
|
499
|
|
500
|
|
501
|
|
502
|
|
503
|
|
504
|
|
505
|
|
506
|
|
507
|
|
508
|
|
509
|
function viewsSlideshowCycleIsVisible(elem, type, amountVisible) {
|
510
|
|
511
|
var docViewTop = $(window).scrollTop();
|
512
|
var docViewBottom = docViewTop + $(window).height();
|
513
|
var docViewLeft = $(window).scrollLeft();
|
514
|
var docViewRight = docViewLeft + $(window).width();
|
515
|
|
516
|
|
517
|
var elemTop = $(elem).offset().top;
|
518
|
var elemHeight = $(elem).height();
|
519
|
var elemBottom = elemTop + elemHeight;
|
520
|
var elemLeft = $(elem).offset().left;
|
521
|
var elemWidth = $(elem).width();
|
522
|
var elemRight = elemLeft + elemWidth;
|
523
|
var elemArea = elemHeight * elemWidth;
|
524
|
|
525
|
|
526
|
var missingLeft = 0;
|
527
|
var missingRight = 0;
|
528
|
var missingTop = 0;
|
529
|
var missingBottom = 0;
|
530
|
|
531
|
|
532
|
if (elemLeft < docViewLeft) {
|
533
|
missingLeft = docViewLeft - elemLeft;
|
534
|
}
|
535
|
|
536
|
|
537
|
if (elemRight > docViewRight) {
|
538
|
missingRight = elemRight - docViewRight;
|
539
|
}
|
540
|
|
541
|
|
542
|
if (elemTop < docViewTop) {
|
543
|
missingTop = docViewTop - elemTop;
|
544
|
}
|
545
|
|
546
|
|
547
|
if (elemBottom > docViewBottom) {
|
548
|
missingBottom = elemBottom - docViewBottom;
|
549
|
}
|
550
|
|
551
|
|
552
|
|
553
|
if (type == 'full') {
|
554
|
return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
|
555
|
&& (elemBottom <= docViewBottom) && (elemTop >= docViewTop)
|
556
|
&& (elemLeft >= docViewLeft) && (elemRight <= docViewRight)
|
557
|
&& (elemLeft <= docViewRight) && (elemRight >= docViewLeft));
|
558
|
}
|
559
|
else if(type == 'vertical') {
|
560
|
var verticalShowing = elemHeight - missingTop - missingBottom;
|
561
|
|
562
|
|
563
|
|
564
|
|
565
|
|
566
|
if (amountVisible.indexOf('%')) {
|
567
|
return (((verticalShowing/elemHeight)*100) >= parseInt(amountVisible));
|
568
|
}
|
569
|
else {
|
570
|
return (verticalShowing >= parseInt(amountVisible));
|
571
|
}
|
572
|
}
|
573
|
else if(type == 'horizontal') {
|
574
|
var horizontalShowing = elemWidth - missingLeft - missingRight;
|
575
|
|
576
|
|
577
|
|
578
|
|
579
|
|
580
|
if (amountVisible.indexOf('%')) {
|
581
|
return (((horizontalShowing/elemWidth)*100) >= parseInt(amountVisible));
|
582
|
}
|
583
|
else {
|
584
|
return (horizontalShowing >= parseInt(amountVisible));
|
585
|
}
|
586
|
}
|
587
|
else if(type == 'area') {
|
588
|
var areaShowing = (elemWidth - missingLeft - missingRight) * (elemHeight - missingTop - missingBottom);
|
589
|
|
590
|
|
591
|
|
592
|
|
593
|
|
594
|
if (amountVisible.indexOf('%')) {
|
595
|
return (((areaShowing/elemArea)*100) >= parseInt(amountVisible));
|
596
|
}
|
597
|
else {
|
598
|
return (areaShowing >= parseInt(amountVisible));
|
599
|
}
|
600
|
}
|
601
|
}
|
602
|
})(jQuery);
|