$(function(){
const owlObj = {
dots: false,
margin: 20,
nav: true,
navText: ['', ''],
responsive: {
0: {
items: 2,
},
576: {
items: 3,
},
768: {
items: 4,
},
1200: {
items: 5,
},
},
}
$('.article-slide').owlCarousel(owlObj)
let asideStep = ''
$(window).on('resize', function(e) {
e.preventDefault()
if($(this).width() >= 1200 && asideStep !== 'desktop') {
asideStep = 'desktop'
$('.article-list').each(function(i, ele) {
if($(ele).data('owl.carousel')) {
$(ele).data('owl.carousel').destroy()
}
})
} else if($(this).width() < 1200 && asideStep !== 'mobile') {
asideStep = 'mobile'
$('.article-list').owlCarousel(owlObj)
}
}).trigger('resize')
})
// ==========================================================
// 列表上方廣告banner輪播
// ==========================================================
;(function($) {
if($('.picSlides-big').length) {
$('.picSlides-big').each(function(i, ele) {
if($(ele).children().length > 1) {
$(ele).owlCarousel({
autoplay: true,
autoplayHoverPause: true,
autoplaySpeed: 1500,
autoplayTimeout: 5000,
dots: false,
items: 1,
loop: true,
margin: 10,
nav: true,
navText: ['', ''],
})
}
})
}
})($)
// ==========================================================
// 手機版次級選單開關
// ==========================================================
;(function($) {
let menuStep = ''
$(window).on('resize', function(e) {
if($(this).width() >= 1200 && menuStep !== 'desktop') {
menuStep = 'desktop'
$(document).off('click', '.with-child > a')
} else if($(this).width() < 1200 && menuStep !== 'mobile') {
menuStep = 'mobile'
$(document).on('click', '.with-child > a', function(e) {
e.preventDefault()
$(this).parent('.with-child').toggleClass('in-active')
.siblings('.with-child').removeClass('in-active')
})
}
}).trigger('resize')
})($)