thumbnails.carousel.js
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// thumbnails.carousel.js jQuery plugin
;(function(window, $, undefined) {
var conf = {
center: true,
backgroundControl: false
};
var cache = {
$carouselContainer: $('.thumbnails-carousel').parent(),
$thumbnailsLi: $('.thumbnails-carousel li'),
$controls: $('.thumbnails-carousel').parent().find('.carousel-control')
};
function init() {
cache.$carouselContainer.find('ol.carousel-indicators').addClass('indicators-fix');
cache.$thumbnailsLi.first().addClass('active-thumbnail');
if(!conf.backgroundControl) {
cache.$carouselContainer.find('.carousel-control').addClass('controls-background-reset');
}
else {
cache.$controls.height(cache.$carouselContainer.find('.carousel-inner').height());
}
if(conf.center) {
cache.$thumbnailsLi.wrapAll("<div class='center clearfix'></div>");
}
}
function refreshOpacities(domEl) {
cache.$thumbnailsLi.removeClass('active-thumbnail');
cache.$thumbnailsLi.eq($(domEl).index()).addClass('active-thumbnail');
}
function bindUiActions() {
cache.$carouselContainer.on('slide.bs.carousel', function(e) {
refreshOpacities(e.relatedTarget);
});
cache.$thumbnailsLi.click(function(){
cache.$carouselContainer.carousel($(this).index());
});
}
$.fn.thumbnailsCarousel = function(options) {
conf = $.extend(conf, options);
init();
bindUiActions();
return this;
}
})(window, jQuery);