$(function(){
var breadcrumb_on =0;
$('#breadcrumb .inline-block').on('click',function(){
if(breadcrumb_on==0){
$(this).addClass('on');
breadcrumb_on++;
}else{
$(this).removeClass('on');
breadcrumb_on=0;
}
});
$(".owl-carousel").owlCarousel({
loop : true,
items : 1,
nav : true,
});
if($("#picSlides .picItem").length>1){
$("#picSlides").owlCarousel({
loop : true,
items : 1,
nav : true,
autoplay:true,
autoplayTimeout:5000,
});
}
var clickbutton=0;
$('.filter-button,.filterbox .close').on('click',function(){
clickbutton++;
if(clickbutton==1){
$('.filterbox').css({'top':'10%'});
}
if(clickbutton==2){
$('.filterbox').css({'top':'-100%'});
clickbutton=0;
}
});
$('#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');
setTimeout(function(){
$('.content').removeClass('hide-back');
},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');
},380);
});
var owl6 = $(".user-list6 .orderSlide");
owl6.owlCarousel({
responsive:{
0:{
items : 2
},
340:{
items : 3
},
660:{
items : 6
},
960:{
items : 7
},
1023:{
items : 8
}
},
nav : true,
onRefresh : callback,
});
var owl5 = $(".user-list5 .orderSlide");
owl5.owlCarousel({
responsive:{
0:{
items : 1
},
481:{
items : 2
},
960:{
items : 5
},
1023:{
items :6
}
},
nav : true,
onRefresh : callback,
});
var addowl = $(".userBox .addBox");
addowl.owlCarousel({
responsive:{
0:{
items : 1
},
481:{
items : 1
},
661:{
items : 2
}
},
nav : true,
onRefresh : callback,
});
function callback(event){
setTimeout(function(){
$('.hidebox').animate({'opacity':1}).removeClass('hidebox');
}, 300);
}
$('article > .content ').on('click','.button1',function(e){
if($(this).attr("class").indexOf('add_to_cart') !=-1){
return false;
}
var img = $(this).parents('.productBox'),
img_src = img.find('img').attr('src'),
img_title = img.find('.title').html(),
img_price = img.find('.font-insert').html(),
img_amount= img.find('.amountBox').val(),
add_array = new Array();
if(img_amount == '無庫存'){
return false;
}
add_array[0] = 0;
if($(this).parents('.content').attr('class').substring(11,13) == '02'){
var add_type = 2
}else{
var add_type = 1;
}
$(".delete[add_type="+add_type+"]").each(function(){
add_array.push(parseInt($(this).attr("del_id")));
});
var img_index = Math.max.apply(null,add_array);
var html = '
'+img_title+'
'+img_price+'
刪除 ';
if($(this).parents('.content').attr('class').substring(11,13) == '02'){
if($('.addBox .pic-bg').length == 1){
addowl.trigger('remove.owl.carousel',$('.addBox .pic-bg').parents('.owl-item').index())
.trigger('refresh.owl.carousel');
}
var smailBox = $('.user-orderBox .addBox'),
smailBox_top = smailBox.offset().top,
smailBox_left = smailBox.offset().left,
smailBox_width = smailBox.width()/8,
smailBox_height = smailBox.height()-20;
for($i=0;$i'+img_title+'
'+img_price+'
刪除 ';
addowl.trigger('to.owl.carousel',[0,0,true])
.trigger('add.owl.carousel',[$(html),0])
.trigger('refresh.owl.carousel');
}
var choseImg = $(this).parents('.productBox').find('.productImg'),
Img_html = choseImg.clone().addClass('moveImg'),
choseImg_top = choseImg.offset().top,
choseImg_left = choseImg.offset().left,
choseImg_width = choseImg.width(),
choseImg_height = choseImg.height();
$('body').append(Img_html);
$('.moveImg').css({'top':choseImg_top,'left':choseImg_left,'width':choseImg_width,'height':choseImg_height})
.animate({
'top': smailBox_top,
'left': smailBox_left,
'width': smailBox_width,
'height': smailBox_height
},350, function() {
$(this).remove();
});
}else{
if($('.user-list5 > .orderSlide .pic-bg').length == 1){
owl5.trigger('remove.owl.carousel',$('.user-list5 > .orderSlide .pic-bg').parents('.owl-item').index())
.trigger('refresh.owl.carousel');
}
var smailBox = $('.user-orderBox'),
smailBox_top = smailBox.offset().top,
smailBox_left = smailBox.offset().left,
smailBox_width = smailBox.width()/8,
smailBox_height = smailBox.height()-20;
for($i=0;$i'+img_title+'
'+img_price+'
刪除 ';
owl6.trigger('to.owl.carousel',[0,0,true])
.trigger('add.owl.carousel',[$(html),0])
.trigger('refresh.owl.carousel');
owl5.trigger('to.owl.carousel',[0,0,true])
.trigger('add.owl.carousel',[$(html),0])
.trigger('refresh.owl.carousel');
}
var choseImg = $(this).parents('.productBox').find('.productImg'),
Img_html = choseImg.clone().addClass('moveImg'),
choseImg_top = choseImg.offset().top,
choseImg_left = choseImg.offset().left,
choseImg_width = choseImg.width(),
choseImg_height = choseImg.height();
$('body').append(Img_html);
$('.moveImg').css({'top':choseImg_top,'left':choseImg_left,'width':choseImg_width,'height':choseImg_height})
.animate({
'top': smailBox_top,
'left': smailBox_left,
'width': smailBox_width,
'height': smailBox_height
},350, function() {
$(this).remove();
});
}
callback();
});
owl6.on('click','.delete',function(){
var delitem = $(this).parents('.owl-item');
delitem.find('.title').remove();
delitem.animate({'opacity':0},300).animate({'width':0},300);
setTimeout(function(){
owl6.trigger('remove.owl.carousel',delitem.index())
.trigger('refresh.owl.carousel');
}, 700);
});
owl5.on('click','.delete',function(){
var delitem = $(this).parents('.owl-item');
delitem.find('.title').remove();
delitem.animate({'opacity':0},300).animate({'width':0},300);
setTimeout(function(){
owl5.trigger('remove.owl.carousel',delitem.index())
.trigger('refresh.owl.carousel');
if(owl5.find('.owl-item').length==0){
var html = '';
owl5.trigger('to.owl.carousel',[0,0,true])
.trigger('add.owl.carousel',[$(html),0])
.trigger('refresh.owl.carousel');
}
}, 700);
});
addowl.on('click','.delete',function(){
var delitem = $(this).parents('.owl-item');
delitem.find('.title').remove();
delitem.animate({'opacity':0},300).animate({'width':0},300);
setTimeout(function(){
addowl.trigger('remove.owl.carousel',delitem.index())
.trigger('refresh.owl.carousel');
if(addowl.find('.owl-item').length==0){
var html = '';
addowl.trigger('to.owl.carousel',[0,0,true])
.trigger('add.owl.carousel',[$(html),0])
.trigger('refresh.owl.carousel');
}
}, 700);
});
});
// ==========================================================
// 書籍細節區塊 閱讀更多
// ==========================================================
;(function($) {
$(window).on('resize', function(e) {
$('.detail-content > .web-editor').each(function(i, item) {
if($(item).height() > $(item).parent('.detail-content').height()) {
$(item).parents('.detail-box').addClass('theme-more')
}
});
})
$('.more-button > span').on('click', function(e) {
$(this).parents('.detail-box').toggleClass('in-active');
})
$(window).trigger('resize')
})($)
// ==========================================================
// 書籍細節區塊 錨點定位
// ==========================================================
;(function($) {
$('.detail-tags').on('click', '.hash-tag', function(e) {
const target = $(this).data('hash')
if(target) {
const offsetTop = $(target).offset().top
$('#wrapper').animate({
scrollTop: offsetTop - $('#Main_Content').offset().top
}, 750)
}
})
})($)
// ==========================================================
// 其他人也買了、瀏覽紀錄
// ==========================================================
;(function($) {
let otherStep = ''
const owlTarget = $('.other-content .slideBox')
$(window).on('resize', function(e) {
if($(this).width() > 1024 && otherStep !== 'desktop') {
otherStep = 'desktop'
owlTarget.each(function(i, ele) {
if($(ele).data('owl.carousel')) {
$(ele).data('owl.carousel').destroy()
}
if($(ele).children().length > 4) {
$(ele).owlCarousel({
items: 4,
margin: 35,
slideBy: 'page',
nav: true,
dots: false,
})
}
});
} else if($(this).width() <= 1024 && $(this).width() > 768 && otherStep !== 'tablet') {
otherStep = 'tablet'
owlTarget.each(function(i, ele) {
if($(ele).data('owl.carousel')) {
$(ele).data('owl.carousel').destroy()
}
if($(ele).children().length > 3) {
$(ele).owlCarousel({
items: 3,
margin: 15,
slideBy: 'page',
nav: true,
dots: false,
})
}
});
} else if($(this).width() <= 768 && otherStep !== 'mobile') {
otherStep = 'mobile'
owlTarget.each(function(i, ele) {
if($(ele).data('owl.carousel')) {
$(ele).data('owl.carousel').destroy()
}
});
}
})
$('.other-tags').on('click', '.item > button', function(e) {
const hashTarget = $(this).data('hash')
$(this).parents('.item').addClass('in-active').siblings('.item').removeClass('in-active')
$(hashTarget).addClass('in-active').siblings('.content-item').removeClass('in-active')
})
$(window).trigger('resize')
$('.other-tags .item:first-child > button').trigger('click')
})($)