-
Notifications
You must be signed in to change notification settings - Fork 1
/
carotte.auto.js
70 lines (55 loc) · 1.62 KB
/
carotte.auto.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* [URL] */
;(function($, window, document, undefined) {
var r = $.carotte.slideshow;
r.autoslide = {
options : {
time:2000,
textPlay:'play',
textPause:'pause',
duration:700,
pauseOnHover:false
}
};
$.fn.autoslide = function(options) {
options = $.extend({}, r.autoslide.options, options);
return this.each(function(){
var slideshow = $(this),
parentSlideshow = $(this).parent().parent(),
navAutoSlide = '<button class="playCarotte">'+options.textPlay+'</button><button class="stopCarotte">'+options.textPause+'</button>',
navCarotte = parentSlideshow.find('.navCarotte'),
paused = false;
navCarotte.append(navAutoSlide);
var playBtn = navCarotte.find('.playCarotte'),
stopBtn = navCarotte.find('.stopCarotte');
stopFct = function() {
autoSlideShow = clearInterval(autoSlideShow);
};
playFct = function() {
autoSlideShow = setInterval(function() {
if (!paused) {
$.fn.carotte.slide(slideshow, 'next', options.duration);
}
}, options.time);
};
//Slide
playFct();
//button to slide
playBtn.bind('click', function(){
playFct();
});
//button to stop slide
stopBtn.bind('click', function(){
stopFct();
});
if (options.pauseOnHover) {
slideshow.hover(function() {
paused = true;
},
function() {
paused = false;
}
);
}
});
};
})(jQuery, window, document);