Сейчас узнаем, какой подарок выпадет именно Вам
Крутите колесо
Как в блок CL47 вставить галерею до/после в Тильда
Literature course for people who can't live without books
You will study English Literature, an introduction to key aspects central to the study of English Literature. You will also choose an optional course from another subject area.

Как в блок CL47 вставить галерею до/после в Тильда

1
Создали блок CL47 и задали ему класс uc-cl47-content
Добавили в него 3 вкладки и картинки в каждую
2
Создали блоки GL09 и задали им классы
uc-gl09_1 , uc-gl09_2 , uc-gl09_3
3
Вставили код на страницу в блок Т123
Библиотека для примера
<script>
(function() {
    const cl47gl09Arr = [
        {
            "cl47": "uc-cl47-content",
            "tab": "1",
            "gl09": "uc-gl09_1"
        },
        {
            "cl47": "uc-cl47-content",
            "tab": "2",
            "gl09": "uc-gl09_2"
        },
        
        {
            "cl47": "uc-cl47-content",
            "tab": "3",
            "gl09": "uc-gl09_3"
        },
    ];

    function triggerWindowResize() {
        if (typeof window.Event === 'function') {
            window.dispatchEvent(new Event('resize'));
        } else {
            const resizeEvent = document.createEvent('Event');
            resizeEvent.initEvent('resize', true, true);
            window.dispatchEvent(resizeEvent);
        }
    }

    function observeTabPanel(tabPanel, item) {
        const observer = new MutationObserver((mutations) => {
            mutations.forEach((mutation) => {
            
                if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
                    if (tabPanel.classList.contains('t817__content_active')) {
                        const recordElement = tabPanel.querySelector('[data-record-type="410"]');
                        if (recordElement) {
                            triggerWindowResize();
                        }
                    }
                }
            });
        });

        observer.observe(tabPanel, {
            attributes: true,
            attributeFilter: ['class']
        });

        if (!window._tabObservers) {
            window._tabObservers = [];
        }
        window._tabObservers.push(observer);
    }
    function processTabs() {
        cl47gl09Arr.forEach(item => {
            const mainBlock = document.querySelector(`.${item.cl47}`);
            
            if (mainBlock) {
                const tabPanel = mainBlock.querySelector(`div[role="tabpanel"][data-tab-content-number="${item.tab}"]`);
                
                if (tabPanel) {
                    observeTabPanel(tabPanel, item);
                    
                    const tImgElement = tabPanel.querySelector('.t-img');
                    
                    if (tImgElement) {
                        const newBlock = document.querySelector(`.${item.gl09}`);
                        
                        if (newBlock) {
                            tImgElement.parentNode.replaceChild(newBlock, tImgElement);
                        } else {
                            console.warn(`Блок с классом .${item.gl09} не найден`);
                        }
                    } else {
                        console.log(`Элемент .t-img не найден во вкладке ${item.tab}, пропускаем замену`);
                    }
                } else {
                    console.warn(`Вкладка с data-tab-content-number="${item.tab}" не найдена в блоке .${item.cl47}`);
                }
            } else {
                console.warn(`Блок с классом .${item.cl47} не найден`);
            }
        });
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', processTabs);
    } else {
        processTabs();
    }
})();
</script>


<style>

.t817 .t410__col.t-col {
    padding-left: 0;
    margin: 0;
    max-width: none;
}

.t817 .t-beforeafter__image img {
    width: auto;
}    

.t817__content-col.t817__content-col_1 {
    width: 100%;
}

@media screen and (max-width: 960px) {
    .t817 .t410__col.t-col {      
        padding-right: 0px;      
    }
}

</style>
Made on
Tilda