$(document).ready(function () {
$('.email-popupbox').on('click','.email-close',function(){
$('.email-popupbox').fadeOut();
});
$(document).on('click','.game-notify-popup',function(e){
if(($(e.target).closest(".popup-closer").length > 0) || $(e.target).hasClass("game-notify-popup")){
$.ajax({
url:"/ajax/ajax_get_gamePop.php",
type:"POST",
cache:false,
async:false,
data:{Type:'Cancel'},
success:function(d){
$(".game-notify-popup").remove();
}
});
}
});
var n =0;
// 首頁主廣告
var all = $("#slideshow .slide-item").length;
if(all >= 1){
var vid = $("#slideshow .slide-item").find('video').get(0);
// console.log($("#slideshow .slide-item").find('video'));
if($("#slideshow .slide-item").find('video').length != 0){
$("#slideshow").owlCarousel({
items : 1,
nav : true,
navText : ['',''],
});
vid.play();
}else{
$("#slideshow").owlCarousel({
loop : true,
items : 1,
nav : true,
navText : ['',''],
autoplay:true,
autoplayTimeout:6000
});
}
}
function vidFade() {
vid.classList.add("stopfade");
}
function autoplay(){
var inall = $("#slideshow .slide-item").length;
var now = $('#slideshow .active').index();
if(inall == now){
console.log(now);
$("#slideshow").trigger('to.owl.carousel',[0,300]);
setTimeout(autoplay,5000);
}else{
console.log(now);
$("#slideshow").trigger('next.owl.carousel',[300]);
setTimeout(autoplay,5000);
}
}
$("#slideshow").on('changed.owl.carousel', function(event) {
var num = event.item.index;
if($("#slideshow").find('video') && $("#slideshow").find('.owl-item').eq(num).find('video')){
}
})
// 新品登場
$('#slide_new').owlCarousel({
// loop : true,
// items : 5,
margin: 28,
responsive: {
0:{
items : 2,
margin : 15,
},
660:{
items : 2,
margin : 15,
},
768:{
items : 2,
margin : 15,
},
960:{
items : 4
}
},
lazyLoad: true,
nav: true,
navText: ['','']
});
setTimeout(function(){
$('#slide_new').fadeIn('slow',function(){
$(this).css({'opacity':1});
});
},1000)
// 熱銷商品
$('.oneline-fiveitem-01 .wrapper').owlCarousel({
// items : 5,
responsive:{
0:{
items : 2
},
660:{
items : 3
},
768:{
items : 4
}
},
nav : true,
navText : ['','']
});
setTimeout(function(){
$('.oneline-fiveitem-01 .wrapper').fadeIn('slow',function(){
$(this).css({'opacity':1});
});
},1000)
// 推薦商品
$('.tags-001 .wrapper').owlCarousel({
// loop : true,
// items : 5,
responsive:{
0:{
items : 2
},
660:{
items : 3
},
768:{
items : 4
},
1023:{
items : 5
}
},
nav :true,
// navText : ['','']
});
// 影音
$('.owl-video').owlCarousel({
loop: true,
margin: 10,
nav: true,
responsive: {
0: {
items: 1
},
600: {
items: 1
},
1000: {
items: 1
}
}
})
//首頁專題
$(".lookbook .picbox").owlCarousel({
loop : true,
responsive:{
0:{
items : 1
},
480:{
items : 2
}
},
nav : true,
navText : ['',''],
autoplay:true,
autoplayTimeout:5000,
});
//試用評價
$('.review-001 .warpper').owlCarousel({
// loop : true,
// items : 5,
responsive:{
0:{
items : 2
},
660:{
items : 3
},
768:{
items : 4
}
},
nav : true,
navText : ['','']
});
// 三個小廣告輪播
$('.index-adbox03 .adbox-list').each((i, item) => {
if($(item).children('.adbox-list-item').length > 1) {
$(item).owlCarousel({
autoplay: true,
autoplayTimeout: 5000,
autoplayHoverPause: true,
autoplaySpeed: 1000,
loop : true,
nav : true,
navText : ['',''],
slideBy: 'page',
margin: 0,
dots: false,
responsive: {
0:{
items : 1,
},
660:{
items : 2,
},
992:{
items : 3,
},
},
});
}
})
// 左圖右商品輪播
let deviceType = '';
$(window).resize(function(e) {
e.preventDefault();
if($(window).width() >= 768 && deviceType !== "desktop") {
deviceType = "desktop"
$('.index-adbox-prod .prodbox-list').each((i, item) => {
if($(item).children('.prodbox-list-item').length > 3) {
$(item).owlCarousel({
loop : true,
nav : true,
navText : ['',''],
slideBy: 'page',
margin: 20,
items : 3,
});
}
})
} else if($(window).width() < 768 && deviceType !== "mobile") {
deviceType = "mobile"
$('.index-adbox-prod .prodbox-list').each((i, item) => {
$(item).trigger('destory.owl.carousel')
})
}
})
// $('.index-adbox-prod .prodbox-list').each((i, item) => {
// if($(item).children('.prodbox-list-item').length > 1) {
// $(item).owlCarousel({
// loop : true,
// nav : true,
// navText : ['',''],
// responsive: {
// 0: {
// slideBy: 1,
// margin: 10,
// autoWidth: true,
// items : 2,
// },
// 768: {
// slideBy: 'page',
// margin: 20,
// autoWidth: false,
// items : 3,
// }
// }
// });
// }
// })
// if($('.index-adbox-prod .prodbox-list').children('.prodbox-list-item').length > 3) {
// $('.index-adbox-prod .prodbox-list').owlCarousel({
// loop : true,
// items : 3,
// nav : true,
// navText : ['',''],
// slideBy: 'page',
// margin: 20,
// });
// }
// var owl =$('.picbox');
// $('.picbox').owlCarousel();
$('.picbox').on('translated.owl.carousel',function(event){
var id = $(this).find('.active').eq(0).find('.pic-item').attr('did');
ajax_topic_content(id);
});
function ajax_topic_content(topic_id){
$.ajax({
url:"/module/ajax/ajax_get_topic_content-p.php",
type:"POST",
cache:false,
async:false,
dataType:"json",
data:{ID:topic_id},
success:function(d){
$("#topic_content").html(d.Content);
}
});
}
});
/*
//scroll時視差效果
;(function($){
$(window).on("scroll", function(){
let _window = $(window)
scrollPosition = _window.scrollTop(),
windowHeight = _window.height()
$(".index-img").each(function(){
let _this = $(this),
imgBox =_this.parents(".index-block"),
imgTop = imgBox.offset().top,
imgHeight = imgBox.height()
if((imgTop < (scrollPosition + windowHeight)) && ((imgTop + imgHeight) > scrollPosition)){
//圖片在螢幕範圍內
let visibleHeight = Math.min(scrollPosition + windowHeight, imgTop + imgHeight) - Math.max(scrollPosition, imgTop),
imgOffset = ((1 - (visibleHeight / imgHeight)) * windowHeight / 10).toString(),
imgCenter = imgTop + imgHeight / 2,
windowCenter = scrollPosition + windowHeight / 2
if(imgCenter < windowCenter){
//圖片在上
_this.css("object-position", "50% calc(50% + " + imgOffset + "px)")
}else{
//圖片在下
_this.css("object-position", "50% calc(50% - " + imgOffset + "px)")
}
}
})
})
})($)
*/