1( function ( $ ) { 2 'use strict'; 3 4 $( function () { 5 const swiperElements = $( '[data-script="swiper"]' ); 6 7 if ( null !== swiperElements && swiperElements.length > 0 ) { 8 swiperElements.each( ( index, element ) => { 9 let swiper = null; 10 const options = $( element ).data( 'script-args' ); 11 const hasBreakpoints = $( element ).data( 'script-breakpoints' ); 12 13 if ( 1 === hasBreakpoints ) { 14 let currentBreakpoint = null; 15 const breakpoints = Object.keys( options ); 16 const initSwiper = ( element, options ) => { 17 if ( null !== swiper ) { 18 swiper.destroy(); 19 } 20 21 swiper = new Swiper( element, options ); 22 }; 23 24 breakpoints.forEach( breakpoint => { 25 const mediaQuery = window.matchMedia( `(min-width: ${breakpoint}px)` ); 26 27 const handleBreakpoint = event => { 28 if ( event.matches && currentBreakpoint !== breakpoint ) { 29 currentBreakpoint = breakpoint; 30 initSwiper( element, options[ breakpoint ] ); 31 } else if ( false === event.matches && currentBreakpoint === breakpoint ) { 32 const indexOfCurrent = breakpoints.indexOf( breakpoint ); 33 34 if ( 0 === indexOfCurrent ) { 35 currentBreakpoint = breakpoints[ 0 ]; 36 initSwiper( element, options ); 37 } else { 38 const previousBreakpoint = breakpoints[ indexOfCurrent - 1 ]; 39 currentBreakpoint = previousBreakpoint; 40 initSwiper( element, options[ previousBreakpoint ] ); 41 } 42 } else if ( false === event.matches && currentBreakpoint === null ) { 43 currentBreakpoint = breakpoints[ 0 ]; 44 initSwiper( element, options[ breakpoints[ 0 ] ] ); 45 } 46 }; 47 48 mediaQuery.addListener( handleBreakpoint ); 49 handleBreakpoint( mediaQuery ); 50 }); 51 } else { 52 new Swiper( element, options ); 53 } 54 } ); 55 } 56 } ); 57} )( 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.