// ==========================================================
// 右側懸浮小廣告開關
// ==========================================================
;(function($) {
function bellCheck(step) {
if(step % 2) {
$('#idx-ad-right').removeClass('theme-close')
$(document).on("click.bellCheck", function(e){
let target = $(e.target)
if(!$("#idx-ad-right").hasClass("theme-close") && target.closest("#idx-ad-right").length <= 0){
nowBellStep = (nowBellStep + 1) % 2
bellCheck(nowBellStep)
}
})
} else {
$('#idx-ad-right').addClass('theme-close')
$(document).off("click.bellCheck")
}
}
let nowBellStep = $('#idx-ad-right').data('step')
bellCheck(nowBellStep)
$('#idx-ad-right').on('click', '.toggle-button', function(e) {
e.preventDefault()
nowBellStep = (nowBellStep + 1) % 2
bellCheck(nowBellStep)
})
})($)
// ==========================================================
// 蓋版廣告功能
// ==========================================================
;(function($) {
if($('.popupAdbox').length) {
$('body').addClass('overflow-hidden')
}
})($)
// ==========================================================
// cookie彈窗
// ==========================================================
;(function($) {
let coockiePopup = $(".cookie-popup")
if(coockiePopup.length > 0){
coockiePopup.on("click", ".cookie-check-btn", function(){
$.ajax({
url: "/ajax/ajax_cookie_check.php",
type:"POST",
dataType:"JSON",
success: function(res){
if(res.message){
alert(res.message)
}
coockiePopup.remove()
},
error: function(){
alert(_jsLang.資料庫忙線中);
}
})
})
}
})($)
// ==========================================================
// 天邊廣告功能
// ==========================================================
;(function($) {
if($('.top-adbox').length) {
const wrapper = $('.top-adbox')
wrapper.on('click', '.top-adbox-button', function(e) {
wrapper.toggleClass('in-hidden').attr('tag-status', '2')
})
if(wrapper.attr('tag-status') !== '1') {
wrapper.addClass('in-hidden')
} else {
wrapper.removeClass('in-hidden')
}
}
})($)
// ==========================================================
// 紅眼廣告功能
// ==========================================================
;(function($) {
const slideTarget = $('#slideshow')
if(slideTarget.length && slideTarget.children().length > 1) {
slideTarget.owlCarousel({
items: 1,
dots: true,
margin: 10,
loop: true,
autoplay: true,
autoplayTimeout: 8000,
autoplaySpeed: 1000,
animateOut: 'fadeOut',
animateIn: 'fadeIn',
nav: true,
navText: ['', ''],
responsive: {
0: {
autoplayHoverPause: false,
},
1200: {
autoplayHoverPause: true,
},
},
})
}
})($)
// ==========================================================
// 滿版輪播廣告功能
// ==========================================================
;(function($) {
const slideTarget = $('.slideshow-block .slideshow-list')
if(slideTarget.length && slideTarget.children().length > 1) {
slideTarget.owlCarousel({
items: 1,
dots: true,
margin: 10,
loop: true,
autoplay: true,
autoplayTimeout: 8000,
autoplaySpeed: 1000,
animateOut: 'fadeOut',
animateIn: 'fadeIn',
nav: true,
navText: ['', ''],
responsive: {
0: {
autoplayHoverPause: false,
},
1200: {
autoplayHoverPause: true,
},
},
})
}
})($)
// ==========================================================
// 推薦主題商品切換
// ==========================================================
;(function($) {
const recomWrap = $('.index-recommend')
if(recomWrap.length) {
recomWrap.on('click', '.tag-item', function(e) {
const switchTarget = $(this).data('target')
$(this).addClass('in-active')
.siblings('.tag-item').removeClass('in-active')
$('.content-item[data-id='+ switchTarget + ']').addClass('in-active')
.siblings('.content-item').removeClass('in-active')
$('.banner-item[data-id='+ switchTarget + ']').addClass('in-active')
.siblings('.banner-item').removeClass('in-active')
})
}
})($)
// ==========================================================
// 商品櫥窗快速購物區塊
// ==========================================================
// ;(function($) {
// if($('.showcase').length) {
// let showcaseStep = true
// $('body').on('mouseenter', '.showcase .HoverShopcart', function(e) {
// e.preventDefault()
// const appendTarget = $(this).parents('.item')
// if(showcaseStep) {
// showcaseStep = false
// jQuery.ajax({
// url: Project_Country+'ajax/ajax_showcase_shopbox.php',
// type: 'POST',
// dataType: 'HTML',
// cache: false,
// async: true,
// data: {
// sid: $(this).attr('sid'),
// },
// })
// .done(function(res) {
// appendTarget.append(res)
// })
// .fail(function(x, y, z) {
// console.log(x);
// })
// .always(function() {
// showcaseStep = true
// });
// }
// }).on('mouseleave', '.showcase .item', function(e) {
// e.preventDefault()
// $(this).find('.hover-cart').remove()
// })
// }
// })($)
// ==========================================================
// 影音購物輪播
// ==========================================================
;(function($) {
const videoSlide = $('.video-area .wrapper')
if(videoSlide.children('.item').length > 1) {
function navFixed(){
let offset = videoSlide.height() - videoSlide.find(".owl-item.active img").eq(0).height()
videoSlide.find(".owl-prev, .owl-next").css({
"top": -offset
})
}
videoSlide.owlCarousel({
nav: true,
loop: true,
margin: 20,
dots: false,
items: 1,
animateIn: 'fadeIn',
animateOut: 'fadeOut',
navText: ['', ''],
onInitialized: navFixed,
onResized: navFixed,
responsive: {
0: {
nav: false,
dots: true,
},
1200: {
nav: true,
dots: false,
}
}
})
}
})($)
// ==========================================================
// 試用評價輪播
// ==========================================================
;(function($) {
const reviewSlide = $('.review-list')
if(reviewSlide.children('.review-group').length > 1) {
reviewSlide.owlCarousel({
loop: false,
margin: 20,
items: 1,
animateIn: 'fadeIn',
animateOut: 'fadeOut',
navText: ['', ''],
responsive: {
0: {
nav: false,
dots: true,
},
1200: {
nav: true,
dots: false,
}
}
})
}
})($)
// ==========================================================
// 櫥窗11
// ==========================================================
;(function($) {
const showcaseSlide = $('.showcase-list')
if(showcaseSlide.children('.list-item').length > 0) {
showcaseSlide.owlCarousel({
loop: true,
dots: false,
navText: ['', ''],
responsive:{
0: {
margin: 10,
items: 1,
nav: false,
},
575: {
margin: 10,
items: 2,
nav: false,
},
768: {
margin: 12,
items: 2,
nav: false,
},
1200: {
margin: 20,
items: 2,
nav: true,
},
},
})
}
})($)
// ==========================================================
// 商品櫥窗、加入購物車彈窗
// ==========================================================
;(function($) {
//商品內容
var file_Obj = new prod_file({
type :'1',
itemBox:'product-detail',
});
file_Obj.init();
})($)
// ==========================================================
// 今日限定區塊腳本
// ==========================================================
;(function($) {
const todaySale = $('.today-sale')
todaySale.find('.timerbox').each(function(i, ele) {
const target = $(ele)
function outputFunc(input) {
target.html(input)
}
CountDown(target, outputFunc)
});
const todayWrapper = todaySale.find(".wrapper")
if(todayWrapper.length){
simpleProductList(todayWrapper)
$(window).on("resize", function(){
simpleProductList(todayWrapper)
})
}
})($)
// ==========================================================
// 熱銷商品
// ==========================================================
;(function($) {
const hotsaleWrapper = $(".oneline-fiveitem-01 .wrapper")
if(hotsaleWrapper.length){
simpleProductList(hotsaleWrapper)
$(window).on("resize", function(){
simpleProductList(hotsaleWrapper)
})
}
})($)
// ==========================================================
// 新品登場
// ==========================================================
;(function($) {
const newWrapper = $(".new-arrivals .wrapper")
if(newWrapper.length){
simpleProductList(newWrapper)
$(window).on("resize", function(){
simpleProductList(newWrapper)
})
}
})($)
// ==========================================================
// 獨家販售
// ==========================================================
;(function($) {
const uniqueWrapper = $(".oneline-fiveitem-02 .wrapper")
if(uniqueWrapper.length){
simpleProductList(uniqueWrapper)
$(window).on("resize", function(){
simpleProductList(uniqueWrapper)
})
}
})($)
// ==========================================================
// 品牌介紹輪撥設定
// ==========================================================
;(function($) {
const slideTarget = $('.index-servicebox .index-brands')
if(slideTarget.length > 0 && slideTarget.children().length > 2) {
slideTarget.owlCarousel({
nav: true,
dots: false,
navText: ['', ''],
responsive: {
0: {
margin: 10,
items: 2,
},
576: {
margin: 10,
items: 3,
},
768: {
margin: 10,
items: 5,
},
1200: {
margin: 20,
items: 5,
},
}
})
}
})($)
// ==========================================================
// 分類購物輪播
// ==========================================================
;(function($) {
const targetCarousel = $('.index-category .category-list .wrapper')
if(targetCarousel.length) {
simpleProductList(targetCarousel)
$(window).on("resize", function(){
simpleProductList(targetCarousel)
})
}
})($)
// ==========================================================
// trigger function
// ==========================================================
;(function($) {
$(window).triggerAll('scroll resize')
})($)