$(function () {
$(".menu_class_a, .menu_sub_a").mouseover(function () {
var pic = $(this).attr('pic');
var url = $(this).attr('url');
var href = (url) ? url : 'javascript:;';
var h = (pic) ? '' : '';
$(this).parents('.item-subitembox').find('.picbox').html(h);
});
$(".menu_sub_a").mouseout(function () {
var pic = $(this).parents('.nav-item').find('.menu_class_a').attr('pic');
var url = $(this).parents('.nav-item').find('.menu_class_a').attr('url');
var href = (url) ? url : 'javascript:;';
var h = (pic) ? '
' : '';
$(this).parents('.nav-item').find('.item-subitembox').children('.picbox').html(h);
});
$("#Select_This_Country").on("click", "li", function () {
$.post('/ajax/ajax_change_country.php', {
ID: $(this).attr('sid')
}, function (h) {
if (typeof updatePage == "function") {
updatePage();
return false;
}
if (h) {
window.location.reload();
}
}, 'html');
});
$('.lazyimg').lazyload({
effect: 'fadeIn',
});
$("body").on("click", ".rack_detail", function () {
var sid = $(this).attr("store_sid");
var serial_no = $(this).attr("serial");
var flag = $(this).attr("data_id");
var box = $(this);
if (!sid) {
sid = $(this).attr("sid");
}
if (sid && flag != sid) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
$.ajax({
url: '/products/ajax/detail/ajax_get_mobile_data.php',
type: 'POST',
async: false,
data: {
lat: position.coords.latitude,
lng: position.coords.longitude,
serial_no: serial_no
},
error: function (d) {
alert(d.responseText);
},
success: function (d) {
box.attr('data_id', sid);
$("#stockCheck").find(".modal-content").html(d);
}
});
}, function () {
$.ajax({
url: '/products/ajax/detail/ajax_get_mobile_data.php',
type: 'POST',
async: false,
data: {
serial_no: serial_no
},
error: function (d) {
alert(d.responseText);
},
success: function (d) {
box.attr('data_id', sid);
$("#stockCheck").find(".modal-content").html(d);
}
});
if (typeof handleLocationError == 'function') {
handleLocationError(true, infoWindow, map.getCenter());
}
});
} else {
console.log('error');
// Browser doesn't support Geolocation
if (typeof handleLocationError == 'function') {
handleLocationError(true, infoWindow, map.getCenter());
}
}
}
});
//門市資料
$("body").on('change', '.stock-drop', function () {
$('.CityList').hide();
$('.Main-City' + $(this).val()).show();
});
var _window = $(window);
var _body = $('body');
var change_1023 = 0;
var nav_item = $('#menu-nav .nav-item');
var scroll_switch = true;
scroll_switch = nav_censor(scroll_switch);
var body_padding = 121;
var body_padding_s = 40;
var userAgent = navigator.userAgent;
/* 回頁首 */
$('.gotop').on('click', function () {
$("html,body").animate({
scrollTop: 0
}, 800);
});
//上方廣告
var button = 0;
$('.top_adbox_button').on('click', function () {
if (_window.width() <= 1023) {
$(".top_adbox").remove();
if (button == 1) button--;
} else {
if (button == 0) {
$(".top_adbox").css('height', 'auto');
$('.top_adbox .fa').removeClass('fa-plus').addClass('fa-times');
$('.top_adbox .inner').stop().animate({
'max-height': '100vh'
}, 1000, function () {
button++;
});
} else {
$('.top_adbox .fa').removeClass('fa-times').addClass('fa-plus');
$('.top_adbox .inner').stop().animate({
'max-height': 0
}, 1000, function () {
button--;
});
}
}
});
var change = 0;
//noisePop();
/* 手機平板 */
if (_window.width() <= 1024 || $(".header-01").hasClass("theme-act")) {
//上方廣告
if ($('.top_adbox').attr('tag-status') == '1') {
$('.top_adbox .fa').removeClass('fa-plus').addClass('fa-times');
$(".top_adbox").show();
};
//天邊會員登入
var member_click_n = 0;
$('.shopbox span.fa-user').on('click', function () {
if (member_click_n == 0) {
member_click_n = 1;
$('.userbox').addClass('open');
} else {
member_click_n = 0;
$('.userbox').removeClass('open');
}
});
var language_click_n = 0;
$('.language_t').on('click', '.wrapper ', function () {
if (language_click_n == 0) {
language_click_n = 1;
$('.language_t').addClass('open');
} else {
language_click_n = 0;
$('.language_t').removeClass('open');
}
});
//天邊會員登入
var language_click_n = 0;
$('#language').on('click', '.wrapper ', function () {
if (language_click_n == 0) {
language_click_n = 1;
$('#language').addClass('open');
} else {
language_click_n = 0;
$('#language').removeClass('open');
}
});
//menu開合
$('#menu-nav .hover').removeClass('hover');
if (/Windows/i.test(userAgent)) {
// console.log(`device1`)
$('#menu-nav').on('click', '.item-title', function (e) {
var n = $(this).parent(".open").length;
$('#menu-nav .nav-item').removeClass('open');
$('#menu-nav .menu-item').removeClass('open-sub');
if (n == 0) {
$(this).parent(".nav-item").addClass('open');
}
menuOpenStyle('#menu-nav a.item-title')
}).on(' click', '.subtitle', function () {
var n = $(this).parent(".open-sub").length;
$('#menu-nav .menu-item').removeClass('open-sub');
if (n == 0) {
$(this).parent(".menu-item").addClass('open-sub');
}
});
} else {
// console.log(`device2`)
$('#menu-nav').on('click', '.item-title', function (e) {
console.log(e.currentTarget)
var n = $(this).parent(".open").length;
var t = $(this).attr("type");
if (t == '') {
$('#menu-nav .nav-item').removeClass('open');
$('#menu-nav .menu-item').removeClass('open-sub');
$(".subitembox").removeClass('open-sub');
if (n == 0) {
$(this).parent(".nav-item").addClass('open');
}
} else {
$('#menu-nav .nav-item').removeClass('open');
$('#menu-nav .menu-item').removeClass('open-sub');
$(".subitembox").removeClass('open-sub');
if (n == 0) {
$(this).parent(".nav-item").find("#subitembox" + t).addClass('open-sub');
$(this).parent(".nav-item").addClass('open');
}
}
menuOpenStyle('#menu-nav a.item-title')
}).on(' click', '.subtitle', function () {
var n = $(this).parent(".open-sub").length;
$('#menu-nav .menu-item').removeClass('open-sub');
if (n == 0) {
$(this).parent(".menu-item").addClass('open-sub');
}
});
}
} else {
//上方廣告
if ($('.top_adbox').attr('tag-status') == '1') {
$(".top_adbox").show();
$(".top_adbox_button").trigger('click');
};
}
/* 手機 */
if (_window.width() <= 480 && change_1023 != 480) {
change_1023 = 480;
body_padding = 50;
/* 平板 */
} else if (_window.width() > 480 && _window.width() <= 1024 && change_1023 != 1024) {
change_1023 = 1023;
body_padding = 75;
body_padding_s = 50;
nav_item.find('.subitem').attr('type', 'checkbox');
/* 電腦 */
} else if (_window.width() > 1023 && change_1023 != 1200) {
change_1023 = 1200;
body_padding = 121;
body_padding_s = 40;
//天邊會員登入hover下拉
$('.shopbox span.fa-user').on('mouseenter', function () {
$('.userbox').addClass('open');
});
//天邊購物車hover下拉
$(document).on('mouseenter', 'body:not(.hidden-store) .shopbox #Shop_Cart_Total', function () {
$("#Header_Shopcart").load('/ajax/ajax_get_cart.php', '');
$('.shopping-cartbox').addClass('open');
});
$('.shopbox').on('mouseleave', function () {
var _this_user = $(this).find('.userbox'),
_this_shop = $(this).find('.shopping-cartbox');
if (_this_user.length == 1) {
$('.userbox').removeClass('open');
} else if (_this_shop.length == 1) {
$('.shopping-cartbox').removeClass('open');
}
});
}
let windowScroll = 0,
isChangeClass = false
_window.on('scroll', throttle(function (event) {
var scrollTop = _window.scrollTop()
if (scrollTop > 0) {
$(".gotop").css("opacity", "1");
$("body").addClass('is-sticky');
} else {
$(".gotop").css("opacity", "0");
$("body").removeClass('is-sticky');
}
//向上滑
if (!isChangeClass) {
if (windowScroll > scrollTop) {
isChangeClass = true
$("body").addClass('is-upwards');
} else {
isChangeClass = true
$("body").removeClass('is-upwards');
}
setTimeout(function () {
isChangeClass = false
}, 150)
}
windowScroll = scrollTop
}, 100));
_window.trigger('scroll')
var time_id;
_window.on('resize', function () {
clearTimeout(time_id);
time_id = setTimeout(nav_censor(scroll_switch), 500);
_window = $(window);
if (_window.width() <= 1023 && change_1023 == 1200) {
//上方廣告
// $('.top_adbox .fa').removeClass('fa-plus').addClass('fa-times');
$('.top_adbox_button').on('click', function () {
$('.top_adbox').remove();
});
$('.shopbox span.fa-user,.shopbox .fa-shopping-cart').off('mouseenter');
//天邊會員登入
var member_click_n = 0;
$('.shopbox span.fa-user').on('click', function () {
if (member_click_n == 0) {
member_click_n = 1;
$('.userbox').addClass('open');
} else {
member_click_n = 0;
$('.userbox,.shopping-cartbox').removeClass('open');
}
});
$('.shopbox').off('mouseleave');
}
if (_window.width() <= 480 && change_1023 != 480) {
change_1023 = 480;
body_padding = 50;
var scrollTop = _window.scrollTop();
} else if (_window.width() > 480 && _window.width() <= 1023 && change_1023 != 1023) {
change_1023 = 1023;
body_padding = 75;
body_padding_s = 50;
var scrollTop = _window.scrollTop();
nav_item.find('.subitem').attr('type', 'checkbox');
} else if (_window.width() > 1023 && change_1023 != 1200) {
change_1023 = 1200;
body_padding = 121;
body_padding_s = 40;
var scrollTop = _window.scrollTop();
nav_item.find('.subitem').attr('type', 'radio');
$('.shopbox span.fa-user').off('click');
//天邊會員登入
$('.shopbox span.fa-user').on('mouseenter', function () {
$('.userbox').addClass('open');
});
//天邊購物車hover下拉
$('.shopbox .fa-shopping-cart').on('mouseenter', function () {
$("#Header_Shopcart").load('/ajax/ajax_get_cart.php', '');
$('.shopping-cartbox').addClass('open');
});
$('.shopbox').on('mouseleave', function () {
$('.userbox,.shopping-cartbox').removeClass('open');
});
//移除menu開合事件
$('#menu-nav').off('click', '.item-title').off('click', '.subtitle');
}
});
function nav_censor(scroll_switch) {
if (scroll_switch) {
for (var i = 1; i < nav_item.length; i++) {
if (nav_item.eq(i).find('h3').height() > 45 || nav_item.eq(i).find('a.item-title').height() > 45) {
nav_item.eq(i).addClass('nav-item-big');
scroll_switch = false;
}
}
}
return scroll_switch;
}
var nav_n = false;
$('.menu-b').on('click', function () {
if (!nav_n) {
nav_n = true;
$('body').addClass('overflow-hidden').addClass('open-nav')
} else {
nav_n = false;
$('body').removeClass('overflow-hidden').removeClass('open-nav')
}
});
$('.navBox').on('click', function (e) {
if (e.target === e.currentTarget) {
nav_n = false;
$('body').removeClass('overflow-hidden').removeClass('open-nav')
}
});
$('.close-menu').on('click', function (e) {
nav_n = false;
$('body').removeClass('overflow-hidden').removeClass('open-nav')
});
$('.footer_menu').on('click', '.menu-item', function () {
$(this).addClass('open');
});
$('.footer_menu').on('click', '.open', function () {
$(this).removeClass('open');
});
$("#Noise_Pop").on("click", ".fa-times", function (e) {
e.preventDefault();
$.ajax({
url: "/ajax/ajax_get_noisePop.php",
type: "POST",
cache: false,
async: false,
data: {
Type: 'Cancel'
},
success: function (d) {
$("#Noise_Pop").remove();
}
});
});
$(".HITS_BT").on("click", function (e) {
e.preventDefault();
if ($.isNumeric($(this).attr('hid')) && $.isNumeric($(this).attr('hdid'))) {
var hid = $(this).attr('hid');
var hdid = $(this).attr('hdid');
var url = $(this).attr('href');
var target = $(this).attr('target');
$.ajax({
url: "/ajax/ajax_add_ad_hits-p.php",
type: "POST",
cache: false,
async: false,
data: {
Hid: hid,
Hdid: hdid
},
success: function (d) {
if (url) {
if (target == '_blank') {
window.open(url);
} else if ((typeof target === 'undefined') || (target == '')) {
window.location = url;
} else {}
}
}
});
} else {
alert(_jsLang.這是錯誤的連結);
}
});
//點擊清空輸入框
$(".CLEAR_INPUT").one("click", function () {
$(this).attr('placeholder', '');
});
//語系選擇
$("#Select_This_Lang").on("click", "li", function () {
$.post('/ajax/ajax_change_language.php', {
Name: $(this).attr('sid')
}, function (h) {
window.location.reload();
}, 'html');
});
//語系選擇
$("#Select_This_Lang3").on("click", "a", function () {
let pageShopId = $("#Page_Shop_ID").val();
$.ajax({
url: "/ajax/ajax_change_language.php",
type: "POST",
cache: false,
async: false,
data: {
Name: $(this).attr('sid'),
PageShopId: pageShopId
},
success: function (d) {
window.location.reload();
}
});
});
if ($(".rosetta-products.theme-carousel").length > 0) {
$(".rosetta-products.theme-carousel").owlCarousel({
nav: true,
responsive: {
0: {
items: 2,
margin: 16,
stagePadding: 30
},
768: {
items: 4,
margin: 16,
},
}
})
}
});
function PDA_AddToCart(Serial_No) {
window.dotq = window.dotq || [];
window.dotq.push({
'projectId': '10000',
'properties': {
'pixelId': '10095723',
'qstrings': {
'et': 'custom',
'ea': 'AddToCart',
'product_id': Serial_No,
}
}
});
window.dotq = window.dotq || [];
window.dotq.push({
'projectId': '10000',
'properties': {
'pixelId': '10146549',
'qstrings': {
'et': 'custom',
'ea': 'AddToCart',
'product_id': Serial_No,
}
}
});
}
function Rosetta_AddToCart(Pos_No) {
if (Pos_No && typeof rosetta == 'function') {
const param = {
type: 'select',
target: Pos_No
};
rosetta('event', param);
console.log('rosetta.event.select');
console.log(param);
console.log(123);
}
}
function Avivid_AddToCart(Datas) {
if (Datas) {
var num = Datas.length;
var string = '';
for (i = 0; i < num; i++) {
string += '[' + Datas[i] + '],';
}
console.log(string.substring(0, string.length - 1));
if (typeof AviviD == 'function') {
setTimeout(function () {
AviviD.analysis(1, [string.substring(0, string.length - 1)]);
}, 5000);
}
}
}
function Avivid_StartCart(Datas) {
if (typeof AviviD == 'function') {
setTimeout(function () {
AviviD.analysis(2, [Datas]);
}, 5000);
}
}
function Avivid_Purchase(Datas) {
if (typeof AviviD == 'function') {
setTimeout(function () {
AviviD.analysis(3, [Datas]);
}, 5000);
}
}
function SAYA_AddToCart() {
var noscript = '';
$("#SAYA_noscript").append(noscript);
var axel = Math.random() + "";
var a = axel * 10000000000000;
$("#SAYA_Div").append('
');
}
//結帳
function SAYA_Purchase() {
var noscript = '';
$("#SAYA_noscript").append(noscript);
var axel = Math.random() + "";
var a = axel * 10000000000000;
$("#SAYA_Div").append('
');
}
//訂單完成
function SAYA_OrderSuccess() {
var noscript = '';
$("#SAYA_noscript").append(noscript);
var axel = Math.random() + "";
var a = axel * 10000000000000;
$("#SAYA_Div").append('
');
}
//訂單完成頁
function SAYA_ShopcartOrder() {
var noscript = '';
$("#SAYA_noscript").append(noscript);
var axel = Math.random() + "";
var a = axel * 10000000000000;
$("#SAYA_Div").append('
');
}
function Set_Box_Files(_item, $this, d) {
if (d.R_Name) _item.find(".box_name").html(d.R_Name);
if (d.Color) _item.find(".colorbox").html(d.Color);
if (d.Color_Name) {
_item.find(".box_color").html('顏色 / ' + d.Color_Name);
}
if (d.Prod_No) {
_item.find(".prodnoBox").html(d.Prod_No);
}
if (d.Size_Name) {
_item.find(".box_size").html('尺寸 / ' + d.Size_Name);
}
if (d.Size_Button) _item.find(".sizebox").html(d.Size_Button);
if (d.Max_Stock) {
//if(d.Max_Stock > 10){d.Max_Stock=10}
_item.find(".amountBox").attr('max', d.Max_Stock);
_item.find(".amountBox").val('1');
}
if (d.Price2) _item.find(".font-delete").html(d.Price2);
if (d.R_Price) _item.find(".font-big").html('NT$' + d.R_Price);
for ($i = 1; $i <= 3; $i++) {
if (d.Button[$i]) _item.find(".Add_Button" + $i).html(d.Button[$i]);
}
if (d.ID) {
_item.find(".stock-icon").attr("sid", d.ID);
_item.find(".wishButton").attr("sid", d.ID);
_item.find(".Add_Reservation_List").attr("sid", d.ID);
}
if (d.Box_Pic) {
let picWrapper = _item.find(".bounce-product-left")
picWrapper.empty()
picWrapper.append('