1(function (Drupal, once) { 2 'use strict'; 3 4 Drupal.behaviors.sliderLight = { 5 onceName: 'sliderLight', 6 sliderSelector: '[data-slider-light]', 7 attach(context) { 8 // Init a simple swiper slider. 9 once(this.onceName, context.querySelectorAll(this.sliderSelector), context).forEach(function (slider) { 10 // Allow per-instance overrides via JSON in data-slider-light attribute. 11 let overrides = {}; 12 const attrValue = slider.getAttribute('data-slider-light'); 13 if (attrValue && attrValue !== 'true') { 14 try { 15 overrides = JSON.parse(attrValue); 16 } catch (e) { 17 // Ignore invalid JSON, use defaults. 18 } 19 } 20 21 const options = { 22 spaceBetween: 24, 23 keyboard: { 24 enabled: true, 25 onlyInViewport: true, 26 }, 27 a11y: { 28 prevSlideMessage: Drupal.t('Previous slide'), 29 nextSlideMessage: Drupal.t('Next slide'), 30 firstSlideMessage: Drupal.t('This is the first slide'), 31 lastSlideMessage: Drupal.t('This is the last slide'), 32 }, 33 navigation: { 34 nextEl: '.swiper-button-next', 35 prevEl: '.swiper-button-prev', 36 }, 37 pagination: { 38 el: '.swiper-pagination', 39 type: 'bullets', 40 }, 41 breakpoints: { 42 320: { 43 slidesPerView: 1.33, 44 spaceBetween: 12 45 }, 46 768: { 47 slidesPerView: 2.33, 48 }, 49 1280: { 50 slidesPerView: 3, 51 }, 52 ...overrides.breakpoints, 53 }, 54 on: { 55 slidesUpdated: (swiper) => {
56 swiper.slides.forEach(slide => { 57 // Those attributes are not suitables here, according RGAA. 58 slide.removeAttribute('role'); 59 slide.removeAttribute('aria-label'); 60 }); 61 }, 62 }, 63 }; 64 // Affect swiper instance to avoid code smell. 65 const swiper = new Swiper(slider, options); 66 }); 67 }, 68 detach: function detach(context, settings, trigger) { 69 if (trigger === "unload") { 70 once.remove(this.onceName, context.querySelectorAll(this.sliderSelector)); 71 } 72 }, 73 }; 74})(Drupal, once);
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.