1function initProductImagesCarousel() { 2 $('.__product-images-carousel').slick({ 3 dots: false, 4 infinite: true, 5 speed: 300, 6 slidesToShow: 1, 7 customPaging: () => { 8 return ''; 9 }, 10 prevArrow: '<button type="button" class="slick-prev"></button>', 11 nextArrow: '<button type="button" class="slick-next"></button>', 12 }); 13} 14 15$(document).ready(function () { 16 /** Megamenu */ 17 function responsiveMegaMenu() { 18 const megaMenu = $('.ets_mm_megamenu'); 19 20 // get width of the window 21 const windowWidth = $(window).width(); 22 if (windowWidth <= 999) { 23 megaMenu.addClass('changestatus'); 24 } 25 26 if (windowWidth > 999) { 27 megaMenu.removeClass('changestatus'); 28 $('body').removeClass('noscroll'); 29 } 30 } 31 32 // Permet de gérer les comportements étranges du menu 33 responsiveMegaMenu(); 34 35 $(window).resize(function () { 36 responsiveMegaMenu(); 37 }); 38 39 function initializeHeader(scrollTop) { 40 const header = $('#header'); 41 42 if (scrollTop > 40) { 43 const height = header.height(); 44 header.addClass('__sticky_enabled'); 45 header.css('min-height', height); 46 } else { 47 header.removeClass('__sticky_enabled'); 48 header.css('min-height', ''); 49 } 50 } 51 52 const body = $('body'); 53 if (!body.hasClass('page-product')) { 54 initializeHeader($(window).scrollTop()); 55 56 $(window).scroll(function () { 57 initializeHeader($(this).scrollTop()); 58 }); 59 } 60 61 $('.open-megamenu-button').click(function () { 62 $('.ybc-menu-toggle').click(); 63 }); 64 65 $('.close-megamenu-button').click(() => { 66 $('body').removeClass('noscroll'); 67 68 $('.ets_mm_megamenu_content_content .ybc-menu-toggle').removeClass('opened'); 69 $('.ets_mm_megamenu_content_content .ybc-menu-toggle').addClass('closed'); 70 $('.ets_mm_megamenu_content_content .mm_menus_ul').stop(true, true).removeClass('active'); 71 }); 72 73 $('body').on('click', '.add-to-wishlist', function () { 74 $('.product-add-to-cart .wishlist-button-add').click() 75 }); 76 77 $('body.page-category, body.page-module-pm_advancedsearch4-searchresults').on('click', '.PM_ASBlockOutput > .card > .card-header', (e) => { 78 const button = $(e.target); 79 const card = button.closest('.card'); 80 card.toggleClass('open'); 81 }); 82 83 $('body.page-product').on('click', '.tabs .nav-link', function () { 84 const accordions = $(".page-product .accordionjs .acc_active"); 85 accordions.each(function () { 86 $(this).removeClass('acc_active'); 87 88 $(this).find('.acc_content').css('display', 'none'); 89 }); 90 }); 91 92 function initProductThumbnailSlider() { 93 $('.thumbnail-top.slick').slick({ 94 dots: false, 95 infinite: true, 96 speed: 300, 97 slidesToShow: 1, 98 customPaging: () => { 99 return ''; 100 }, 101 prevArrow: '<button type="button" class="slick-prev"></button>', 102 nextArrow: '<button type="button" class="slick-next"></button>', 103 }); 104 } 105 106 function initProductImagesSlider() { 107 if (window.innerWidth >= 992) 108 return; 109 110 initProductImagesCarousel(); 111 112 $('.page-product .product-images.slick').slick({ 113 dots: false, 114 infinite: true, 115 speed: 300, 116 slidesToShow: 1, 117 customPaging: () => { 118 return ''; 119 }, 120 prevArrow: '<button type="button" class="slick-prev"></button>', 121 nextArrow: '<button type="button" class="slick-next"></button>', 122 }); 123 } 124 125 jQuery(document).ready(function ($) { 126 const accordions = $(".page-product .accordionjs"); 127 accordions.each(function () { 128 $(this).accordionjs(); 129 }); 130 131 initProductThumbnailSlider(); 132 initProductImagesSlider(); 133 134 // register on resize event 135 // $(window).resize(function() { 136 // initProductImagesSlider(); 137 // }); 138 139 $('.__slick-slider').slick({ 140 dots: true, 141 infinite: true, 142 speed: 300, 143 autoplay: true, 144 prevArrow: '<button type="button" class="slick-prev"></button>', 145 nextArrow: '<button type="button" class="slick-next"></button>', 146 slidesToShow: 4, 147 customPaging: () => { 148 return ''; 149 }, 150 responsive: [ 151 { 152 breakpoint: 1024, 153 settings: { 154 slidesToShow: 2, 155 slidesToScroll: 2, 156 infinite: true, 157 dots: true 158 } 159 }, 160 // { 161 // breakpoint: 600, 162 // settings: { 163 // slidesToShow: 2, 164 // slidesToScroll: 2 165 // } 166 // }, 167 { 168 breakpoint: 480, 169 settings: { 170 slidesToShow: 1, 171 slidesToScroll: 1 172 } 173 } 174 ] 175 }); 176 }); 177 178 function handleCartHover() { 179 const cart = $('#_desktop_cart .blockcart'); 180 const cartDropdown = $('#_desktop_cart .blockcart .dropdown'); 181 const cartDropdownMenu = $('#_desktop_cart .blockcart .dropdown-menu'); 182 183 $(cartDropdown, cartDropdownMenu).hover(function () { 184 cartDropdown.addClass('open'); 185 }, function () { 186 cartDropdown.removeClass('open'); 187 }); 188 } 189 190 handleCartHover(); 191 window.handleCartHover = handleCartHover; 192 193 // Observe .page-category .js-product-list-header when HTML changes 194 const observer = new MutationObserver(function (mutationsList, observer) { 195 for (const mutation of mutationsList) { 196 if (mutation.type === 'childList') {
197 initProductThumbnailSlider(); 198 } 199 } 200 }); 201 202 var config = {childList: true, subtree: true}; 203 const target = $('.page-category #products')[0]; 204 205 if (target) 206 observer.observe(target, config); 207}); 208 209 210/** 211 * Fichier : themes/votre_theme/assets/js/custom.js 212 * Correction du scroll après mise à jour de la liste de produits (Filtres/Pagination). 213 */ 214$(document).ready(function() { 215 // Vérifie si l'objet PrestaShop est défini 216 if (typeof prestashop !== 'undefined') { 217 218 // 1. Ãcouteur d'événement pour la mise à jour de la liste de produits (Filtres et Pagination AJAX) 219 prestashop.on('updateProductList', function() { 220 // Utilise jQuery pour forcer le défilement au sommet de la page de la manière la plus compatible (même sur Firefox). 221 // Durée de 0ms pour un saut instantané. 222 $('html, body').animate({ 223 scrollTop: 0 224 }, 0); 225 }); 226 227 // 2. Ãcouteur de Clic Direct sur les liens de Pagination/Filtres (en cas de problème de timing AJAX) 228 // Ceci est une couche de sécurité si l'événement 'updateProductList' a un timing instable. 229 $(document).on('click', '.js-search-link', function() { 230 // Utilise un petit délai (timeout) pour s'assurer que l'animation jQuery s'exécute APRÃS 231 // que le code de base de PrestaShop ait fait son travail. 232 setTimeout(function() { 233 $('html, body').animate({ 234 scrollTop: 0 235 }, 0); 236 }, 10); // 10ms suffisent souvent à résoudre les problèmes de timing dans ce contexte. 237 }); 238 239 } 240}); 241 242(function () { 243 244 if (window.__historyPatched) { 245 return; 246 } 247 window.__historyPatched = true; 248 249 var originalPushState = window.history.pushState; 250 251 window.history.pushState = function (state, title, url) { 252 try { 253 254 if (state && typeof state === 'object' && state.id_product_attribute) { 255 // On remplace lâétat courant au lieu dâempiler 256 return window.history.replaceState(state, title, url); 257 } 258 return originalPushState.apply(window.history, arguments); 259 } catch (e) { 260 return originalPushState.apply(window.history, arguments); 261 } 262 }; 263})(); 264 265 266/** 267 * Montagut â Resynchronise les sélecteurs langue/devise du mega menu (visibles sur mobile) 268 * sur ceux du header, rendus à chaque requête et donc toujours justes. 269 * Correctif d'attente tant que le fragment mis en cache par le menu n'est pas corrigé. 270 */ 271(function () { 272 'use strict'; 273 274 var DEFINITIONS = [ 275 { 276 css: '.language-selector', 277 key: function (el) { return el.getAttribute('data-iso-code'); } 278 }, 279 { 280 css: '.currency-selector', 281 key: function (el, url) { 282 var match = /[?&]id_currency=(\d+)/.exec(url); 283 return match ? match[1] : null; 284 } 285 } 286 ]; 287 288 function readUrl(el) { 289 return el.tagName === 'OPTION' ? el.value : el.getAttribute('href'); 290 } 291 292 function writeUrl(el, url) { 293 if (el.tagName === 'OPTION') { 294 el.value = url; 295 } else { 296 el.setAttribute('href', url); 297 } 298 } 299 300 function findSource(css) { 301 return Array.prototype.find.call(document.querySelectorAll(css), function (el) { 302 return !el.closest('.top_megamenu'); 303 }) || null; 304 } 305 306 function sync() { 307 DEFINITIONS.forEach(function (def) { 308 var source = findSource(def.css); 309 if (!source) { 310 return; 311 } 312 313 var urls = {}; 314 source.querySelectorAll('a.dropdown-item, option').forEach(function (el) { 315 var url = readUrl(el); 316 var key = url ? def.key(el, url) : null; 317 if (key) { 318 urls[key] = url; 319 } 320 }); 321 322 document.querySelectorAll('.top_megamenu ' + def.css + ' a.dropdown-item, .top_megamenu ' + def.css + ' option') 323 .forEach(function (el) { 324 var url = readUrl(el); 325 var key = url ? def.key(el, url) : null; 326 if (key && urls[key] && urls[key] !== url) { 327 writeUrl(el, urls[key]); 328 } 329 }); 330 }); 331 } 332 333 if (document.readyState === 'loading') { 334 document.addEventListener('DOMContentLoaded', sync); 335 } else { 336 sync(); 337 } 338})();
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.