1/* 2 * File : assets/js/script.js 3 */ 4 5( function( $, window ) { 6 7 function myCarousel(id) 8 { 9 const carouselContainer = $('#'+id); 10 const nbEL = carouselContainer.attr('nbElement'); 11 const prevBtn = carouselContainer.find('.prev'); 12 const nextBtn = carouselContainer.find('.next'); 13 const carousel = carouselContainer.find('.carousel'); 14 15 const items = carouselContainer.find('.item'); 16 const itemCount = items.length; 17 let currentIndex = 0; 18 19 var itemWidth = carouselContainer.width() / nbEL; 20 items.css('width', itemWidth + 'px'); 21 var sommeLargeurs = itemWidth * itemCount; 22 carousel.css('width', sommeLargeurs + 'px'); 23 24 prevBtn.on('click', function(e) { 25 e.preventDefault(); 26 target = $(this).attr('target'); 27 console.log("cible: " + target); 28 29 const carousel = $('#'+target + ' .carousel'); 30 if (currentIndex > 0) 31 { 32 currentIndex--; 33 carousel.css('transform', 'translateX(' + -currentIndex * itemWidth + 'px)'); 34 } 35 }); 36 37 nextBtn.on('click', function(e) { 38 e.preventDefault(); 39 target = $(this).attr('target'); 40 const carousel = $('#'+target + ' .carousel'); 41 42 43 carousel.css('transform', 'translateX(' + -currentIndex * itemWidth + 'px)'); 44 var clonedItem = items.eq(currentIndex).clone(); 45 carousel.width(function(index, currentWidth) { 46 return currentWidth + itemWidth; 47 }); 48 carousel.append(clonedItem); 49 currentIndex++; 50 }); 51 52 } 53 54// Make sure you run this code under Elementor. 55$( window ).on( 'elementor/frontend/init', function() { 56 elementorFrontend.hooks.addAction( 'frontend/element_ready/acf_repeater_loop.default', WidgetWycanHandler ); 57}); 58 59 position_slide = 0 60/** 61* @param $scope The Widget wrapper element as a jQuery element 62* @param $ The jQuery alias 63*/ 64var WidgetWycanHandler = function ($scope, $) 65{ 66 67 var elementSettings = {}; 68 69 var modelCID = $scope.data('model-cid') 70 if(elementorFrontend.isEditMode() && modelCID ) 71 { 72 var settings = elementorFrontend.config.elements.data[ modelCID ] 73 settings.getActiveControls() 74 75 jQuery.each(settings.attributes, function( controlKey, object ) { 76 elementSettings[controlKey] = object 77 }) 78 } 79 else 80 { 81 elementSettings = $('.elementor-widget-acf_repeater_loop').data('settings') 82 } 83 84 //Script for masonry skin 85 var masonry = elementSettings.masonry 86 87 if(masonry == "yes") 88 { 89 90 var numberOfColumn = elementSettings.columns 91 var motifLoop = '.elementor-widget-acf_repeater_loop .elementor-grid div.elementor'; 92 93 //Parcours de chaque element de la boucle 94 $(motifLoop).each(function (index) 95 { 96 index = index + 1 97 //Quand on arrive a la ligne on le remonte 98 if(index > numberOfColumn ) 99 { 100 var motifTop = index - numberOfColumn; 101 var marginTop = $(motifLoop +':nth-child('+motifTop+')').height() - $(motifLoop + ':nth-child('+motifTop+') > div').height() - 20 102 $(this).css('margin-top', - marginTop) 103 } 104 }) 105 } 106 //Fin script for masonry skin 107 108 //Script for carousel 109 110 var device = elementorFrontend.getCurrentDeviceMode() 111 var autoPlay = elementSettings.auto_play 112 var auto_play_duration = elementSettings.auto_play_duration 113 console.log(auto_play_duration) 114 115 116 if(device == "desktop") 117 { 118 var number_slide = elementSettings.slides_to_display 119 var number_slide_scroll = elementSettings.slides_to_scroll 120 var position_icon = elementSettings.position_icons 121 } 122 123 if(device == "tablet") 124 { 125 var number_slide = elementSettings.slides_to_display_tablet 126 var number_slide_scroll = elementSettings.slides_to_scroll_tablet 127 var position_icon = elementSettings.position_icons_tablet 128 } 129 130 if(device == "mobile") 131 { 132 var number_slide = elementSettings.slides_to_display_mobile 133 var number_slide_scroll = elementSettings.slides_to_scroll_mobile 134 var position_icon = elementSettings.position_icons_mobile 135 } 136 137 //console.log(position_icon) 138 if(position_icon == '2') 139 { 140 //console.log('esteirer') 141 var container_parent = $('.elementor-widget-acf_repeater_loop .elementor-widget-container').width() 142 console.log('container parent: '+ container_parent) 143 var width_arrow_container = parseInt($('.container-arrow').width()) + parseInt($('.container-arrow').css('padding-left')) + parseInt($('.container-arrow').css('padding-left')) 144 console.log('width_arrow_container: '+ width_arrow_container) 145 //console.log('size bloc : ' + width_arrow_container) 146 $('.content-wycan-carousel').css('width', container_parent - (width_arrow_container * 2 + 4)) 147 $('.content-wycan-carousel').css('margin','0 auto') 148 console.log('container enfant: '+ container_parent - (width_arrow_container * 2 + 4)) 149 } 150 151 var largeur = $('.content-wycan-carousel').width() 152 var largeur_bloc = parseInt(largeur) / number_slide 153 largeur_bloc_whitoutMargin = largeur_bloc - parseInt($('.diapositive').css('margin-left')) - parseInt($('.diapositive').css('margin-right')) 154 155 $('.diapositive').css('width', largeur_bloc_whitoutMargin) 156 157 if(autoPlay == 'yes') 158 { 159 load_autoPlay(largeur_bloc,number_slide_scroll, auto_play_duration) 160 } 161 162 $('.wy-repeater-previous').click(function() 163 { 164 position_slide = position_slide + parseInt(largeur_bloc) * number_slide_scroll 165 166 if(position_slide <= 0) 167 { 168 $('.content-diapositive').css('transform','translate3d('+position_slide +'px, 0px, 0px)'); 169 $('.content-diapositive').css('transition-duration', '500ms'); 170 } 171 else 172 { 173 position_slide = position_slide - parseInt(largeur_bloc) * number_slide_scroll 174 } 175 check_clone(position_slide) 176 }) 177 178 $('.wy-repeater-next').click(function() 179 { 180 avance(largeur_bloc,number_slide_scroll,auto_play_duration) 181 }) 182 //Fin script 183} 184 185function avance(largeur_bloc,number_slide_scroll,auto_play_duration) 186{ 187 position_slide = position_slide - largeur_bloc * number_slide_scroll 188 $('.content-diapositive').css('transform','translate3d('+position_slide +'px, 0px, 0px)'); 189 $('.content-diapositive').css('transition-duration', '500ms'); 190 check_clone(position_slide) 191} 192 193 194function load_autoPlay(largeur_bloc,number_slide_scroll,auto_play_duration) 195{ 196 avance(largeur_bloc,number_slide_scroll,auto_play_duration) 197 198 setTimeout(() => { 199 load_autoPlay(largeur_bloc,number_slide_scroll,auto_play_duration) 200 }, auto_play_duration * 1000) 201 202} 203 204 205 206function check_clone(position_slide) 207{ 208 var size_carousel = $('.content-wycan-carousel').width() 209 var size_diapo = $('.content-diapositive').width() + position_slide 210 211 //console.log('size carousel : ' + size_carousel) 212 //console.log('size diapo : ' + size_diapo) 213 214 if(size_diapo <= size_carousel) 215 { 216 //console.log('clonage iminent') 217 $('.content-diapositive > div').clone().appendTo('.content-diapositive') 218 } 219} 220 221 222 223})( jQuery, window );
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.