1/* 2Check versions for compatibility 3===== 4cd <theme-directory>/assets/libs 5 6Install 7===== 8npm install --save swiper 9 10Make sure the server supports mjs & clear the browser cache (add to .htaccess) 11===== 12<IfModule mod_mime.c> 13 AddType text/javascript mjs 14</IfModule> 15*/ 16 17class libSwiper { 18 static init = (args) => { 19 // console.log(args); 20 21 args.parent.classList.add('lib-swiper--init'); 22 args.parent.classList.remove('lib-swiper--pending'); 23 24 args.element.classList.add('swiper'); 25 args.element.querySelector('.lib-swiper__wrapper').classList.add('swiper-wrapper'); 26 27 args.slides.forEach((slide) => { 28 slide.classList.add('swiper-slide'); 29 }); 30 31 const swiperOptions = args.options; 32 33 if (swiperOptions.pagination) { 34 // console.log('with pagination'); 35 36 if (!swiperOptions.pagination.el) { 37 // console.log('create pagination'); 38 39 swiperOptions.pagination.el = document.createElement('div'); 40 swiperOptions.pagination.el.classList.add('swiper-pagination'); 41 42 if (args.parentPagination) { 43 args.parentPagination.append(swiperOptions.pagination.el); 44 } else { 45 args.parent.append(swiperOptions.pagination.el); 46 } 47 } 48 } 49 50 if (swiperOptions.navigation) { 51 // console.log('with navigation'); 52 53 if (!swiperOptions.navigation.nextEl) { 54 // console.log('create navigation next'); 55 56 swiperOptions.navigation.nextEl = document.createElement('div'); 57 swiperOptions.navigation.nextEl.classList.add('swiper-button-next'); 58 59 if (args.parentNavigation) { 60 args.parentNavigation.append(swiperOptions.navigation.nextEl); 61 } else { 62 args.parent.append(swiperOptions.navigation.nextEl); 63 } 64 } 65 66 if (!swiperOptions.navigation.prevEl) { 67 // console.log('create navigation prev'); 68 69 swiperOptions.navigation.prevEl = document.createElement('div'); 70 swiperOptions.navigation.prevEl.classList.add('swiper-button-prev'); 71 72 if (args.parentNavigation) { 73 args.parentNavigation.append(swiperOptions.navigation.prevEl); 74 } else { 75 args.parent.append(swiperOptions.navigation.prevEl); 76 } 77 } 78 } 79 80 // console.log(swiperOptions); 81 82 return new libSwiperModule(args.element, swiperOptions); 83 }; 84 85 static load = async (args) => { 86 // console.log(args); 87 88 if (!window.libSwiperModule) { 89 /* 90 import(`${w153HlpAssetsFrontendVars.themeURL}assets/libs/node_modules/swiper/swiper-bundle.min.mjs`) 91 .then((module) => { 92 // console.log(module); 93 94 window.libSwiperModule = module.Swiper; 95 96 W153CThUtilities.addStylesheet({ 97 href: `${w153HlpAssetsFrontendVars.themeURL}assets/libs/node_modules/swiper/swiper-bundle.min.css?v=${w153HlpAssetsFrontendVars.themeVersion}`, 98 }, () => { 99 swiperInstance = libSwiper.init(args); 100 }); 101 }) 102 .catch((err) => { 103 // console.log(err.message); 104 }); 105 */ 106 107 const module = await import(`${w153HlpAssetsFrontendVars.themeURL}assets/libs/node_modules/swiper/swiper-bundle.min.mjs`); 108 109 // console.log(module); 110 111 window.libSwiperModule = module.Swiper; 112 113 await new Promise((resolve) => { 114 W153CThUtilities.addStylesheet({ 115 href: `${w153HlpAssetsFrontendVars.themeURL}assets/libs/node_modules/swiper/swiper-bundle.min.css?v=${w153HlpAssetsFrontendVars.themeVersion}`, 116 }, resolve); 117 }); 118 } 119 120 return libSwiper.init(args); 121 }; 122}
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.