1(function($, Drupal, once) { 2 'use strict'; 3 4 function _isDesktop() { 5 return $(window).innerWidth() >= 768; 6 } 7 8 Drupal.behaviors.mdRelEveGallerySlider = { 9 attach: function(context, settings) { 10 $(once('md-related-events-slider-processed', '.md-related-events-slider')).each(function() { 11 var totalSlides = $(this).find('.swiper-slide').length; 12 var transitionSpeed = 1000; 13 var initSlide; 14 var isLoop; 15 var slidesPerView; 16 var loopAdditionalSlides; 17 if (_isDesktop()) { 18 //centramos en la 3(2) si es desktop y en la 2(1) si es movil 19 initSlide = (totalSlides > 4) ? 2 : parseInt(totalSlides / 2); 20 isLoop = (totalSlides > 5); 21 loopAdditionalSlides = (isLoop) ? 5 : 0 22 } else { 23 initSlide = (totalSlides > 2) ? 1 : parseInt(totalSlides / 2);; 24 isLoop = (totalSlides > 3); 25 loopAdditionalSlides = (isLoop) ? 3 : 0 26 } 27 var gallerySwiper = new Swiper($(this).find('.swiper-container').first(), { 28 loop: isLoop, 29 loopAdditionalSlides: loopAdditionalSlides, 30 speed: transitionSpeed, 31 centeredSlides: true, 32 centeredSlidesBounds: true, 33 centerInsufficientSlides: true, 34 spaceBetween: 0, 35 effect: 'slide', 36 initialSlide: initSlide, 37 updateOnWindowResize: true, 38 pagination: { 39 el: '.swiper-pagination', 40 type: 'bullets', 41 clickable: true, 42 }, 43 // Default parameters 44 slidesPerView: 1 45 }); 46 47 $(this).find('.swiper-slide').each(function(index) { 48 $(this).click(function() { 49 //si es el seleccionado, vamos a l url, si no, lo ponemos a activo y cancelamos evento 50 var prevIndex = gallerySwiper.activeIndex; 51 gallerySwiper.slideTo(index); 52 gallerySwiper.loopFix(); 53 gallerySwiper.update(); 54 if (prevIndex != index) { 55 return false; 56 } 57 }); 58 }); 59 60 }); 61 } 62 }; 63 64})(jQuery, 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.