$(document).ready(function () {
$('.filterbox').ontouchmove = function(event){
event.preventDefault();
}
var _window = $(window);
var _body = $('body');
var change_1023 = 0;
var productSlidebox = $(".productSlidebox");
if(_window.width() <= 1023 && change_1023 != 1023){
change_1023 = 1023;
// $('#filtercontrol-2,#filtercontrol-3,#filtercontrol-4').attr('checked',true);
}else if(_window.width() > 1023 && change_1023 != 1200){
change_1023 = 1200;
productSlidebox.owlCarousel({
loop : true,
items : 1,
nav : true,
});
}
_window.on('resize',function(){
if(_window.width() <= 1023 && change_1023 != 1023){
change_1023 = 1023;
// $('#filtercontrol-2,#filtercontrol-3,#filtercontrol-4').attr('checked',true);
productSlidebox.trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded');
productSlidebox.find('.owl-stage-outer').children().unwrap();
}else if(_window.width() > 1023 && change_1023 != 1200){
change_1023 = 1200;
productSlidebox.owlCarousel({
loop : true,
items : 1,
nav : true,
});
// $('#filtercontrol-2,#filtercontrol-3,#filtercontrol-4').removeAttr('checked');
}
});
var clickbutton=0;
$('#sendSearchButton,.filter-button,.filterbox .close').on('click',function(){
clickbutton++;
if(clickbutton==1){
$('.filterbox').css({'top':'5%'});
$('.filter-bg').show();
}
if(clickbutton==2){
$('.filterbox').css({'top':'-100%'});
$('.filter-bg').hide();
clickbutton=0;
}
});
$('.filter-bg').on('click',function(){
$('.filterbox').css({'top':'-100%'});
$(this).hide();
});
$('#viewMode .view-three').on('click',function(){
$('#viewMode .view-three').addClass('now');
$('#viewMode .view-four').removeClass('now');
$('.content').removeClass('view-four').addClass('view-three hide-back');
$('.content .warpper').show();
setTimeout(function(){
$('.content').removeClass('hide-back');
productSlidebox.trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded');
productSlidebox.find('.owl-stage-outer').children().unwrap();
productSlidebox.owlCarousel({
loop : true,
items : 1,
nav : true,
navText:["",""],
});
},380);
});
$('#viewMode .view-four').on('click',function(){
$('#viewMode .view-four').addClass('now');
$('#viewMode .view-three').removeClass('now');
$('.content').removeClass('view-three').addClass('view-four hide-back');
setTimeout(function(){
$('.content').removeClass('hide-back');
productSlidebox.trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded');
productSlidebox.find('.owl-stage-outer').children().unwrap();
productSlidebox.owlCarousel({
loop : true,
items : 1,
nav : true,
navText:["",""],
});
},380);
});
$(".newbox").find(function(){
})
});
// ==========================================================
// 手機版,點擊購物車圖示開啟該商品購物相關細節
// ==========================================================
(function($) {
let deviceState = "desktop";
const $window = $(window);
$window.on('resize', function(e) {
if($window.width() > 1024 && deviceState !== "desktop") {
deviceState = "desktop"
$('.productBox').removeClass('in-active')
$('.toggle-detail').each(function(i, item) {
const thisText = $(item).data('cart');
$(item).text(thisText);
})
$('#Main_Content').off('click', '.toggle-detail')
} else if($window.width() <= 1024 && deviceState !== "mobile") {
deviceState = "mobile"
$('#Main_Content').on('click', '.toggle-detail', function(e) {
if($(this).parents('.productBox').hasClass('in-active')) {
$('.productBox').removeClass('in-active')
$('.toggle-detail').each(function(i, item) {
const thisText = $(item).data('cart');
$(item).text(thisText);
})
} else {
$('.productBox').removeClass('in-active')
$('.toggle-detail').each(function(i, item) {
const thisText = $(item).data('cart');
$(item).text(thisText);
})
$(this).parents('.productBox').addClass('in-active');
$(this).text($(this).data('close'))
}
})
}
})
$window.trigger('resize');
})($);