1 2class TopCarousel { 3 constructor() { 4 this.root = document.querySelector('.js-carousel'); 5 this.indWrap = document.querySelector('.js-carousel__indWrap'); 6 this.ind = document.querySelector('.js-carousel_ind'); 7 this.indItems = this.ind.querySelectorAll('.js-carousel__indItem'); 8 this.currentIndItem = this.ind.firstElementChild.firstElementChild; 9 this.nextIndItem = null; 10 this.btn = document.querySelector('.js-carousel__btn'); 11 this.btnTxt = this.btn.querySelector('.js-carousel__btnTxt'); 12 this.currentItem = this.root.firstElementChild; 13 this.nextItem = null; 14 this.activeClass = 'is-current'; 15 this.stopClass = 'is-stop'; 16 this.stopTxt = '忢ãã'; 17 this.startTxt = 'åçãã'; 18 this.playId; 19 this.tm = 5000; 20 } 21 22 init() { 23 this.setCarousel(); 24 this.bindShow(); 25 this.indClick(); 26 this.setAlly(); 27 28 this.playId = setInterval(this.show.bind(this), this.tm); 29 } 30 31 //Allyè¨ç½® 32 setAlly() { 33 34 } 35 36 //ã«ã«ã¼ã»ã«ã®åæè¨ç½® 37 setCarousel() { 38 this.btnTxt.textContent = this.stopTxt; 39 this.indWrap.style.display = 'block'; 40 } 41 42 43 //次表示ããè¦ç´ ã®åå¾ 44 setNext() { 45 const id = this.currentItem.id; 46 this.indItem = this.ind.querySelector(id); 47 48 if (this.currentItem.nextElementSibling === null) { 49 this.nextItem = this.root.firstElementChild; 50 this.nextIndItem = this.ind.firstElementChild.firstElementChild; 51 52 } else { 53 this.nextItem = this.currentItem.nextElementSibling; 54 this.nextIndItem = this.currentIndItem.parentNode.nextElementSibling.firstElementChild; 55 } 56 } 57 58 //ã¤ã³ã¸ã²ã¼ã¿ã¼ãæ¼ããããæ¼ãããçªå·ã®ã¹ã©ã¤ãã表示ããã 59 indClick(){ 60 for (const indItem of this.indItems) { 61 indItem.addEventListener('click', (e)=> { 62 const id = indItem.getAttribute('data-item'); 63 const item = this.root.querySelector(`#${id}`); 64 65 this.currentIndItem.classList.remove(this.activeClass); 66 this.currentItem.classList.remove(this.activeClass); 67 indItem.classList.add(this.activeClass); 68 item.classList.add(this.activeClass); 69 70 this.currentIndItem = indItem; 71 this.currentItem = item; 72 73 // ã¯ãªãã¯ããã¦ãã5ç§å¾ã«ã¹ã©ã¤ããå¤ãã 74 // ä»ã¾ã§åãã¦ããsetIntervalãæ¢ã㦠75 // æ°ããsetIntervalãè¨ç½® 76 clearInterval(this.playId); 77 this.playId = setInterval(this.show.bind(this), this.tm); 78 79 e.preventDefault() 80 }); 81 } 82 } 83 84 //5ç§å¾ã«æ¬¡ã®ç»åã表示ããã 85 // (5ç§å¾ã«æ½åºãããè¦ç´ ã«ã¯ã©ã¹ãã¤ãã) 86 bindShow() { 87 this.btn.addEventListener('click', () => { 88 // 忢ããã¦ãããåçããã 89 if (this.btn.classList.contains(this.stopClass)) { 90 this.playId = setInterval(this.show.bind(this), this.tm); 91 this.btn.classList.remove(this.stopClass); 92 this.btnTxt.textContent = this.stopTxt; 93 94 // åçããã¦ãããæ¢ãã 95 } else { 96 clearInterval(this.playId); 97 this.btn.classList.add(this.stopClass); 98 this.btnTxt.textContent = this.startTxt; 99 } 100 }) 101 } 102 103 //次ã®ç»åã表示ããã 104 show() { 105 this.setNext(); 106 this.currentItem.classList.remove(this.activeClass); 107 this.currentIndItem.classList.remove(this.activeClass); 108 this.nextItem.classList.add(this.activeClass); 109 this.nextIndItem.classList.add(this.activeClass); 110 this.currentItem = this.nextItem; 111 this.currentIndItem = this.nextIndItem; 112 } 113} 114 115(()=>{ 116 const carousel = document.querySelector('.js-carousel'); 117 118 if (!carousel) { 119 return 120 } 121
122 const top_Carousel = new TopCarousel(carousel); 123 top_Carousel.init(); 124 125})() 126
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.