PageSourceSearch

http://carmedia.tech/assets/theme/js/slider.js

js carmedia.tech collected 2026-10-04 15:55:01 UTC 5,418 bytes, 142 lines download raw bytes

1function setActiveCarouselItem(card){
2   var $target = $(card).find('.carousel-item:first');
3   $target.addClass('active');
4} 
5function initTestimonialsCarousel(card){
6    var $target = $(card),
7        $carouselID = $target.attr('ID') +"-carousel"; 
8    $target.find('.carousel').attr('id',$carouselID);
9    $target.find('.carousel-controls a').attr('href','#'+$carouselID);
10    $target.find('.carousel-indicators li').attr('data-target','#'+$carouselID);
11    setActiveCarouselItem($target);  
12}
13function initClientCarousel(card){
14    var $target = $(card),
15    countElems = $target.find('.carousel-item').length,
16    visibleSlides = $target.find('.carousel-inner').attr('data-visible');
17    if (countElems < visibleSlides){
18        visibleSlides = countElems;
19    }
20    $target.find('.carousel-inner').attr('class', 'carousel-inner slides' + visibleSlides);
21    $target.find('.clonedCol').remove();
22
23    $target.find('.carousel-item .col-md-12').each(function() {
24        if (visibleSlides < 2) {
25            $(this).attr('class', 'col-md-12');
26        } else if (visibleSlides == '5') {
27            $(this).attr('class', 'col-md-12 col-lg-15');
28        } else {
29            $(this).attr('class', 'col-md-12 col-lg-' + 12 / visibleSlides);
30        }
31    });
32
33    $target.find('.carousel-item').each(function() {
34        var itemToClone = $(this);
35        for (var i = 1; i < visibleSlides; i++) {
36            itemToClone = itemToClone.next();
37            if (!itemToClone.length) {
38                itemToClone = $(this).siblings(':first');
39            }
40            var index = itemToClone.index();
41            itemToClone.find('.col-md-12:first').clone().addClass('cloneditem-' + i).addClass('clonedCol').attr('data-cloned-index', index).appendTo($(this).children().eq(0));
42        }
43    });
44}
45function updateClientCarousel(card){
46    var $target = $(card),
47        countElems = $target.find('.carousel-item').length,
48        visibleSlides = $target.find('.carousel-inner').attr('data-visible');
49    if (countElems < visibleSlides){
50        visibleSlides = countElems;
51    }
52    $target.find('.clonedCol').remove();
53    $target.find('.carousel-item').each(function() {
54        var itemToClone = $(this);
55        for (var i = 1; i < visibleSlides; i++) {
56            itemToClone = itemToClone.next();
57            if (!itemToClone.length) {
58                itemToClone = $(this).siblings(':first');
59            }
60            var index = itemToClone.index();
61            itemToClone.find('.col-md-12:first').clone().addClass('cloneditem-' + i).addClass('clonedCol').attr('data-cloned-index', index).appendTo($(this).children().eq(0));
62        }
63    });
64}
65function clickHandler(e){
66    e.stopPropagation();
67    e.preventDefault();
68
69    var $target = $(e.target);
70    var curItem;
71    var curIndex;
72
73    if ($target.closest('.clonedCol').length) {
74        curItem = $target.closest('.clonedCol');
75        curIndex = curItem.attr('data-cloned-index');
76    } else {
77        curItem = $target.closest('.carousel-item');
78        curIndex = curItem.index();
79    }
80    var item = $($target.closest('.carousel-inner').find('.carousel-item')[curIndex]).find('img')[0];
81 
82    if ($target.parents('.clonedCol').length > 0) {
83        item.click();
84    }
85}
86
87// Mobirise initialization
88var isBuilder = $('html').hasClass('is-builder');
89if (isBuilder) {
90    $(document).on('add.cards', function(event) {
91        if (!$(event.target).hasClass('clients')) {
92            return;
93        }
94        initTestimonialsCarousel(event.target);
95        initClientCarousel(event.target);
96        if (event.type === 'add') {       
97            $(event.target).on('slide.bs.carousel', function() {
98                updateClientCarousel(event.target);
99            });
100        }
101        $(event.target).find('.carousel-item [mbr-media]').on('click', function(e) {
102            clickHandler(e);
103        });
104        $(event.target).on('slide.bs.carousel', function() {
105            $(event.target).find('.carousel-item .clonedCol [mbr-media]').off('click').on('click', function(e) {
106                        clickHandler(e);
107                    });
108        });
109    }).on('changeParameter.cards', function(event, paramName,value) {
110        if (paramName=='slidesCount'){
111            if ($(event.target).find('.carousel-item.active').length==0) {
112                setActiveCarouselItem(event.target);
113            }                
114        }
115        initClientCarousel(event.target);
116        updateClientCarousel(event.target);
117        $(event.target).find('.carousel-item [mbr-media]').on('click', function(e) {
118            clickHandler(e);
119        });
120        $(event.target).on('slide.bs.carousel', function() {
121            $(event.target).find('.carousel-item .clonedCol [mbr-media]').off('click').on('click', function(e) {
122                        clickHandler(e);
123                    });
124        });
125    }).on('changeContent.cards', function(event,type) {
126       updateClientCarousel(event.target);
127       try{
128        $(event.target).closest('.carousel').carousel('next');
129       }catch(err){}
130    });
131}
132else{
133    if(typeof window.initClientPlugin === 'undefined'){
134        window.initClientPlugin = true;
135        $(document.body).find('.clients').each(function(index, el) {
136            if(!$(this).attr('data-isinit')){
137                initTestimonialsCarousel($(this));
138                initClientCarousel($(this));
139            }  
140        });  
141    }
142}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.