1/** 2 * Functions for the cards carousel components. 3 */ 4 5function initCardsCarouselSlider (element) { 6 let controlsContainer = element.next(); 7 8 element.slick({ 9 'arrows': true, 10 'dots': true, 11 'appendDots': controlsContainer.find('.slick-pagination-dots'), 12 'prevArrow': controlsContainer.find('.slick-prev-arrow'), 13 'nextArrow': controlsContainer.find('.slick-next-arrow'), 14 'infinite': false, 15 'autoplay': false, 16 'slidesToShow': 3, 17 'slidesToScroll': 3, 18 'speed': 300, 19 'arrowsPlacement': 'afterSlides', 20 'responsive': [ 21 { 22 'breakpoint': 769, 23 'settings': { 24 'slidesToShow': 2, 25 'slidesToScroll': 2 26 } 27 }, 28 { 29 'breakpoint': 491, 30 'settings': { 31 'slidesToShow': 1, 32 'slidesToScroll': 1 33 } 34 } 35 ] 36 }); 37} 38 39// Helpers 40function cardsCarouselAfterInitHelpers (element) { 41 const paginationContainer = element.next(); 42 43 if (paginationContainer.attr('class') === 'slider-controls') { 44 if (paginationContainer.find('.slick-dots').length == 0) { 45 // Don't display pagination element when there are no other pages. 46 paginationContainer.css('display', 'none'); 47 } 48 } 49 50 console.log('i loaded the cards carousel after init helpers'); 51} 52 53function cardsCarouselAccessibilityHelpers (element, slickArgs, idString) { 54 const elementId = idString.toLowerCase() + '-carousel-' + (new Date()).getTime(); 55 56 element.attr('aria-label', idString + ' Carousel Section'); 57 element.find('.slick-list').attr('id', elementId); 58 59 console.log('i loaded the cards carousel accessibility helpers'); 60} 61 62jQuery(document) 63 .ready(function () { 64 initSlickCarousel(); 65 }); 66 67// Determines where to place arrows. 68function calculateArrowPos (elementLoaded) { 69 let prevArrow = elementLoaded.querySelector('.slick-prev'); 70 let nextArrow = elementLoaded.querySelector('.slick-next'); 71 let carouselImages = elementLoaded.querySelectorAll('.slick-carousel-item .at-constructor-image'); 72 73 // Sit the arrows on the CTA button's centre line, falling back to the title 74 // when a slide has no button. This used to be image height plus a hand-tuned 75 // offset per breakpoint, which drifted out of alignment whenever anything in 76 // the caption changed height. Slick's own transform is translate(0, -50%), 77 // so the value written to `top` is the centre line. 78 let anchor = elementLoaded.querySelector('.slick-slide.slick-current .slick-carousel-item .carousel-content-wrapper .carousel-cta') 79 || elementLoaded.querySelector('.slick-slide.slick-current .slick-carousel-item .carousel-content-wrapper .carousel-title'); 80 81 if (!carouselImages.length || !anchor || !prevArrow || !nextArrow) { 82 return; 83 } 84 85 let anchorRect = anchor.getBoundingClientRect(); 86 let newArrowPos = ( 87 anchorRect.top + anchorRect.bottom 88 ) / 2 - elementLoaded.getBoundingClientRect().top; 89 90 prevArrow.style.top = newArrowPos + 'px'; 91 nextArrow.style.top = newArrowPos + 'px'; 92} 93 94// Carousel documentation: https://accessible360.github.io/accessible-slick/ 95function initSlickCarousel () { 96 const carouselElementString = '.at-slick-carousel'; 97 98 jQuery(carouselElementString) 99 .on('init', function (slickElement) { 100 const elementLoaded = slickElement.target; 101 const carouselId = 'at-slick-carousel-' + ( 102 new Date() 103 ).getTime(); 104 105 jQuery(elementLoaded).attr('aria-label', 'Carousel Section'); 106 jQuery(elementLoaded).find('.slick-list').attr('id', carouselId); 107 108 calculateArrowPos(elementLoaded); 109 }); 110 111 jQuery(carouselElementString) 112 .slick({ 113 'arrows': true, 114 'centerMode': true, 115 'centerPadding': '23.5vw', 116 'infiniteMode': true, 117 'autoplay': false, 118 'responsive': [ 119 { 120 'breakpoint': 1200, 121 'settings': { 122 'centerPadding': '21.375vw', 123 }, 124 }, 125 { 126 'breakpoint': 880, 127 'settings': { 128 'centerPadding': '14.625vw', 129 }, 130 }, 131 { 132 'breakpoint': 491, 133 'settings': { 134 'centerPadding': '11.125vw', 135 }, 136 }, 137 ], 138 }); 139}
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.