1/** 2 * SLIDESHOW SCRIPTS 3 */ 4$(function () { 5 // get slideshow element 6 let $slideshow = $(".mainCarousel"); 7 8 if ($slideshow.length == 0) { 9 return; 10 } 11 12 //get data-fade attribute 13 let fade = $slideshow.data("fade"); 14 let slideshowSettings; 15 16 if (fade != true) { 17 // define settings and intialise slick 18 slideshowSettings = { 19 autoplay: true, 20 autoplaySpeed: 5000, 21 cssEase: "ease-in-out", 22 dots: true, 23 easing: "ease-in-out", 24 speed: 250, 25 }; 26 } else { 27 slideshowSettings = { 28 autoplay: true, 29 autoplaySpeed: 5000, 30 dots: true, 31 infinite: true, 32 speed: 500, 33 fade: true, 34 cssEase: "linear", 35 }; 36 } 37 $slideshow.find(".slides").slick(slideshowSettings); 38 39 // Anything that moves on its own needs a way to stop it (WCAG 2.2.2), and a 40 // slideshow that keeps changing pulls a screen reader's place out from under 41 // it. The pause button shows only while it has keyboard focus 42 // (.rs-slideshow-toggle in the theme's screen-reader styles), so the design 43 // is untouched. Inside .carouselWrapper so it hides with the slideshow on 44 // sites that switch it off on mobile. 45 let paused = false; 46 let $toggle = $('<button type="button" class="rs-slideshow-toggle"></button>'); 47 let toggleLabel = function () { 48 $toggle.text(paused ? "Play slideshow" : "Pause slideshow"); 49 }; 50 toggleLabel(); 51 $toggle.on("click", function () { 52 paused = !paused; 53 $slideshow.find(".slides").slick(paused ? "slickPause" : "slickPlay"); 54 toggleLabel(); 55 }); 56 let $wrapper = $slideshow.find(".carouselWrapper"); 57 ($wrapper.length ? $wrapper : $slideshow).prepend($toggle); 58 59 // function for resizing slideshow to full height (if it has the .fullHeight class) 60 function resizeSlideshow() { 61 if ($slideshow.hasClass("fullHeight")) { 62 let slideshowTopPos = $slideshow.position().top; 63 let newSlideshowHeight = $(window).height() - slideshowTopPos; 64 let $slides = $slideshow.find(".slides .slide"); 65 $slides.css({ 66 height: newSlideshowHeight, 67 "max-height": "none", 68 }); 69 } 70 } 71 72 // fire resize on reload and on window resize 73 resizeSlideshow(); 74 $(window).resize(function () { 75 resizeSlideshow(); 76 }); 77});
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.