// 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') } }) })($) // 天邊跑馬燈設定 ;(function($) { $(".marquee-wrapper .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, }); })($) // 螢幕滾動 ;(function($) { let windowScroll = 0 $(window).on('scroll', function(e) { if($(this).scrollTop() > 0) { $("body").addClass('is-scroll') } else { $("body").removeClass('is-scroll') } if(windowScroll > $(this).scrollTop() && $(this).scrollTop() > 0) { $("body").addClass('is-sticky'); } else { $("body").removeClass('is-sticky'); } windowScroll = $(this).scrollTop() }) })($) // 主選單 ;(function($) { let navbarDevice = '' let navbarTouch = '' $(window).on('resize', function(e) { // 通用選單 if($(this).width() >= 992) { if(navbarDevice !== 'desktop') { navbarDevice = 'desktop' // 主選單開關 $('body').removeClass('menu-open'); $('.navbar-toggle, .header').off('click') } if($('body').hasClass('DeviceWithHover')) { $('.header').off('click') $('.header').on('mouseenter', '.main-link', function(e) { e.preventDefault() const thisTarget = $(this).attr('data-target') $(this).parent('.main-item').addClass('in-hover').siblings('.main-item').removeClass('in-hover') $(thisTarget).addClass('in-hover').siblings('.children-content').removeClass('in-hover') }).on('mouseleave', '.navbar-wrapper', function(e) { e.preventDefault() $('.main-item, .children-content').removeClass('in-hover') }) } else { $('.header').off('mouseenter').off('mouseleave') $('.header').on('click', '.main-link', function(e) { e.preventDefault() const thisTarget = $(this).attr('data-target') $(this).parent('.main-item').toggleClass('in-hover').siblings('.main-item').removeClass('in-hover') $(thisTarget).toggleClass('in-hover').siblings('.children-content').removeClass('in-hover') }) } } else if($(this).width() < 992 && navbarDevice !== 'mobile') { navbarDevice = 'mobile' // 主選單開關 $('.navbar-toggle').on('click', function(e) { $('body').toggleClass('menu-open'); }) $('.main-item, .children-content').removeClass('in-hover') $('.header').on('click', '.main-link', function(e) { e.preventDefault() const thisTarget = $(this).attr('data-target') $(this).parent('.main-item').addClass('in-active').siblings('.main-item').removeClass('in-active') $(thisTarget).addClass('in-active').siblings('.children-content').removeClass('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(Project_Country+'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 change = 0; /* 手機平板 */ 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'); }; } var time_id; _window.on('resize',function(){ clearTimeout(time_id); _window = $(window); 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(); }); } }); //點擊率 $(".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: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/'; }); }); $('main').on('click', '.club-aside', function(event) { $('body').css('position','fixed'); }); $('main').on('click', '.close-m', function(event) { $('body').removeAttr('style'); }); // ========================================================== // footer menu toggle // ========================================================== ;(function($, jQuery, window, document) { let footerMenuStep = ''; $(window).on('resize', function(e) { if($(this).width() >= 992 && footerMenuStep !== 'desktop') { footerMenuStep = 'desktop' $('.footer-menu').off('click', '.menu-title').find('.menu-item').removeClass('in-active') } else if($(this).width() < 992 && 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') }) } }).trigger('resize') })($, jQuery, window, document) // ========================================================== // 商品規格 tag 切換 // ========================================================== ;(function($) { $('body').on('click', '.tag-box .title-link', function(e) { e.preventDefault() const thisTarget = $(this).attr('href') $(this).parent('.title-item').addClass('in-active') .siblings('.title-item').removeClass('in-active') $(thisTarget).addClass('in-active') .siblings('.content-item').removeClass('in-active') }) })($) // ========================================================== // 商品規格評論區塊輪播 // ========================================================== ;(function($) { let productReviewStep = '' $(window).on('resize', function(e) { if($(this).width() >= 992 && productReviewStep !== 'desktop') { productReviewStep = 'desktop' $('.content-pics').each(function(i, ele) { $(ele).owlCarousel({ autoWidth: true, margin: 15, nav: true, dots: false, navText: ['', ''], }) }); } else if($(this).width() < 992 && productReviewStep !== 'mobile') { productReviewStep = 'mobile' $('.content-pics').each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } }); } }) })($) // ========================================================== // 評價圖片跳窗 // ========================================================== ;(function($) { $('main').on('click', '.content-pics .OpenSlide', function(e) { e.preventDefault() $('body').addClass('overflow-hidden') const targetPic = $(this).attr('href'); const targetGroup = $(this).attr('group') const targetStep = $(this).attr('data-step') const groupAry = $(this).parents('.content-pics').find('[group=' + targetGroup + ']') const slideAry = [] groupAry.each(function(i, ele) { const pushString = $(ele).attr('href') slideAry.push(pushString) }); // console.log(slideAry) const appendSlides = slideAry.reduce(function(prev, ele, i) { const thisStr = `
` return prev + thisStr }, '') const appendChild = `