// JQ 功能擴增
$.fn.triggerAll = function(list) {
return this.each(function() {
const $this = $(this)
$.each(list.split(' '), function(key, val) {
$this.trigger(val)
})
})
}
// 裝置判斷
function DeviceIsTouch() {
const userAgent = navigator.userAgent
const regexp = /Android|iPhone|SymbianOS|Windows Phone|iPad|iPod|Touch|Mobile|Tablet|BlackBerry/gi
return !!userAgent.match(regexp)
}
// resize 裝置判斷
;(function($) {
$(window).on('resize', function(e) {
if(DeviceIsTouch()) {
$('body').removeClass('DeviceWithHover')
} else {
$('body').addClass('DeviceWithHover')
}
})
})($)
//定義css變數 --vh 避免行動裝置vh計算異常(會被瀏覽器address bar影響)
$(function(){
function setVh(){
document.documentElement.style.setProperty('--vh', `${window.innerHeight * 0.01}px`)
}
setVh()
$(window).on('resize', setVh)
})
// 天邊跑馬燈設定
;(function($) {
$(".marquee .marquee-list").owlCarousel({
items: 1,
nav: false,
dots: false,
autoplay: true,
autoplayTimeout: 8000,
autoplaySpeed: 1000,
autoplayHoverPause: true,
animateIn: 'slideInUp',
animateOut: 'slideOutUp',
mouseDrag: false,
loop:true
});
//展開跑馬燈
$(document).on("click", ".marquee-toggle", function(){
if($(this).parents(".marquee").hasClass("countdown-mode")){
$("body").toggleClass("marquee-countdown-expand")
}else{
$("body").toggleClass("marquee-expand")
}
})
//跑馬燈倒數模式
marqueeCountdown($(".marquee-countdown .countdown-box"))
function marqueeCountdown(target){
let num = parseInt(target.data("second"),10),
rotors = target.find(".countdown-rotor")
let temp = num,
timeArray = ""
let day = Math.floor(temp/86400)
temp = temp % 86400
let hour = Math.floor(temp / 3600)
temp = temp % 3600
let min = Math.floor(temp / 60)
temp = temp % 60
let second = temp
timeArray += (day < 10) ? "0" + day : day
timeArray += (hour < 10) ? "0" + hour : hour
timeArray += (min < 10) ? "0" + min : min
timeArray += (second < 10) ? "0" + second : second
if(timeArray.length > 8){
for(let i = 0; i < timeArray.length - 8; i++){
target.find(".day-group .countdown-rotor").eq(0).before(`
0
`)
}
rotors = target.find(".countdown-rotor")
}
for(let i in timeArray){
let rotor = rotors.eq(i),
num = timeArray[i]
rotor.text(num)
}
setInterval(function(){
num--
let tempNum = 0,
carryFlag = false,
tempCount = 0
if(num <= 0){
window.location.reload();
}
//sec個位
tempCount = num % 10
carryFlag = (tempCount == 9) ? true : false
tempNum = Math.floor(num/10)
flipUpdate(rotors.eq(-1), tempCount)
//sec十位
if(carryFlag){
tempCount = tempNum % 6
carryFlag = (tempCount == 5) ? true : false
tempNum = Math.floor(tempNum/6)
flipUpdate(rotors.eq(-2), tempCount)
}
//min個位
if(carryFlag){
tempCount = tempNum % 10
carryFlag = (tempCount == 9) ? true : false
tempNum = Math.floor(tempNum/10)
flipUpdate(rotors.eq(-3), tempCount)
}
//min十位
if(carryFlag){
tempCount = tempNum % 6
carryFlag = (tempCount == 5) ? true : false
tempNum = Math.floor(tempNum/6)
flipUpdate(rotors.eq(-4), tempCount)
}
//hour個位/十位
if(carryFlag){
tempCount = tempNum % 24
carryFlag = (tempCount == 23) ? true : false
tempNum = Math.floor(tempNum/24)
let hourDigits = tempCount % 10,
hourTens = Math.floor(tempCount/10)
flipUpdate(rotors.eq(-5), hourDigits)
if(tempCount == 9 || tempCount == 19 || tempCount == 23){
flipUpdate(rotors.eq(-6), hourTens)
}
}
for(let i = 7; i < timeArray.length+1; i++){
//day
if(carryFlag){
tempCount = tempNum % 10
carryFlag = (tempCount == 9) ? true : false
tempNum = Math.floor(tempNum/10)
flipUpdate(rotors.eq(-i), tempCount)
}
}
},1000)
}
function flipUpdate(target,num){
setTimeout(function(){
target.text(num)
},500)
}
})($)
// 螢幕滾動
;(function($) {
let windowScroll = 0
$(window).on('scroll', function(e) {
if($(this).scrollTop() > 0) {
$('.gotop').fadeIn(400)
$("body").addClass('is-sticky');
} else {
$('.gotop').fadeOut(400)
$("body").removeClass('is-sticky');
}
//向上滑
if(windowScroll > $(this).scrollTop()){
$("body").addClass('is-upwards');
}else{
$("body").removeClass('is-upwards');
}
windowScroll = $(this).scrollTop()
})
})($)
// 主選單
;(function($) {
//螢幕寬度
function checkMobileWidth(){
if($(window).width() >= 1200){
return false
}else{
return true
}
}
var mobileFlag = checkMobileWidth()
$(window).on("resize", function(){
mobileFlag = checkMobileWidth()
$(window).trigger("mobileFlagChange")
})
//桌機 hover分類時顯示對應細分類組
$(document).on("mouseenter", ".child-navbar .child-item", function(){
if(!mobileFlag){
let target = $(this).data("target"),
parent = $(this).parents(".child-content"),
targetBox = parent.find(".third-box[data-index="+target+"]")
parent.find(".child-item").removeClass("in-active")
parent.find(".third-box").removeClass("in-open")
$(this).addClass("in-active")
targetBox.addClass("in-open")
}
})
//桌機 hover細分類時顯示對應廣告
$(document).on("mouseenter", ".third-navbar .third-link", function(){
if(!mobileFlag){
let _this = $(this),
picPath = _this.data("img"),
thirdBox = _this.parents(".third-box")
picHover = thirdBox.find(".third-ad-hover"),
picOrigin = thirdBox.find(".third-ad-pic")
if(picPath){
let picItem = _this.parents(".third-box").find(".third-ad-hover")
picHover.attr("src", picPath)
picOrigin.addClass("hide")
picHover.removeClass("hide")
}
}
})
$(document).on("mouseleave", ".third-navbar .third-link", function(){
if(!mobileFlag){
let _this = $(this),
thirdBox = _this.parents(".third-box")
picHover = thirdBox.find(".third-ad-hover"),
picOrigin = thirdBox.find(".third-ad-pic")
picHover.addClass("hide")
picOrigin.removeClass("hide")
}
})
//行動裝置 menu toggle
$(document).on("click" , ".navbar-toggle", function(){
$('body').toggleClass('menu-open')
})
$(document).on("click", ".navbar-wrapper", function(e) {
if(e.target === e.currentTarget) {
$("body").removeClass("menu-open");
}
})
$(".third-navbar-inner").on("scroll", function(e){
let _this = $(this),
container = _this.parent(".third-navbar")
if(_this.scrollTop() == 0){
//最上方
container.removeClass("theme-shadow-top")
}else if(_this.scrollTop() + _this.height() == _this[0].scrollHeight){
//最下方
container.removeClass("theme-shadow-bottom")
}else{
container.addClass("theme-shadow-top theme-shadow-bottom")
}
})
//行動裝置連結行為更改
$(".navbar-wrapper").on("click", ".navbar-link", function(e){
if(mobileFlag){
if($(this).parent(".navbar-item").hasClass("with-child")){
e.preventDefault()
$(".navbar-item").removeClass("in-active")
$(this).parent(".navbar-item").addClass("in-active")
}
}
})
let clientClickFlag = false
$(".navbar-wrapper").on("click", ".child-link", function(e){
if(mobileFlag){
let childItem = $(this).parent(".child-item"),
target = childItem.data("target"),
parent = $(this).parents(".child-content"),
scrollBox = parent.find(".third-wrapper"),
navbarBox = parent.find(".child-navbar-box")
if(childItem.length > 0){
e.preventDefault()
$(".child-item").removeClass("in-active")
childItem.addClass("in-active")
clientClickFlag = true
scrollBox.animate({
scrollTop: parent.find(".third-box[data-index="+target+"]").offset().top - scrollBox.offset().top + scrollBox.scrollTop() - navbarBox.height()
}, 240)
}
}
})
//手機版 細分類列表滾動同步更新上方對應分類
let thirdBoxScroll = throttleScroll(function(currentScroll){
let parent = currentScroll.parents(".child-content"),
navbarBox = parent.find(".child-navbar-box"),
navbar = parent.find(".child-navbar"),
topRange = (navbarBox.hasClass("in-open"))?navbarBox.height(): parseInt(parent.find(".third-wrapper").css("padding-top"), 10),
topItem
currentScroll.find('.third-box').each(function(){
if($(this).position().top - topRange <= 0){
topItem = $(this)
}else{
return false
}
})
let childItem = parent.find(".child-item[data-target=" + topItem.data("index") + "]")
console.log(clientClickFlag)
if(!childItem.hasClass("in-active")){
//點擊分類產生的scroll不觸發
if(!clientClickFlag){
parent.find(".child-item").removeClass("in-active")
childItem.addClass("in-active")
navbar.animate({
scrollLeft: childItem.offset().left - navbar.offset().left + navbar.scrollLeft()
})
}else{
clientClickFlag = false
}
}
}, 250, $(".third-wrapper"))
function checkThirdBoxScroll(){
if(mobileFlag){
thirdBoxScroll.init()
}else{
thirdBoxScroll.destroy()
}
}
checkThirdBoxScroll()
$(window).on("mobileFlagChange", checkThirdBoxScroll)
//手機版 分類折疊
$(".navbar-wrapper").on("click", ".child-switch", function(){
$(this).parents(".child-navbar-box").toggleClass("in-open")
})
//預設展開 若當前無展開的則找第一個來展開
//分館
let navbarWrapper = $(".navbar-wrapper")
if(navbarWrapper.find(".navbar-item.in-active").length <= 0){
navbarWrapper.find(".navbar-item.with-child").eq(0).addClass("in-active")
}
//分類
let childContent = $(".child-content")
childContent.each(function(){
let _this = $(this)
if(_this.find(".child-item.in-active").length <= 0){
let targetItem = _this.find(".child-item.with-child").eq(0)
targetItem.addClass("in-active")
_this.find(".third-box[data-index="+targetItem.data("target")+"]").addClass("in-open")
}
})
// function menu toggle
$('.func-menu').on('click', '.able-toggle', function(e) {
$(this).parents('.func-item').toggleClass('in-active')
})
})($)
// gotop
;(function($) {
$('.gotop').on('click', function(e){
e.preventDefault()
$("html, body").animate({scrollTop: 0},800);
});
})($)
$(function(){
//點擊率
$(document).on("click",".HITS_BT",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:Project_Country+"ajax/ajax_add_ad_hits-p.php",
type:"POST",
cache:false,
async:false,
data:{Hid: hid , Hdid : hdid},
error:function(d){
alert('網路連線過慢,網頁請重新整理');
},
success:function(d){
if(url){
if(target == '_blank'){
window.open(url);
}else if( ( typeof target === 'undefined' ) || (target == '') ){
window.location = url;
}else{
}
}
}
});
}else{
alert(_jsLang.這是錯誤的連結);
}
});
//讚數加減
$(".Thumbs_BT").on("click",function(e){
e.preventDefault();
if( $.isNumeric($(this).attr('pdid')) ){
var h = $(this);
var ID = h.attr('pdid');
var Type = (h.attr('tbup')==1)?'Sub':'Add';
$.ajax({
url:Project_Country+"ajax/ajax_add_thumbs-p.php",
type:"POST",
cache:false,
async:false,
dataType:"json",
data:{Type: Type , ID : ID},
error:function(d){
alert('網路連線過慢,網頁請重新整理');
},
success:function(d){
if(d.Thumbs_Up=='1'){
$('.content').find('.Thumbs'+ID).attr('tbup','1');
$('.content').find('.Thumbs'+ID).find('.Thumbs_icon').removeClass('fa-thumbs-o-up');
$('.content').find('.Thumbs'+ID).find('.Thumbs_icon').addClass('fa-thumbs-up');
}else{
$('.content').find('.Thumbs'+ID).attr('tbup','0');
$('.content').find('.Thumbs'+ID).find('.Thumbs_icon').removeClass('fa-thumbs-up');
$('.content').find('.Thumbs'+ID).find('.Thumbs_icon').addClass('fa-thumbs-o-up');
}
$('.content').find('.Thumbs'+ID).find('.Thumbs_Num').html(d.Thumbs_Num);
}
});
}else{
alert(_jsLang.這是錯誤的連結);
}
});
// //點擊清空輸入框
// $(".CLEAR_INPUT").one("click", function(){
// $(this).attr('placeholder','');
// });
// //語系選擇
// $(".Select_This_Lang").on("click","li,label",function(){
// $.post(Project_Country+'ajax/ajax_change_language.php', {Name: $(this).attr('sid')}, function(h){
// window.location.reload();
// /*if (typeof updatePage == "function"){
// updatePage();
// return false;
// }
// if(h){
// window.location.reload();
// }*/
// }, 'html');
// });
// //貨到通知改為連至門市
// $(document).on('click','.informForPorter',function(){
// window.location.href = '/'+$("#Website_Mall_ID").val()+'/store/';
// });
});
// function errorbox(title,content,button){
// var html='';
// $('body').append(html);
// $('body').on('click', '#popupBox .close', function(event) {
// $('#popupBox').remove();
// });
// };
// $('main').on('click', '.club-aside', function(event) {
// $('body').css('position','fixed');
// });
// $('main').on('click', '.close-m', function(event) {
// $('body').removeAttr('style');
// });
// ==========================================================
// owl carousel 樣式校正
// ==========================================================
;(function($) {
function dotsCheck(jqElement) {
const thisTarget = jqElement
const checkTarget = thisTarget.find('.owl-dots')
if(!checkTarget.hasClass('disabled')) {
thisTarget.addClass('with-dots')
} else {
thisTarget.removeClass('with-dots')
}
}
$('body').on('refreshed.owl.carousel', '.owl-carousel.with-dots', function(e) {
dotsCheck($(this))
})
})($)
// ==========================================================
// footer menu toggle
// ==========================================================
;(function($, jQuery, window, document) {
let footerMenuStep = '';
$(window).on('resize', function(e) {
if($(this).width() >= 1200 && footerMenuStep !== 'desktop') {
footerMenuStep = 'desktop'
$('.footer-menu').off('click', '.menu-title').find('.menu-item').removeClass('in-active')
} else if($(this).width() < 1200 && footerMenuStep !== 'mobile') {
footerMenuStep = 'mobile'
$('.footer-menu').on('click', '.menu-title', function(e) {
e.preventDefault()
$(this).parent('.menu-item').toggleClass('in-active')
.siblings('.menu-item').removeClass('in-active')
})
}
})
})($, jQuery, window, document)
// ==========================================================
// 通用跳窗功能
// ==========================================================
;(function($) {
$('body').on('click', '.popupBox-wrapper', function(e) {
if(e.currentTarget === e.target || $(e.target).hasClass('closer')) {
e.preventDefault()
let popupWrapper = '';
$('body').removeClass('overflow-hidden')
if(e.currentTarget === e.target) {
popupWrapper = $(e.target)
} else {
popupWrapper = $(e.target).parents('.popupBox-wrapper')
}
if(!popupWrapper.hasClass('popupBox-constant')) {
popupWrapper.remove()
} else {
popupWrapper.addClass('hide')
}
}
})
$(document).on('click', '.popupBox-trigger', function(){
let target = $(this).data("target"),
popupTarget = $('.popupBox-wrapper[data-popup=' + target + ']')
if(popupTarget.length > 0){
$('body').addClass('overflow-hidden')
popupTarget.removeClass('hide')
}
})
})($)
// ==========================================================
// 再買一次
// ==========================================================
;(function($) {
$(document).on('click', '.btn-purchase-again', function() {
const order_num = $(this).data("order");
$.ajax({
url:Project_Country+"member/ajax/ajax_order_again.php",
type:"POST",
data:{order_num:order_num,},
dataType:'json',
error:function(d){
alert('網路連線過慢,網頁請重新整理');
},
success:function(d)
{
if(d.status != 'ok')
{
alert(d.msg);
}
else
{
if(d.dataLayer)eval(d.dataLayer);
window.location.href = d.url;
}
}
});
})
})($)
// ==========================================================
// 快速購物跳窗
// ==========================================================
;(function($) {
let commonShopcartStep = false
$('body').on('click', '.QuickShop', function(e) {
e.preventDefault()
if(!commonShopcartStep) {
commonShopcartStep = true
jQuery.ajax({
url: Project_Country + 'ajax/ajax_popup_shopbox.php',
type: 'POST',
dataType: 'html',
data: {
SID: $(this).attr('SID'),
Serial: $(this).attr('serial'),
Amount: $(this).parent().find('.amountBox').val(),
},
}).done(function(res) {
$('body').addClass('overflow-hidden').append(res)
}).fail(function(x, y, z) {
console.log(x)
}).always(function() {
commonShopcartStep = false
})
}
})
})($)
// ==========================================================
// 快速購物跳窗規格選擇
// ==========================================================
;(function($) {
$('body').on('click', '.choice-item, .checkbox-item', function(e) {
$(this).addClass('in-choice').siblings('.choice-item, .checkbox-item').removeClass('in-choice')
})
})($)
// ==========================================================
// 快速購物跳窗規格選擇
// ==========================================================
;(function($) {
$(document).on('click', '.get-product-intro', function(e) {
let _this = $(this)
let serial = _this.attr("serial")
jQuery.ajax({
url: Project_Country + 'ajax/ajax_popup_product_intro.php',
type: 'POST',
dataType: 'html',
data: {
Serial: serial,
},
}).done(function(res) {
$('body').addClass('overflow-hidden').append(res)
}).fail(function(x, y, z) {
console.log(x)
})
})
})($)
// ==========================================================
// 購物車細節
// =========================================================
;(function($) {
$('#Shop_Cart_Total').on('mouseenter', function(e) {
if(!$(this).hasClass('can-open')){
return false;
}
$("#Header_Shopcart").load(Project_Country+'ajax/ajax_get_cart.php','');
$('.shopping-cartbox').addClass('in-open');
$('.one-cartbox').removeClass('in-open');
});
$('.func-menu').on('mouseleave', function(e) {
$('.shopping-cartbox').removeClass('in-open');
});
//天邊購物車刪除商品
$(document).on('click','.func-item .prod_del',function(e){
e.preventDefault()
const clickItem = $(this)
let itemNum = 0
$.ajax({
url:Project_Country+"shopcart/ajax/ajax_cart_del.php",
type:"POST",
cache:false,
data:{ID:$(this).attr("sid"),Act:$(this).attr("act"),Ch_Flag:$(this).attr("ch")},
dataType:'json',
error:function(d){
alert('網路連線過慢,網頁請重新整理');
},
success:function(d){
if(d.Status == 'RET_SUCCESS')
{
if(d.DataLayer){eval(d.DataLayer)}
alert(_jsLang.刪除成功);
updateCartNum()
GetFloatCart()
}
else if(d.Status == 'RET_ERROR_Not_Delete'){
alert(_jsLang.商品已刪除請重新整理確認);
}
else
{
alert(_jsLang.資料庫忙線中);
}
}
});
});
let shopcartWrapper = $(".shopping-cartbox, .one-cartbox")
shopcartWrapper.on("click", ".spec-button", function() {
let _this = $(this),
amountInput = _this.siblings(".spec-input"),
amount = parseInt(amountInput.val()),
max = parseInt(amountInput.attr("max")),
min = (parseInt(max)>0)?1:0
if(_this.hasClass("locked")){
return false;
}
if(_this.hasClass("spec-plus")){
if(amount+1 > max){
amountInput.val(max);
return false;
}else{
amount = amount + 1
}
}else{
if(amount-1 < min){
amountInput.val(min);
return false;
}else{
amount = amount - 1
}
}
shopcartWrapper.find(".spec-button").addClass("locked")
$.ajax({
type: "POST",
cache:false,
url: Project_Country+"ajax/ajax_change_cart.php",
data: {
sid: amountInput.attr("sid"),
num: amount
},
dataType: "json",
}).done(function(d){
if(d.status == "RET_SUCCESS"){
updateCartNum()
GetFloatCart()
shopcartWrapper.find(".spec-button").removeClass("locked")
}
}).fail(function(d) {
alert('網路連線過慢,網頁請重新整理');
})
})
// 數量輸入
shopcartWrapper.on('change',".spec-input",function(){
var amountInput = $(this)
now_num = amountInput.val(),
max_num = amountInput.attr('max'),
min_num = (parseInt(max_num)>0)?1:0;
now_num = parseInt(now_num);
min_num = parseInt(min_num);
$(this).val(now_num);
if(now_num>max_num){
alert('庫存不足');
amountInput.val(max_num);
}
if(now_num 0){
$('html, body').animate({
scrollTop: target.offset().top - headerHeight
})
}
})
})($)
// ==========================================================
// 列表上方廣告banner輪播
// ==========================================================
;(function($) {
if($('.picSlides-big:not(#slideshow)').length > 0) {
$('.picSlides-big').each(function(i, ele) {
if($(ele).children().length > 1) {
$(ele).owlCarousel({
autoplay: true,
autoplayHoverPause: true,
autoplaySpeed: 1500,
autoplayTimeout: 5000,
dots: false,
items: 1,
loop: true,
margin: 10,
nav: true,
navText: ['', ''],
})
}
})
}
})($)
// ==========================================================
// 密碼顯示明碼
// ==========================================================
;(function($) {
$(document).on('click', '.password-eye', function(){
let _this = $(this)
passwordInput = _this.parents('.password-box').find('.input-text')
if(_this.hasClass('password-plain')){
_this.removeClass('password-plain')
passwordInput.attr('type', 'password')
}else{
_this.addClass('password-plain')
passwordInput.attr('type', 'text')
}
})
})($)
// ==========================================================
// 商品細節頁、快速購物跳窗行銷列表開關
// ==========================================================
;(function($) {
$(document).on('click', '.sale-title a', function(e) {
e.preventDefault()
$(this).addClass('hide').parents('.salebox').addClass('in-expand')
})
})($)
// ==========================================================
// 細節頁下方說明區塊滑動定位
// ==========================================================
;(function($) {
$(document).on('click', '.tag-title > .title-h2', function(e) {
e.preventDefault()
const thisTarget = $(this).attr('for')
const targetOffset = $('.itembox.' + thisTarget).offset().top
$('body, html').animate({
scrollTop: targetOffset
}, 750)
})
})($)
// ==========================================================
// 列表上方廣告banner輪播
// ==========================================================
;(function($) {
$('.banner-ad').each(function(i, el) {
if($(el).children('.ad-item').length > 1) {
$(el).owlCarousel({
autoplay: true,
autoplayHoverPause: true,
autoplaySpeed: 1500,
autoplayTimeout: 5000,
dots: true,
items: 1,
loop: true,
margin: 10,
nav: false,
navText: ['', ''],
})
}
});
})($)
// ==========================================================
// 滾動事件節流
// ==========================================================
function throttleScroll(func, time, scrollBox = $(window)){
let throttleFlag = false
function throttle(method ,currentScroll){
if(throttleFlag){
return false
}
throttleFlag = true
setTimeout(function(){
//currentScroll為當前滾動的容器
method(currentScroll)
throttleFlag = false
}, time)
}
let tempFunc = function(){
throttle(func, $(this))
}
return {
init: function(){
scrollBox.on('scroll', tempFunc)
},
destroy: function(){
scrollBox.off('scroll', tempFunc)
}
}
}
//更新購物車紅點數字
function updateCartNum(){
$.ajax({
url:Project_Country+"ajax/ajax_get_cart_num.php",
type: "POST",
cache: false,
async:false,
dataType:"json",
success:function(d){
$(".cart-total-num").text(d.Total_Num)
}
})
}
function checkAmountDisabled(val, max, amountBox){
if(val < max){
amountBox.find('[class*=-plus]').removeClass('disabled')
}else{
amountBox.find('[class*=-plus]').addClass('disabled')
}
if(val > 1){
amountBox.find('[class*=-minus]').removeClass('disabled')
}else{
amountBox.find('[class*=-minus]').addClass('disabled')
}
}
// trigger function
;(function($) {
$(window).triggerAll('resize, scroll')
})($)
// search toggle
;(function($) {
$('body').on('click', '.tags-toggle', function(e) {
$(this).parents('.search-modal').toggleClass('tags-active');
})
function stepCheck(step, target, className) {
if (step) {
$('body').addClass('overflow-hidden')
target.addClass(className)
} else {
$('body').removeClass('overflow-hidden')
target.removeClass(className)
}
}
$("#keywords").on("keyup",function(){
if($("#keywords").val()!=''){
$('#Origin_Tag').hide();
$.post(Project_Country+'ajax/ajax_get_tag.php', {keywords: $("#keywords").val()}, function(data){
var Msg=JSON.parse(data),
Content='',
Mall = $("#Website_Mall_ID").val()
//console.log(Msg);
Content+='';
Content+='';
Content+='';
}
document.getElementById("Show_Tag").innerHTML=Content;
$('#Show_Tag').show();
})
}else{
$('#Show_Tag').hide();
$('#Origin_Tag').show();
}
})
//開關search modal
let searchStep = 0
$('body').on('click', '.search-toggle', function(e) {
searchStep = 1
$("#keywords").val('').trigger("keyup");//清空並觸發事件
stepCheck(searchStep, $('.search-modal'), 'in-active')
})
$('body').on('click', '.search-modal .modal-closer', function(e) {
searchStep = 0
stepCheck(searchStep, $('.search-modal'), 'in-active')
})
})($)
//取得全館活動細則
;(function($) {
$(document).on("click", ".get-activities-popup", function(){
let _this = $(this)
$.ajax({
type: "POST",
url: "/ajax/ajax_get_activities_intro.php",
data: {
id: _this.data("target")
},
success: function(res){
if(res){
let popup = $("#activitiesIntroPopup")
$("body").addClass("overflow-hidden")
if(popup.length > 0){
popup.find(".popupBox-body").html(res)
popup.removeClass("hide")
}else{
$('body').append(``);
}
}
},
error: function(d){
alert('網路連線過慢,網頁請重新整理');
}
})
})
})($)