// 裝置判斷 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') } }) })($) // 天邊跑馬燈設定 ;(function($) { $(".marquee-list").marquee({ yScroll: 'down', showSpeed: 1000, pauseSpeed: 8000, pauseOnHover: true, }); })($) // 螢幕滾動 ;(function($) { $(window).on('scroll', function(e) { if($(this).scrollTop() > 0) { $('.gotop').fadeIn(400) $("body").addClass('is-sticky'); } else { $('.gotop').fadeOut(400) $("body").removeClass('is-sticky'); } }) })($) // 主選單 ;(function($) { let navbarDevice = '' let navbarTouch = '' $(window).on('resize', function(e) { // 通用選單 if($(this).width() >= 992 && navbarDevice !== 'desktop') { navbarDevice = 'desktop' // 主選單開關 $('body').removeClass('menu-open'); $('.navbar-toggle').off('click') $('.navbar-wrapper').off('click') // 主選單切換(商品/關於) $('.navbar-label').off('click', '.nav-radio') // 第三層選單項目開闔 $('.navbar-wrapper').find('.with-child').removeClass('in-active') $('.navbar-wrapper').off('click', '.with-child > .child-link') } else if($(this).width() < 992 && navbarDevice !== 'mobile') { navbarDevice = 'mobile' // 主選單開關 $('.navbar-toggle').on('click', function(e) { $('body').toggleClass('menu-open'); }) $('.navbar-wrapper').on('click', function(e) { if(e.target === e.currentTarget) { $('body').removeClass('menu-open'); } }) // 主選單切換(商品/關於) $('.navbar-label').on('click', '.nav-radio', function(e) { $(this).addClass('in-active') .siblings('.nav-radio').removeClass('in-active') }) // 第三層選單項目開闔 // $('.navbar-wrapper').find('.with-child').removeClass('in-active') $('.navbar-wrapper').on('click', '.with-child > .child-link', function(e) { e.preventDefault() $(this).parent('.with-child').toggleClass('in-active') .siblings('.with-child').removeClass('in-active') }) } if($(this).width() >= 992 && !DeviceIsTouch() && navbarTouch !== 'hover') { navbarTouch = 'hover' // 第二層選單項目開闔 $('.navbar-wrapper').find('.with-child').removeClass('in-active') $('.navbar-wrapper').on('click', '.with-child > .navbar-link') } else if(($(this).width() < 992 || DeviceIsTouch()) && navbarTouch !== 'click') { navbarTouch = 'click' // 第二層選單項目開闔 // $('.navbar-wrapper').find('.with-child').removeClass('in-active') $('.navbar-wrapper').on('click', '.with-child > .navbar-link', function(e) { e.preventDefault() $(this).parent('.with-child').toggleClass('in-active') .siblings('.with-child').removeClass('in-active') }) } }) $('.navbar-wrapper').on('mouseenter', '.child-item', function(e) { const itemPicture = $(this).attr('pic') || null const itemLink = $(this).attr('url') || 'javascript:;' if(itemPicture !== null) { $(this).parents('.child-content') .find('.picture-link').attr('href', itemLink) .children('.picture-item').attr('src', itemPicture) } }) // 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(){ $(".Select_This_Country").on("click","li,label",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'); }); var _window = $(window); var _body = $('body'); var change_1023 = 0; var nav_item =$('#menu-nav .nav-item'); var body_padding = 121; var body_padding_s = 40; var userAgent = navigator.userAgent; /* 回頁首 */ //上方廣告 var button =0; $('.top_adbox_button').on('click',function(){ if(_window.width() <= 1024){ $(".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': 800},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){ //上方廣告 if($('.top_adbox').attr('tag-status') == '1'){ $('.top_adbox .fa').removeClass('fa-plus').addClass('fa-times'); $(".top_adbox").show(); }; }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 != 1023){ 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下拉 $('#Shop_Cart_Total').on('mouseenter',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'); } }); } var time_id; _window.on('resize',function(){ clearTimeout(time_id); _window = $(window); // noisePop(); if(_window.width() <= 1024 && 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; }else if(_window.width() > 480 && _window.width() <= 1024 && change_1023 != 1023){ change_1023 = 1023; body_padding = 75; body_padding_s = 50; }else if(_window.width() > 1023 && change_1023 != 1200){ change_1023 = 1200; body_padding = 121; body_padding_s = 40; $('.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'); }); } }); $("#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'}, error:function(d){ alert('網路連線過慢,網頁請重新整理'); }, 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}, 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:"/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('/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='