diff --git a/layout/js/custom.js b/layout/js/custom.js index 5caafdb..83d523b 100644 --- a/layout/js/custom.js +++ b/layout/js/custom.js @@ -31,6 +31,14 @@ $(function () { activateProductColors(boxHref) activateProductDrafts(boxHref) activateProductBanner(boxHref) + + if ($(this).attr('colors')) { + $('#product-colors-preview-box').show(); + let colorsArr = $(this).attr('colors').split(' '); + activateProductColorsTabs(colorsArr); + } else { + $('#product-colors-preview-box').hide(); + } }) function activateProductBox(boxHref) { @@ -74,11 +82,29 @@ $(function () { }) } } -}) -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + function activateProductColorsTabs(colors) { + console.log(colors); + + if (colors && typeof colors === 'object') { + $('#nav_tabs_colors li').each(function() { + var href = $(this).find('a').attr('href').substring(1); + if (!colors.includes(href)) { + $(this).hide(); + } else { + $(this).show(); + } + }); + + let firstVisible = $('#nav_tabs_colors li:visible').first(); + if (firstVisible.length > 0) { + firstVisible.find('a').trigger('click'); + } + } + } + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -$(function() { var productColorsList = $("#product-colors-preview-box .scontainer-content") $("#nav_tabs_colors li a").on("click", function (e) { diff --git a/templates_user/promozione-invernale.php b/templates_user/promozione-invernale.php index 2dbf9b1..9fd709d 100644 --- a/templates_user/promozione-invernale.php +++ b/templates_user/promozione-invernale.php @@ -3,7 +3,7 @@
+