1class Carousel { 2 /** 3 * @param {HTMLElement} element l'élément du carousel 4 * @param {Object} options 5 * @param {Object} options.slidesToScroll Nombre d'éléments à faire défiler 6 * @param {Object} options.slidesVisible Nombre d'éléments visible dans le slider 7 */ 8 constructor(element, options = {}) { 9 this.currentItem = 0 10 this.isMobile = false 11 this.isTablet = false 12 this.isTour = false 13 this.translateX = 18 14 this.dx=0 15 this.margin_right_left = 2 16 17 this.element = element 18 this.children = [].slice.call(element.children) 19 20 this.options = Object.assign({}, { 21 slidesToScroll: 1, 22 slidesVisible: 1 23 }, options) 24 25 this.onWindowResize(); 26 this.setStyle() 27 this.createNavigation(); 28 window.addEventListener("resize", this.onWindowResize.bind(this)) 29 } 30 setStyle() { 31 var ratio = this.children.length / this.options.slidesVisible,containerWidth,itemWidth 32 33 if (!this.isMobile) { 34 containerWidth = (ratio * 100 + (2 * this.margin_right_left * this.options.slidesVisible) + this.dx) + "%"; 35 itemWidth = (100 / this.options.slidesVisible / ratio) - (2 * this.margin_right_left) + "%" 36 } else { 37 containerWidth = (ratio * 100)+ "%"; 38 itemWidth = (100 / this.options.slidesVisible / ratio) + "%" 39 } 40 41 this.element.style.width = containerWidth 42 this.children.forEach((child) => { 43 child.style.width = itemWidth; 44 if (!this.isMobile) child.style.margin = "0 0 " + this.margin_right_left + "% " + this.margin_right_left + "%" 45 }) 46 } 47 onWindowResize() { 48 const infWidth = 600 49 const supWidth = 1200 50 var mobile = window.innerWidth < infWidth 51 var tablet = window.innerWidth >= infWidth && window.innerWidth < supWidth 52 var tour = window.innerWidth >= supWidth 53 //console.log(mobile + 'x' + tablet + 'x' + tour) 54 if (mobile != this.isMobile && window.innerWidth < infWidth) { 55 this.isMobile = true; this.isTablet = false; this.isTour = false 56 this.options.slidesVisible = 1;this.dx=0 57 this.setStyle() 58 } else if (tablet != this.isTablet && window.innerWidth >= infWidth && window.innerWidth < supWidth) { 59 this.isTablet = true; this.isMobile = false; this.isTour = false 60 this.options.slidesVisible = 2;this.dx=6 61 this.setStyle() 62 } else if (tour != this.isTour && window.innerWidth >= supWidth) { 63 this.isTablet = false; this.isMobile = false; this.isTour = true 64 this.options.slidesVisible = 2;this.dx=6 65 this.setStyle() 66 } 67 } 68 createNavigation() { 69 this.prevButton = document.querySelector('#efbl-button__prev') 70 this.nextButton = document.querySelector('#efbl-button__next') 71 this.nextButton.addEventListener('click', this.next.bind(this)) 72 this.prevButton.addEventListener('click', this.prev.bind(this)) 73 this.prevButton.style.opacity = "0" 74 this.prevButton.style.cursor = "not-allowed" 75 this.isNoClickPrev = true 76 this.isNoClickNext = false 77 } 78 next() { 79 if (!this.isNoClickNext) this.gotoItem(this.currentItem + this.options.slidesToScroll, true) 80 } 81 prev() { 82 if (!this.isNoClickPrev) this.gotoItem(this.currentItem - this.options.slidesToScroll, false) 83 } 84 /** 85 * @param {number} index l'item actuel +- le scroll 86 * @param {boolean} next pour savoir si c'est next() ou prev() 87 */ 88 gotoItem(index, next) { 89 if (index < 0) index = this.children.length - this.options.slidesVisible 90 if (next && (index >= this.children.length || this.children[this.currentItem + this.options.slidesVisible] == undefined)) index = 0 91 92 this.affArrow(index) 93 var translateX 94 if (!this.isMobile) translateX = -(index * this.translateX) 95 else translateX = index * -100/this.children.length 96 this.element.style.transform = "translate3D(" + translateX + "%,0,0)" 97 this.currentItem = index 98 } 99 /** 100 * @param {number} index l'item actuel +- le scroll 101 */ 102 affArrow(index) { 103 if (index == (this.children.length - this.options.slidesVisible)) this.affArrowInd("next", "0", "not-allowed", true) 104 else this.affArrowInd("next", "1", "pointer", false) 105 106 if (index == 0) this.affArrowInd("prev", "0", "not-allowed", true) 107 else this.affArrowInd("prev", "1", "pointer", false) 108 } 109 /** 110 * @param {string} button next ou prev 111 * @param {string} opacity opacité du bouton prev ou next 112 * @param {string} cursor type du curseur 113 * @param {boolean} click possibilité de cliquer sur le bouton prev ou next 114 */ 115 affArrowInd(button, opacity, cursor, click) { 116 if (button == "prev") { 117 this.prevButton.style.opacity = opacity
118 this.prevButton.style.cursor = cursor 119 this.isNoClickPrev = click 120 } else { 121 this.nextButton.style.opacity = opacity 122 this.nextButton.style.cursor = cursor 123 this.isNoClickNext = click 124 } 125 } 126 /** 127 * @param {string} className le nom de la classe du tag 128 * @param {string} elmt le type du tag 129 * @returns [el] le tag créé 130 */ 131 createElWithClass(className, elmt) { 132 let el = document.createElement(elmt) 133 el.setAttribute('class', className) 134 return el 135 } 136} 137(function ($) { 138 $(document).ready(function () { 139 if(document.querySelector('.efbl_feeds_holder')!==null && document.querySelector('.efbl_feeds_holder')!==undefined) { 140 var bdsrc19_trans1 = ["heures", "heure", "jours", "jour", "mois", "mois", "semaines", "semaine", "", "minutes", "minute", "secondes", "seconde"]; 141 var bdsrc19_trans2 = ["hours", "hour", "days", "day", "months", "month", "weeks", "week", "ago", "minutes", "minute", "seconds", "second"]; 142 143 $(".efbl_feed_wraper").before("<div id='efbl-button__prev'><img src='https://serilhac.fr/wp-content/themes/astrachild-astra-child/img/arrow-left.png'/></div") 144 $(".efbl_feed_wraper").after("<div id='efbl-button__next'><img src='https://serilhac.fr/wp-content/themes/astrachild-astra-child/img/arrow-right.png'/></div") 145 146 var bdsrc19_carousel = new Carousel(document.querySelector('.efbl_feeds_holder'), { 147 slidesToScroll: 1, 148 slidesVisible: 3 149 }) 150 //evenements 151 152 bdsrc19_modifPlugin();//on modifie l'affichage du plugin 153 154 function bdsrc19_modifPlugin() { 155 //on modifie les textes 156 $(".efbl-view-on-fb").each(function () { 157 $(this).text("voir sur facebook"); 158 }); 159 $(".esf-share-wrapper>a").each(function () { 160 $(this).text("partager"); 161 }); 162 $(".efbl-profile-title>span").each(function () { 163 chaine = bdsrc19_translate($(this).text()); 164 $(this).text(chaine); 165 }); 166 } 167 /** 168 * @param {string} timeRecup récupère la durée écoulée depuis la création de l'article 169 * @returns [chaine] traduction de cette durée 170 */ 171 function bdsrc19_translate(timeRecup) { 172 timeR = timeRecup.split(' '); chaine = "Publié il y a"; 173 timeR.forEach(el => { 174 ind = bdsrc19_trans2.indexOf(el); 175 if (ind != -1) { 176 chaine = chaine + bdsrc19_trans1[ind] + " et"; 177 } else chaine = chaine + " " + el + " "; 178 }); 179 chaine = chaine.substring(0, chaine.length - 6); 180 //console.log(chaine); 181 return chaine; 182 } 183 } 184 }); 185})(jQuery);
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.