33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
(function() {
|
|
function initMainVisualLwd(moduleId) {
|
|
const moduleElement = document.getElementById(moduleId);
|
|
if (!moduleElement) return;
|
|
|
|
const slider = moduleElement.querySelector('.cycle-slideshow');
|
|
if (!slider) return;
|
|
|
|
if (typeof jQuery !== 'undefined' && jQuery.fn.cycle) {
|
|
const $slider = jQuery(slider);
|
|
if ($slider.data('cycle.opts')) {
|
|
$slider.cycle('destroy');
|
|
}
|
|
$slider.cycle();
|
|
} else {
|
|
console.warn("jQuery Cycle2 라이브러리가 로드되지 않았습니다. 메인 비주얼 슬라이더가 작동하지 않습니다.");
|
|
}
|
|
}
|
|
|
|
window.initMainVisualLwd = initMainVisualLwd;
|
|
|
|
// DOMContentLoaded가 이미 발생했을 수 있으므로, 즉시 실행도 고려
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const el = document.querySelector('.main-visual-lwd');
|
|
if(el) initMainVisualLwd(el.id);
|
|
});
|
|
} else {
|
|
const el = document.querySelector('.main-visual-lwd');
|
|
if(el) initMainVisualLwd(el.id);
|
|
}
|
|
})();
|