1 2(function ($) { 3 Drupal.behaviors.cmbv_slider_produits = { 4 initOk: false, 5 6 attach: function (context, settings) { 7 Drupal.behaviors.cmbv_slider_produits.positionRubanOnImgReady(); 8 9 // eviter le rappel via AJAX 10 if (Drupal.behaviors.cmbv_slider_produits.initOk) return; 11 Drupal.behaviors.cmbv_slider_produits.initOk = true; 12 13 Drupal.behaviors.cmbv_slider_produits.sliderCMBVproduits(); 14 15 $(window).on('resize', function () { 16 Drupal.behaviors.cmbv_slider_produits.positionRubanOnImgReady(); 17 }); 18 19 $(document).ajaxComplete(function () { 20 Drupal.behaviors.cmbv_slider_produits.positionRubanOnImgReady(); 21 }); 22 }, 23 24 25 /*--------------------------------------------------------------------- 26 :: SliderProduits 27 -------------------------------------------------------------------*/ 28 sliderCMBVproduits: function () { 29 var sliderProduits = $('.cmbv-slider-produits'); 30 if (!sliderProduits.length) return; 31 32 33 $('.cmbv-slider-produits').each(function () { 34 35 var qteItem = $(this).find('.produit-mosaique-item').length; 36 var wrapAround = true; 37 if (qteItem < 5) { 38 wrapAround = false; 39 } 40 41 $(this).on('ready.flickity', function (e) { 42 $(e.target).closest('.slider-container').addClass('is-visible'); 43 }); 44 45 $(this).flickity({ 46 autoPlay: true, 47 contain: true, 48 cellAlign: 'left', 49 imagesLoaded: true, 50 dragThreshold: 50, 51 wrapAround: wrapAround 52 53 // prevNextButtons: false, 54 }); 55 }); 56 57 58 Drupal.behaviors.ssks_sliders.checkIfSliderIsWiderThanContainer('.cmbv-slider-produits'); 59 60 }, 61 62 63 /*--------------------------------------------------------------------- 64 :: positionRuban 65 -------------------------------------------------------------------*/ 66 positionRuban: function (img) { 67 var top = Math.floor(img.position().top); 68 var left = Math.floor(img.position().left); 69 var ruban = img.closest('figure').find('.produit-ruban'); 70 ruban.css({ 71 top: top + "px", 72 left: left + "px", 73 }); 74 ruban.addClass('is-visible'); 75 }, 76 77 positionRubanOnImgReady: function () { 78 $('.produit-mosaique-item img').each(function (e) { 79 $(this).once('produit-mosaique-img', function () { 80 Drupal.behaviors.cmbv_slider_produits.positionRuban($(this)); 81 $(this)[0].addEventListener('lazyloaded', function (e) { 82 Drupal.behaviors.cmbv_slider_produits.positionRuban($(this)); 83 }); 84 }) 85 86 }); 87 }, 88 } 89})(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.