PageSourceSearch

https://ceas.org.tw/js/coreScript.js

js ceas.org.tw collected 2026-10-01 23:47:30 UTC 46,993 bytes, 1,424 lines download raw bytes

1var rootUrl = $("#ctl00_initValue_HiddenFieldUrl").val();
2
3
4$(window).on("load", function () {
5    $('.preloader').fadeOut(1000,
6        function () { });
7});
8
9
10$(document).ready(function () {
11
12    $("body").addClass(nation_class);
13
14    if (Modernizr.touch) {
15        $("body").addClass("is_touch");
16    }
17
18    //判斷 content 
19    if ($("main .side").is(':empty') && $("main .content").is(':empty')) $("main").remove();
20
21    //for editor
22    $(".editor table.scroll").wrap("<div class='table-responsive'></div>");
23
24
25    if ($("body.home.preview .navbar.bsnav-left .navbar-brand img").length > 0) {
26        $("body.home.preview .navbar.bsnav-left .navbar-brand").css("background", "none");
27    }
28
29    /*$(".editor iframe[src*='youtube']").each(function (e) {
30        if (!$(this).hasClass("embed-responsive-item")) {
31            var w = ($(this).attr("width")) ? $(this).attr("width") : "",
32                u = (w && w.search(/px|%/) === -1) ? "px" : "";
33            $(this)
34                .removeAttr("height")
35                .removeAttr("width")
36                .addClass("embed-responsive-item")
37                .attr("allowfullscreen", "1")
38                .wrap("<div class='youtube_wrap' style='max-width:" + w + u + ";margin:auto;'><div class='embed-responsive embed-responsive-16by9' style='width:100%;'></div></div>");
39        }
40    });*/
41
42    $(window).scroll(function (e) {
43        var win_h = $(window).scrollTop();
44        var win_w = $(window).width();
45        (win_h > 10) ? $("body").addClass("is_scroll") : $("body").removeClass("is_scroll");
46
47    });
48
49    $('.btn-floating').click(function (e) {
50        e.preventDefault();
51        $('.wid-float-section').toggleClass("open");
52    });
53
54    //節慶主題
55    $(".header .wrp-deco.avatar").addClass(avatar_class);
56
57    //floating
58    var fixedBox = $(".wid-float-section");
59    var bodyObj = $("body");
60    //var fixedBox = $("body");
61    if (fixedBox.length > 0 || $(".scrolldownHeader").length > 0) {
62        pushFixedHeight(fixedBox);
63        $(window).resize(function () {
64            pushFixedHeight(fixedBox);
65        });
66
67
68        var senseSpeed = 5;
69        var previousScroll = 0;
70        var detectLast = fixedBox.outerHeight();
71        $(window).scroll(function (event) {
72            var scroller = $(this).scrollTop();
73            if (scroller - senseSpeed > previousScroll) {
74                bodyObj.addClass("scroll-down");
75                if ($(".floating_circle").length > 0) { $('.floating_circle #fmenu-open').prop('checked', false); }
76
77                //console.log("Down");
78
79            } else if (scroller + senseSpeed < previousScroll) {
80                
81                bodyObj.removeClass("scroll-down");
82                //console.log("Up");
83            }
84            previousScroll = scroller;
85
86
87            if ((scroller + $(window).height() + 10) > ($(document).height() - detectLast)) {
88                    bodyObj.removeClass("scroll-down");
89                    bodyObj.addClass("scroll-to-bottom");
90                } else {
91                    bodyObj.removeClass("scroll-to-bottom");
92                }
93        });
94    }
95
96
97    //側選單的開合按鈕
98    $('.side-toggle').click(function (e) {
99        e.preventDefault();
100        $('.side1').toggleClass("menu-open");
101    });
102
103    //side has subnav
104    if ($(".side .filter-sidebar").length <= 0) {
105        $(".side .function-bar").addClass("d-none")
106    }
107
108    //gotop Animate
109    if ($(".footer .gotop").length > 0) {
110        $(".footer .gotop a").click(function (e) {
111            e.preventDefault();
112            $("html,body").animate({ scrollTop: 0 }, "fast");
113            //return false;
114        });
115    }
116    if ($(".floating_circle .fcgotop").length > 0) {
117        $(".floating_circle .fcgotop").click(function (e) {
118            $("html,body").animate({ scrollTop: 0, behavior: 'auto' }, 600);
119            $('.floating_circle #fmenu-open').prop('checked', false);
120            return false;
121        });
122
123    }
124
125    //onepage
126    $("a[data-op=Y]").attr("href", "javascript:void(0);");
127    
128
129
130
131    //banner
132    if ($('.banner .slick').length > 0) {
133
134        //$('.banner .slick').slick({
135        //    dots: false,
136        //    infinite: true,
137        //    autoplaySpeed: 2000,
138        //    fade: true,
139        //    cssEase: 'linear',
140        //    autoplay: true
141        //});
142
143    }
144
145    //logo置中,往下滑消失
146    if ($(".bsnav-brand-center-wrapper").length > 0) {
147        var brandH = $(".header .navbar .navbar-brand").outerHeight() + parseInt($('.header .navbar .navbar-brand').css('margin-top'), 10) * 2;
148        $(".bsnav-brand-center-wrapper").css("height", brandH);
149        //$(window).resize(function () {
150        //    var brandH_rwd = $(".header .navbar .navbar-brand").outerHeight() + parseInt($('.header .navbar .navbar-brand').css('margin-top'), 10) * 2;
151        //    $(".bsnav-brand-center-wrapper").css("height", brandH_rwd);
152        //});
153    }
154
155    //fixedTop
156    if ($(".banner:not(.banner_trigger) .banner-top").length > 0) {
157        //$(".banner").css("padding-top", $(".header .navbar").outerHeight());
158        pushHeaderFixedHeight($(".header .navbar"));
159        $(window).resize(function () {
160            //var resizeH = $(".header .navbar").outerHeight();
161            //$(".banner").css("padding-top", resizeH);
162
163            pushHeaderFixedHeight($(".header .navbar"));
164        });
165    }
166
167    if ($(".banner:not(.banner_trigger) .banner-mob-bg").length > 0) {
168
169        $(".banner:not(.banner_trigger) .item").each(function () {
170            var iimg = $(this).children(".banner-pic").find(".img-small").attr("src");
171            $(this).css("background-image", "url(" + iimg + ")");
172        });
173
174
175        //if ($(window).width() <= 991) {
176            
177        //}
178        //$(window).resize(function () {
179        //    if ($(window).width() <= 991) {
180        //        $(".banner .item").each(function () {
181        //            var iimg = $(this).children(".banner-pic").find(".img-small").attr("src");
182        //            $(this).css("background-image", "url(" + iimg + ")");
183        //        });
184        //    }
185        //});
186    }
187    if ($(".banner:not(.banner_trigger) .banner-full").length > 0) {
188
189        ieFixImg($(".banner:not(.banner_trigger) .banner-full .item"));
190
191        $("body").addClass("header-animation");
192    }
193
194    if ($(".header.scrolldownHeader").length > 0) {
195        $("body").addClass("header-animation");
196    }
197
198
199    
200    
201
202
203    //bsnav
204    $(".bsnav .navbar-toggler").click(function () {
205
206
207        if ($(".bsnavclose.close-btn").length > 0 && $(".bsnav-mobile").hasClass("full") || $(".bsnav-mobile").hasClass("down")) {
208            $(".bsnavclose.close-btn").addClass("active");
209        }
210
211        $(".bsnav-mobile .navbar-nav.navbar-mobile > .nav-item > .nav-link").click(function () {
212            $(".bsnav-mobile .navbar-nav.navbar-mobile > .nav-item > .nav-link").not(this).parent("li").removeClass("in");
213            $(".bsnav-mobile .navbar-nav.navbar-mobile > .nav-item > .nav-link").not(this).next("ul").slideUp();
214          
215        });
216
217
218        //if ($(".bsnav-addToMobile").length > 0) {
219
220        //    $(".bsnav-addToMobile >
220 ul").clone().appendTo(".bsnav-mobile > .navbar");
221
222        //    if ($(".bsnav-mobile .dropdown").length > 0) {
223        //        $(".bsnav-mobile li").removeClass("dropdown");
224        //        $(".bsnav-mobile ul").removeClass("dropdown-menu");
225        //        $(".bsnav-mobile a").removeClass("dropdown-toggle");
226        //        $(".bsnav-mobile a").removeClass("dropdown-item");
227        //        $(".bsnav-mobile a").removeAttr("data-toggle");
228        //        $(".bsnav-mobile a").removeAttr("aria-haspopup");
229        //        $(".bsnav-mobile a").removeAttr("aria-expanded");
230        //    }
231        //}
232
233        return false;
234    });
235
236
237    
238
239
240    //手機選單關閉按鈕 
241    if ($(".bsnavclose.close-btn").length > 0) {
242        $(".bsnavclose.close-btn").click(function () {
243            $(".bsnav-mobile").removeClass("in");
244            $(".bsnav .navbar-toggler").removeClass("active");
245            $(this).removeClass("active");
246        });
247        $(window).resize(function () {
248            if ($(".bsnavclose.close-btn").hasClass("active")) {
249                $(".bsnavclose.close-btn").removeClass("active")
250            }
251        });
252    }
253
254
255
256    //搜尋按鈕
257    if ($(".header .search-area").length > 0) {
258
259        if ($(".nav-search-box").hasClass("slide-down-st")) {
260            var header_oh = $(".header > .navbar").outerHeight();
261            $(".header .search-area").css("top", "auto");
262            if ($(window).width() < 768) {
263                $(".header .search-area").css("top", header_oh);
264            }
265            $(window).resize(function () {
266                var header_mob_oh = $(".header > .navbar").outerHeight();
267                $(".header .search-area").css("top", "auto");
268                if ($(window).width() < 768) {
269                    $(".header .search-area").css("top", header_mob_oh);
270                }
271            });
272        }
273
274        $(".header nav .btn-search").click(function (e) {
275            e.preventDefault();
276            if ($(".nav-search-box").hasClass("slide-down-st")) {
277                $(".header .search-area").slideToggle();
278            } else if ($(".nav-search-box").hasClass("full-st")) {
279                $(this).toggleClass("active full-active");
280                $(".nav-search-box").toggleClass("active");
281            }
282
283        });
284
285    }
286
287    //購物車按鈕
288    if ($(".nav-cart-info").length > 0) {
289
290        var drop_cart_h = $(".header .nav-cart-info .cart-drop-box").parents(".small-btn-box").outerHeight();
291        $(".header .nav-cart-info .cart-drop-box .nav-cart-list").css("top", drop_cart_h);
292
293
294        if ($(window).width() < 768) {
295            $(".header .nav-cart-info .cart-drop-box .nav-cart-list").css("top", "100%");
296            $(".nav-cart-info-btn").click(function (e) {
297                e.preventDefault();
298                $(this).parents("li").toggleClass("open");
299            });
300        }
301        $(window).resize(function () {
302            var drop_cart_h = $(".header .nav-cart-info .cart-drop-box").parents(".small-btn-box").outerHeight();
303            $(".header .nav-cart-info .cart-drop-box .nav-cart-list").css("top", drop_cart_h);
304            if ($(window).width() < 768) {
305                $(".header .nav-cart-info .cart-drop-box .nav-cart-list").css("top", "100%");
306                $(".nav-cart-info-btn").click(function (e) {
307                    e.preventDefault();
308                    $(this).parents("li").toggleClass("open");
309                });
310            }
311        });
312    }
313
314
315    
316
317    //scroll to fixed
318    if ($("nav").hasClass("scrollToFixed")) {
319        $(".navbar.scrollToFixed").scrollToFixed();
320    }
321
322    //isotope
323    //initIsotope();
324    if ($(".iso-sec:not(.removeIsoTope)").length > 0) {
325        var $grid = $('.iso-area .grid.grid-normal');
326        var options = {
327            itemSelector: '.grid-normal .grid-item',
328            filter: '*',
329            percentPosition: true
330        }
331        if ($('.iso-area .grid.grid-normal .priceAmount').length > 0) {
332            options = {
333                itemSelector: '.grid-normal .grid-item',
334                filter: '*',
335                percentPosition: true,
336                getSortData: {
337                    priceAmount: function (itemElem) {
338                        var priceamount = $(itemElem).attr('data-priceAmount');
339                        return parseInt(priceamount);
340                    }
341                }
342            }
343        }
344        
345        $grid.isotope(options);
346
347
348        //masonry
349        //var $gridmasonry = $('.iso-area .grid.grid-masonry');
350        //$gridmasonry.isotope({
351        //    itemSelector: '.grid-masonry .grid-item',
352        //    filter: '*',
353        //    percentPosition: true,
354        //    masonry: {
355        //        //columnWidth: '.grid-sizer'
356        //    }
357        //});
358
359
360        $('.iso-kind a').click(function () {
361            var selector = $(this).attr('data-filter');
362            var $isoSelf = $(this).parents(".iso-sec").children(".iso-area").children(".grid");
363            $isoSelf.isotope({ filter: selector });
364
365            $(".iso-kind ul li a").not(this).parent("li").removeClass("active");
366            $(this).parent("li").addClass("active");
367
368            return false;
369        });
370
371
372        if ($(".function-bar .sort-area").length > 0) {
373
374            $(".function-bar .sort-area .dropdown-menu a").click(function (e) {
375
376                e.preventDefault();
377
378                var sortValue = $(this).attr('data-sort-value');
379                var direction = $(this).attr('data-sort-direction');
380
381                var isAscending = (direction === 'asc');
382                var newDirection = (isAscending) ? 'desc' : 'asc';
383
384                $grid.isotope({ sortBy: sortValue, sortAscending: isAscending });
385
386                //$(this).attr('data-sort-direction', newDirection);
387
388            });
389
390            
391        }
392
393
394    }
395
396
397    //datetimepicker
398    if ($(".datetimepicker").length > 0) {
399        $(".datetimepicker").bootstrapMaterialDatePicker({
400            weekStart: 0,
401            time: false,
402            lang: 'zh-tw'
403        });
404    }
405
406   
407
408
409    //fancybox
410    if ($('.btn-fancy').length > 0) {
411        $('.btn-fancy').fancybox();
412    }
413
414    //banner trigger
415    //if ($(".banner_trigger").length > 0) {
416
417    //    $("body").addClass("btrigger");
418
419    //    $(".bannertrigger-btn").trigger("click");
420
421    //    fixedSlick(".banner_trigger .slick");
422
423    //}
424
425    //swiper
426    if ($('.swiper-container').length > 0) {
427        //initSwipper();
428    }
429
430
431    //slick
432    if ($(".slick-mode").length > 0) {
433        if ($('.news-sec .multiple-slick').length > 0) {
434           // runNewsSlick();
435        }
436        if ($('.link-sec .multiple-slick').length > 0) {
437            //runlinkSlick();
438        }
439        
440    }
441
442    
443
444    //if ($(".flatPicker").length > 0) {
445    //    flatpickr(".flatPicker", {
446    //        "locale": "zh"
447    //    });
448    //    //$(".flatPicker").flatpickr({
449    //    //    enableTime: true,
450    //    //    dateFormat: "Y-m-d H:i"
451    //    //});
452    //}
453
454    var nav = animateTime = 500
455
456    //filter-sidebar
457    if ($(".function-bar .filter-btn-area").length > 0) {
458        $(".function-bar .filter-btn-area .btn").click(function (e) {
459            e.preventDefault();
460            $(".side.filter-side").toggleClass("open");
461
462            if ($(window).width() < 768) {
463                $(".side.filter-side .filter-sidebar").slideToggle();
464            }
465        });
466
467        //$(window).resize(function () {
468        //    if ($(window).width() < 768) {
469        //        $(".side.filter-side").slideToggle();
470        //    }
471        //});
472
473        $(".side .filter-title .collapsed-btn").each(function () {
474            if ($(this).next("ul").length > 0) {
475
476            } else {
477                $(this).removeAttr("data-toggle");
478            }
479        });
480
481    }
482
483    //側選單單層收合
484    if ($(".side .filter-title .collapsed-btn").length > 0 && $(".filter-sidebar.accordion.accordion-blocks.one-accordion").length > 0) {
485
486        $(".side .filter-title .collapsed-btn").each(function (index, element) {
487            
488            var filterCont = $(this).parents(".filter-item").find(".filter-content");
489            if (filterCont.length > 0) {
490                var originNum = $(this).data("num");
491                $(this).attr("data-toggle", "collapse");
492                $(this).attr("aria-expanded", "true");
493                $(this).attr("aria-controls", "collapse_" + originNum);
494                $(this).attr("href", "#collapse_" + originNum);
495                $(this).addClass("dropdown-toggle");
496                filterCont.attr("id", "collapse_" + originNum);
497                filterCont.removeClass("show");
498
499            }
500            //if (index > 0) { filterCont.removeClass("show"); }
501        });   
502    }
503
504    //main 側選單收合
505    if ($(".side .wid-collapse-onesub").length > 0) {
506        $(".side .wid-collapse-onesub .collapsed-btn").each(function (index, element) {
507            var filterCont = $(this).parents(".filter-item").find(".filter-content");
508            if (filterCont.length > 0) {
509                var originNum = $(this).data("num");
510                $(this).attr("data-bs-toggle", "collapse");
511                $(this).attr("aria-expanded", "true");
512                $(this).attr("aria-controls", "collapse_" + originNum);
513                $(this).attr("href", "#collapse_" + originNum);
514                $(this).addClass("dropdown-toggle");
515                filterCont.attr("id", "collapse_" + originNum);
516                filterCont.removeClass("show");
517            }
518        });
519    }
520
521
522    //側選單收合
523    multiSideMenu(true);
524
525    //側選單checkbox
526    if ($(".wid.wid-check-filter").length > 0) {
527        checkStatus();
528    }
529
530
531    //選單固定
532    if ($(".section .anchor-title").length > 0) {
533        exeScrollToFixed();
534    }
535
536    if ($(".navbar .anchor-title").length > 0) {
537        if (typeof (getUrlVars()["anchor"]) !== "undefined") {
538            if (getUrlVars()["anchor"].length > 0) {
539                var currLink = $(".navbar .anchor-title a[data-anchortitle='" + getUrlVars()["anchor"] + "']");
540                scrollToAnchor(getUrlVars()["anchor"], currLink);
541            }
542        }
543    }
544
545    //tab dropdown
546    if ($(".tab-dropdown").length > 0) {
547        tabDropdownStyle();
548        $(window).resize(function () {
549            tabDropdownStyle();
550        });
551    }
552
553    //lightgallery
554    if ($(".lightgallery-box").length > 0) {
555        $(".lightgallery-box").lightGallery();
556    }
557
558    //Modal
559    if ($(".btn-modal").length > 0) {
560        //exeModal();
561    }
562
563
564    //nav fixed top
565    if ($(".self-pad-top").length > 0) {
566        var outH = $(".self-pad-top > .fixed-top").outerHeight();
567        $(".self-pad-top").css("height", outH);
568
569        $(window).resize(function () {
570            var outH = $(".self-pad-top > .fixed-top").outerHeight();
571            $(".self-pad-top").css("height", outH);
572        });
573
574    }
575
576    
577
578    //marquee
579    if ($(".marquee").length > 0) {
580        $('.marquee-box').marquee();
581
582        if ($('.marquee').hasClass("fixed") && $(".header > .navbar").hasClass("fixed-top")) {
583            $(".header > .navbar").css("top", $('.marquee').outerHeight());
584        }
585    }
586
587    //countdown
588    if ($(".countdown-sec").length > 0) {
589        $(".footer_content").css("padding-bottom", $(".countdown-sec").outerHeight() + 40);
590    }
591
592    //product mode
593    if ($("body.product .mode-switch").length > 0) {
594        $(".display-mode").show();
595        $("body.product .btn-mode").click(function (e) {
596            e.preventDefault();
597            $("body.product .btn-mode").not(this).removeClass("active");
598            $(this).addClass("active");
599
600            var prevModeData = $("body.product .btn-mode").not(this).data("mode");
601            var modeClass = $(this).data("mode");
602            $("body.product .gallery-list").fadeOut(300, function () {
603                //$(".mode-switch").removeClass(prevModeData);
604                //$(".mode-switch").addClass(modeClass);
605                $("body.product .mode-switch").attr('data-mode', modeClass);
606            }).fadeIn();
607
608            //$(".mode-switch").data('mode', modeClass);
609
610            //$(".mode-switch").attr('data-mode', modeClass);
611
612            //console.log(modeClass);
613
614        });
615    } else {
616        $("body.product .display-mode").hide();
617    }
618
619
620    //slide banner
621    if ($('.wid-slideBanner .jcarousel').length > 0) {
622
623
624        $('.wid-slideBanner .jcarousel').slick({
625
626            dots: false,
627            infinite: true,
628            arrows: true,
629            autoplay: true,
630            autoplaySpeed: 5000,
631            slidesToShow: 1,
632            slidesToScroll: 1,
633            prevArrow: ".jcarousel-control-prev",
634            nextArrow: ".jcarousel-control-next",
635            responsive: [
636                {
637                    breakpoint: 1200,
638                    settings: {
639                        slidesToShow: 1,
640                        slidesToScroll: 1
641                    }
642                },
643                {
644                    breakpoint: 992,
645                    settings: {
646                        slidesToShow: 1,
647                        slidesToScroll: 1
648                    }
649                },
650                {
651                    breakpoint: 768,
652                    settings: {
653                        slidesToShow: 2,
654                        slidesToScroll: 1
655                    }
656                },
657                {
658                    breakpoint: 576,
659                    settings: {
660                        slidesToShow: 2,
661                        slidesToScroll: 1
662                    }
663                }
664            ]
665        });
666
667        
668
669        //var jcarousel = $('.wid-slideBanner .jcarousel');
670
671        //jcarousel
672        //    .on('jcarousel:reload jcarousel:create', function () {
673        //        var carousel = $(this),
674        //            width = carousel.innerWidth();
675        //        //width = width / 3;
676        //        if (width >= 600) {
677        //            width = width / 3;
678        //        } else if (width >= 350) {
679        //            width = width / 2;
680        //        }
681
682        //        carousel.jcarousel('items').css('width', Math.ceil(width) + 'px');
683        //    })
684        //    .jcarousel({
685        //        wrap: 'circular'
686        //    });
687
688        //jcarousel.siblings('.jcarousel-control-prev')
689        //    .jcarouselControl({
690        //        target: '-=1'
691        //    });
692
693        //jcarousel.siblings('.jcarousel-control-next')
694        //    .jcarouselControl({
695        //        target: '+=1'
696        //    });
697    }
698
699    if ($(".header .search-area").length > 0) {
700        $(".header .search-area").on('keypress', function (e) {
701            if (e.which == 13) {
702                e.preventDefault();
703                searchPro($(this).find(".btn-submit-search"));
704            }
705        });
706    }
707    
708
709});
710
711function pushFixedHeight(t) {
712    var winW = $(window).width(),
713        pushH = t.outerHeight();
714    if ($(window).width() <= 991) {
715        $("body").css("padding-bottom", pushH);
716    } else {
717        $("body").css("padding-bottom", 0);
718    }
719}
720
721function pushHeaderFixedHeight(t) {
722    var winW = $(window).width(),
723        pushH = t.outerHeight();
724    $(".banner:not(.banner_trigger)").css("padding-top", pushH);
725}
726
727//***************
728
729function fixedSlick(obj) {
730    $(obj).get(0).slick.setPosition();
731}
732
733function initSwipper(obj, autoplayMode, autoplaySpeedMode, id = "") {
734    var swiper = new Swiper(obj, {
735        on: {
736            init: function () {
737                swiperAnimateCache(this); //隐藏动画元素 
738                swiperAnimate(this); //初始化完成开始动画
739            },
740            slideChangeTransitionEnd: function () {
741                swiperAnimate(this); //每个slide切换结束时也运行当前slide动画
742                //this.slides.eq(this.activeIndex).find('.ani').removeClass('ani'); 动画只展现一次,去除ani类名
743            },
744            slideChange: function (el) {
745                console.log('1');
746                $(obj + ' .swiper-slide').each(function () {
747                    var youtubePlayer = $(this).find('iframe').get(0);
748                    if (youtubePlayer) {
749                        youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
750                    }
751                });
752            },
753        },
754        //spaceBetween: 30,
755        centeredSlides: true,
756        loop: true,
757        autoplay: {
758            delay: autoplaySpeedMode,
759            disableOnInteraction: false,
760        },
761        pagination: {
762            el: '.swiper-pagination',
763            clickable: true,
764        },
765        navigation: {
766            nextEl: '.swiper-button-next',
767            prevEl: '.swiper-button-prev',
768        },
769    })
770
771    if (!autoplayMode) {
772        //swiper.autoplay = false;
773        swiper.autoplay.stop();
774    }
775}
776
777var tag = document.createElement('script');
778tag.src = "https://www.youtube.com/iframe_api";
779var firstScriptTag = document.getElementsByTagName('script')[0];
780firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
781
782function onYouTubeIframeAPIReady(id) {
783    let player = document.querySelectorAll('[iframe-video]');
784    let buttons = document.querySelectorAll('[video-buttons]');
785
786    player.forEach(item => {
787        var itemElem = item.dataset.videolink;
788        itemElem = new YT.Player(item, {
789            videoId: item.dataset.iframeid
790        });
791
792        buttons.forEach(item => {
793            item.addEventListener('click', function (e) {
794                itemElem.pauseVideo();
795            });
796        });
797    })
798}
799
800
801function ieFixImg(obj) {
802    if (!!window.ActiveXObject || "ActiveXObject" in window) {
803        if (obj.length) {
804            obj.each(function () {
805                //$(this).children("a").css({
806                $(this).find("img").parents(".pic-wrapper").css({
807                    "background-image": function () {
808                        //var b = $(this).children("img").attr("src");
809                        var b = $(this).find("img").attr("src");
810                        //$(this).children("img").remove();
811                        $(this).find("img").remove();
812                        return "url(" + b + ")";
813                    }
814                });
815                $(this).addClass("fixedSupport");
816            });
817        }
818    }
819}
820
821
822function openSideMenu() {
823    if ($(".main .wid.wid-collapse-onesub").length > 0) {
824        if ($(".side .filter-sidebar .collapse.navbar-collapse").hasClass("show")) {
825            $(".side .filter-sidebar .collapse.navbar-collapse").removeClass("show");
826        } else {
827            $(".side .filter-sidebar .collapse.navbar-collapse").addClass("show");
828        }
829    } else {
830        if ($(".collapse-side-btn").length > 0) {
831            $(".collapse-side-btn").click(function () {
832                if ($(".collapse-side-content").length > 0) {
833                    if ($(".collapse-side-content").hasClass("show")) {
834                        $(".collapse-side-content").removeClass("show");
835                    } else {
836                        $(".collapse-side-content").addClass("show");
837                    }
838                }
839                if ($(".collapse-side-content").length > 0) {
840                    if ($(".side .navbar > .collapse").hasClass("show")) {
841                        $(".side .navbar > .collapse").removeClass("show");
842                    } else {
843                        $(".side .navbar > .collapse").addClass("show");
844                    }
845                }
846                //$(".collapse-side-content").toggleClass("show");
847                //$(".side .navbar > .collapse").toggleClass("show");
848
849                if ($('.wid-slideBanner .jcarousel').length > 0) {
850                    $('.wid-slideBanner .jcarousel').get(0).slick.setPosition();
851                }
852
853            });
854        }
855        //else {
856        //    if ($(".side .filter-sidebar").length > 0) {
857        //        if ($(".side .filter-sidebar").is(':visible')) {
858        //            $(".side .filter-sidebar").slideUp();
859        //        } else {
860        //            $(".side .filter-sidebar").slideDown();
861        //        }
862        //    }
863        //    //$(".side .filter-sidebar").slideToggle();
864        //}
865    }
866    
867    
868}
869
870function multiSideMenu(closeother) {
871
872    //<ul class="dropdown-menu show" x-placement="top-start">
873    //wid-multiple-collapse
874    //$(".filter-sidebar.multiple-collapse .navbar-nav li").each(function () {
875    $(".wid.wid-multiple-collapse .wid-cont .navbar-nav li").each(function () {
876        if ($(this).children("ul").length > 0) {
877            $(this).addClass("dropdown");
878        }
879    });
880
881    //var dropdownBtn = $(".filter-sidebar.multiple-collapse .navbar-nav > .nav-item.dropdown > .nav-link");
882    //var dropdownContent = $(".filter-sidebar.multiple-collapse .navbar-nav > .nav-item.dropdown > .nav-link").next("ul");
883    var dropdownBtn = $(".wid.wid-multiple-collapse .wid-cont .navbar-nav > .nav-item.dropdown > .nav-link");
884    var dropdownContent = $(".wid.wid-multiple-collapse .wid-cont .navbar-nav > .nav-item.dropdown > .nav-link").next("ul");
885    var dropdownIitem = dropdownContent.children("li").children("a");
886
887
888    dropdownBtn.attr("data-toggle", "dropdown");
889    dropdownBtn.attr("aria-haspopup", "true");
890    dropdownBtn.attr("aria-expanded", "true");
891    dropdownBtn.addClass("dropdown-toggle");
892
893    dropdownContent.addClass("dropdown-menu");
894    dropdownBtn.attr("x-placement", "top-start");
895
896    dropdownIitem.addClass("dropdown-item");
897
898    //避免點外面關閉下拉
899    //$('.side:not(.side-top) .filter-sidebar.multiple-collapse').on('hide.bs.dropdown', function (e) {
900    //    if (e.clickEvent) {
901    //        e.preventDefault();
902    //    }
903    //});
904    $('.side:not(.side-top) .wid.wid-multiple-collapse').on('hide.bs.dropdown', function (e) {
905        if (e.clickEvent) {
906            e.preventDefault();
907        }
908    });
909
910
911    $(".collapse-side-btn").click(function () {
912        $(".collapse-side-content").toggleClass("show");
913        $(".side .navbar > .collapse").toggleClass("show");
914        if ($('.wid-slideBanner .jcarousel').length > 0) {
915            $('.wid-slideBanner .jcarousel').get(0).slick.setPosition();
916        }
917    });
918
919
920    //side 多層
921    $('.side .dropdown-menu .dropdown-toggle').on('click', function () {
922        var $el = $(this);
923        var $parent = $el.offsetParent(".side .dropdown-menu");
924
925        if (!$el.next().hasClass("show")) {
926            $el.parents('.side .dropdown-menu').first().find(".show").removeClass("show");
927        }
928        $el.next(".side .dropdown-menu").toggleClass("show").parent("li").toggleClass("show");
929
930        $el.parents(".side li.nav-item.dropdown.show").on("hidden.bs.dropdown", function () {
931            $(".side .dropdown-menu .show").removeClass("show");
932        });
933
934        if (!$parent.parent().hasClass("navbar-nav")) {
935            $el.next().css({ "top": $el[0].offsetTop, "left": $parent.outerWidth() });
936        }
937
938        return false;
939    });
940
941    //nav cart
942    if ($(".modal-body .cart-list-collapse .cart-list-collapse-title").length > 0) {
943        $(".modal-body .cart-list-collapse .cart-list-collapse-title").click(function () {
944            $(".modal-body .cart-list-collapse .cart-list-collapse-cont").slideToggle();
945        });
946    }
947    
948
949}
950
951function checkStatus() {
952    //全選/checkbox
953    $(".wid.wid-check-filter .filter-title .chkall").click(function () {
954        $(this).parents(".filter-item").children(".filter-content").find(".chksuball").prop('checked', $(this).prop('checked'));
955        $(this).parents(".filter-item").children(".filter-content").find(".chksub").prop('checked', $(this).prop('checked'));
956
957    });
958    $(".wid.wid-check-filter .filter-content .chksuball").change(function () {
959        if (!$(this).prop("checked")) {
960            $(".filter-sidebar .filter-title .chkall").prop("checked", false);
961            //$(".country-menu #chkall").prop("checked", false);
962        }
963    });
964    $(".wid.wid-check-filter .filter-content .chksub").change(function () {
965        if (!$(this).prop("checked")) {
966            $(".filter-sidebar .filter-title .chkall").prop("checked", false);
967            $(this).parents(".filter-item").children(".filter-content").find(".chksuball").prop('checked', false);
968            $(this).parent(".filter-item").children(".filter-title").find(".chkall").prop("checked", false);
969        }
970    });
971
972    $(".wid.wid-check-filter .filter-content .chksuball").click(function () {
973        var subObj = $(this).parent("label").next(".filter-content").find(".chksub");
974        subObj.prop('checked', $(this).prop('checked'));
975    });
976}
977
978
979function initIsotope() {
980    if ($(".iso-sec").length > 0) {
981        var $grid = $('.iso-area .grid.grid-normal');
982        var options = {
983            itemSelector: '.grid-normal .grid-item',
984            filter: '*',
985            percentPosition: true
986        }
987        if ($('.iso-area .grid.grid-normal .priceAmount').length > 0) {
988            options = {
989                itemSelector: '.grid-normal .grid-item',
990                filter: '*',
991                percentPosition: true,
992                getSortData: {
993                    priceAmount: function (itemElem) {
994                        var priceamount = $(itemElem).attr('data-priceAmount');
995                        return parseInt(priceamount);
996                    }
997                }
998            }
999        }
1000
1001        $grid.isotope(options);
1002
1003
1004        //masonry
1005        var $gridmasonry = $('.iso-area .grid.grid-masonry');
1006        $gridmasonry.isotope({
1007            itemSelector: '.grid-masonry .grid-item',
1008            filter: '*',
1009            percentPosition: true,
1010            masonry: {
1011                //columnWidth: '.grid-sizer'
1012            }
1013        });
1014
1015
1016        $('.iso-kind a').click(function () {
1017            var selector = $(this).attr('data-filter');
1018            var $isoSelf = $(this).parents(".iso-sec").children(".iso-area").children(".grid");
1019            $isoSelf.isotope({ filter: selector });
1020
1021            $(".iso-kind ul li a").not(this).parent("li").removeClass("active");
1022            //$(this).parent("li").addClass("active");
1023
1024            return false;
1025        });
1026
1027
1028        if ($(".function-bar .sort-area").length > 0) {
1029
1030            $(".function-bar .sort-area .dropdown-menu a").click(function (e) {
1031
1032                e.preventDefault();
1033
1034                var sortValue = $(this).attr('data-sort-value');
1035                var direction = $(this).attr('data-sort-direction');
1036
1037                var isAscending = (direction === 'asc');
1038                var newDirection = (isAscending) ? 'desc' : 'asc';
1039
1040                $grid.isotope({ sortBy: sortValue, sortAscending: isAscending });
1041
1042                //$(this).attr('data-sort-direction', newDirection);
1043
1044            });
1045
1046
1047        }
1048
1049
1050
1051    }
1052}
1053
1054
1055function getUrlVars() {
1056    var vars = [], hash;
1057    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
1058    for (var i = 0; i < hashes.length; i++) {
1059        hash = hashes[i].split('=');
1060        vars.push(hash[0]);
1061        vars[hash[0]] = hash[1];
1062    }
1063    return vars;
1064}
1065
1066
1067function scrollToAnchor(aid, obj, url = "") {
1068    var aTag = $("div[data-anchor='" + aid + "']");
1069    if (url !== "" && aTag.length <= 0) {
1070        window.location.href = url + "?anchor=" + aid;
1071    } else {
1072
1073        var addiDistance = 80;
1074
1075        if ($(".anchor-title").length > 0) {
1076            $(obj).parents(".anchor-title").find("a").not(obj).removeClass("active");
1077            $(obj).addClass("active");
1078            addiDistance += $(".anchor-title").outerHeight();
1079            if ($(".header > .navbar").hasClass("fixed-top")) {
1080                if (typeof ($(".banner").attr("style")) != "undefined") {
1081                    addiDistance = addiDistance - $(".header > .navbar").outerHeight();
1082                } else {
1083                    addiDistance = addiDistance - ($(".header > .navbar").outerHeight() / 2);
1084                }
1085            }
1086        }
1087
1088        
1089        if ($(window).width() <= 768) {
1090            addiDistance = 80;
1091            $(".bsnav-mobile").removeClass("in");
1092        }
1093
1094        var topDistance = aTag.offset().top - addiDistance;
1095
1096
1097        $('html,body').animate({ scrollTop: topDistance }, 'slow');
1098    }
1099}
1100
1101function exeScrollToFixed() {
1102      //主選單的 anchor 不需要執行
1103    $(".section .anchor-title").scrollToFixed({
1104        marginTop: $(".header > .navbar").outerHeight(),
1105
1106        preFixed: function () {
1107            $("body").addClass("scroll_to_fixed");
1108            setTimeout(function () {
1109                $(".anchor-title").css("top", "0");
1110            }, 10);
1111        },
1112        postFixed: function () {
1113            $("body").removeClass("scroll_to_fixed");
1114            $(".section .anchor-title").css("top", "auto");
1115            console.log("postFixed");
1116        },
1117
1118    });
1119
1120    //滑到該區域,標題變色
1121    $(window).scroll(function () {
1122
1123        var scrollPos = $(document).scrollTop();
1124        var aTag = $("div[data-anchor]");
1125        aTag.each(function () {
1126            var currLink = $(this);
1127            var currAnchor = $(this).data("anchor");
1128            var currTitleAnchor = $(".anchor-title a[data-anchortitle=" + currAnchor + "]");
1129            
1130            if (currLink.position().top - 100 <= scrollPos && currLink.position().top + currLink.height() - 100 > scrollPos) {    
1131                $(".anchor-title a").removeClass("active");
1132                currTitleAnchor.addClass("active");
1133
1134            }
1135            else {
1136                currTitleAnchor.removeClass("active");
1137            }
1138        });
1139    });
1140
1141
1142}
1143
1144function tabDropdownStyle() {
1145    var screen_w = $(window).width();
1146    if (screen_w < 768) {
1147        //if ($(".dropdown-toggle").length <= 0) {
1148            var tab_header = $('.tab-dropdown .nav-tabs a.active').text();
1149        //    $('.tab-dropdown').addClass('dropdown');
1150        $('.tab-dropdown .tab_dropdown_title').html(tab_header + '<span class="caret"></span>');
1151        //    //$('.tab-dropdown ul').before('<button class="btn btn-primary dropdown-toggle tab_dropdown_title w-100" type="button" data-bs-toggle="dropdown" id="dropdownTab" aria-expanded="false">' + tab_header + '<span class="caret"></span></button>');
1152        //    $(".tab-dropdown ul").addClass("dropdown-menu");
1153            $(".tab-dropdown .dropdown-menu li").click(function () {
1154                var dropdown_select = jQuery(this).find("a").text();
1155                $('.tab_dropdown_title').html(dropdown_select + '<span class="caret"></span>');
1156
1157            });
1158
1159        //}
1160    } else {
1161        //$(".dropdown-toggle").remove();
1162        //$('.tab-dropdown').removeClass("dropdown");
1163        //$(".tab-dropdown ul").removeClass("dropdown-menu");
1164
1165    }
1166}
1167
1168function fixAccordion() {
1169    $('.accordion-list-cont').on('shown.bs.collapse', function (e) {
1170        var $panel = $(this).closest('.accordion-list-item');
1171        $('html,body').animate({
1172            scrollTop: $panel.offset().top - $(".header .navbar").outerHeight()
1173        }, 'fast');
1174    });
1175}
1176
1177
1178function exeModal() {
1179    //toast
1180    $(".btn-modal").click(function (e) {
1181        e.preventDefault();
1182        $('#myModal').modal('hide');
1183        if ($('.toast').length > 0) {
1184            $('.toast').toast('show');
1185        }
1186    });
1187}
1188
1189
1190//localstorage 
1191function setWithExpiry(key, value, ttl) {
1192    const now = new Date()
1193
1194    // `item` is an object which contains the original value
1195    // as well as the time when it's supposed to expire
1196    const item = {
1197        value: value,
1198        expiry: now.getTime() + ttl,
1199    }
1200    localStorage.setItem(key, JSON.stringify(item))
1201
1202
1203    //console.log(localStorage.getItem(key));
1204}
1205function getWithExpiry(key) {
1206    const itemStr = localStorage.getItem(key)
1207    // if the item doesn't exist, return null
1208    if (!itemStr) {
1209        return null
1210    }
1211    const item = JSON.parse(itemStr)
1212    const now = new Date()
1213    // compare the expiry time of the item with the current time
1214
1215    if (now.getTime() > item.expiry) {
1216        // If the item is expired, delete the item from storage
1217        // and return null
1218
1219        //console.log("EXPIRED");
1220        localStorage.removeItem(key)
1221        return null
1222    }
1223
1224    //console.log(item.value);
1225
1226    return item.value
1227}
1228
1229
1230/*** 驗證 email 格式 ***/
1231function isEmail(strEmail) {
1232    if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/) != -1)
1233        return true;
1234    else
1235        return false;
1236}
1237
1238
1239/*********** share ************/
1240var thisUrl = window.location.href;
1241var windowSize = "height=500,width=600";
1242var thisTitle = document.title;
1243function shareTo(target, currUrl = "") {
1244
1245    if (currUrl === "") {
1246        currUrl = thisUrl;
1247    }
1248
1249    switch (target) {
1250        case "fb":
1251            window.open('http://www.facebook.com/share.php?u='.concat(encodeURIComponent(currUrl)), '', config = windowSize);
1252            break;
1253        case "line":
1254            window.open('https://lineit.line.me/share/ui?url=' + encodeURIComponent(currUrl) + '&text=' + encodeURIComponent(document.title), '_blank', config = windowSize);
1255            break;
1256        case "twitter":
1257            window.open('http://twitter.com/home/?status='.concat(encodeURIComponent(document.title)).concat(' ').concat(encodeURIComponent(currUrl)), '', config = windowSize);
1258            break;
1259        case "mail":
1260            window.location = "mailto:?subject=" + thisTitle + "&body=" + thisTitle + currUrl, '', config = windowSize;
1261            break;
1262        case "linkedin":
1263            window.open('https://www.linkedin.com/shareArticle?mini=true&url='.concat(encodeURIComponent(currUrl)).concat('&title=').concat(encodeURIComponent(document.title)).concat('&summary=').concat(encodeURIComponent(document.title)).concat('&source=LinkedIn').concat(' '), '', config = windowSize);
1264            break;
1265    }
1266}
1267
1268/**=============  sweet alert =============**/
1269function msgbox(html, icon = '', url = '') {
1270    Swal.fire({
1271        icon: icon,
1272        html: html,
1273        confirmButtonText: '關閉',
1274        onClose: () => {
1275            if (url != '') {
1276                window.location = url;
1277            }
1278        }
1279    });
1280}
1281
1282function msgtop(html, icon = 'success') {
1283    const Toast = Swal.mixin({
1284        toast: true,
1285        position: 'top-end',
1286        showConfirmButton: false,
1287        timer: 3000,
1288        heightAuto: false,
1289        timerProgressBar: true,
1290        onOpen: (toast) => {
1291            toast.addEventListener('mouseenter', Swal.stopTimer)
1292            toast.addEventListener('mouseleave', Swal.resumeTimer)
1293        }
1294    })
1295
1296    Toast.fire({
1297        icon: icon,
1298        html: '<div class="swal2-toast-cus">' + html + '</div>'
1299    })
1300}
1301
1302var mctmp = '0';
1303function msgconfirm(html, btn, icon = 'question') {
1304    if (mctmp == '0') {
1305        Swal.fire({
1306            html: html,
1307            icon: icon,
1308            showCancelButton: true,
1309            confirmButtonText: '<i class="fas fa-check"></i> 確定',
1310            cancelButtonText: '<i class="fas fa-times"></i> 取消'
1311        }).then((result) => {
1312            if (result.value) {
1313                mctmp = '1';
1314                if ($(btn)[0].hasAttribute('href')) {
1315                    var href = $(btn).attr('href');
1316                    window.location.href = href;
1317                } else {
1318                    $(btn).click();
1319                }
1320            }
1321        })
1322        mctmp = '0';
1323        return false;
1324    } else {
1325        mctmp = '0';
1326        return true;
1327    }
1328}
1329
1330//======= 購物車增減數字 =======
1331function qtyadd(A) {
1332    event.preventDefault();
1333    var qtyInput = $(A).parents(".input-group").children(".qty-quantity");
1334
1335    $(qtyInput).val((parseInt($(qtyInput).val()) + 1).toString());
1336}
1337
1338function qtyminus(B) {
1339    event.preventDefault();
1340    var qtyInput = $(B).parents(".input-group").children(".qty-quantity");
1341    if ((parseInt($(qtyInput).val())) < 2) {
1342        $(qtyInput).val("2");
1343    }
1344    $(qtyInput).val((parseInt($(qtyInput).val()) - 1).toString());
1345
1346}
1347
1348//============  檢查只能輸入英、數字  ==============
1349function ValidateCNWord(value) {
1350    var re = /[\W]/g;
1351    if (!re.test(value)) {
1352        return true;
1353    } else {
1354        return false;
1355    }
1356}
1357
1358
1359
1360//============  地址  ==============
1361function getAddressList(value,obj,drop) {
1362
1363    var nPostObj = $(obj).parents(".address-box").find(".postObj");
1364    
1365    if (drop === 'city') {
1366        var nAreaObj = $(obj).parents(".address-box").find(".areaObj");
1367        
1368        nPostObj.val("");
1369        
1370        $.get(rootUrl + "api/RegionData/" + value + "." + $(".nation-val").val(), function () {
1371            //alert("success");
1372        }).done(function (data) {
1373            if (data) {
1374                var dataList = data.addressdata;
1375                nAreaObj.html("");
1376                nAreaObj.append("<option value=''></option>")
1377                $.each(dataList, function (index, item) {
1378                    //alert(index + ": " + value);
1379                    nAreaObj.append("<option value='" + item.value + "/" + item.zip + "'>" + item.text + "</option>");
1380                });
1381            } else {
1382                nAreaObj.html("");
1383            }
1384        }).fail(function () {
1385            //reject('Error');
1386        });
1387    } else {
1388        //area to zip
1389        if (value !== "") {
1390            nPostObj.val(value.split('/')[1]);
1391
1392        } else {
1393            nPostObj.val("");
1394        }
1395        
1396    }
1397    
1398
1399}
1400
1401
1402function privateCookie() {
1403    $("body").addClass("cookie_agree");
1404    $(".cookie.agree a.agree-btn").click(function (e) {
1405        e.preventDefault();
1406        $.get(rootUrl + "page/_uc/agree.aspx", function (data) {
1407            $(".cookie.agree").slideUp();
1408            $("body").removeClass("cookie_agree");
1409            $("body .footer .footer_content").css("padding-bottom", 10);
1410        });
1411    });
1412
1413    pushAgreeBox($(".cookie.agree"));
1414    $(window).resize(function () { pushAgreeBox($(".cookie.agree")); });
1415}
1416
1417function pushAgreeBox(t) {
1418    var winW = $(window).width(),
1419        pushH = t.outerHeight();
1420    $("body.cookie_agree .footer .footer_content").css("padding-bottom", (pushH + 10));
1421}
1422function setPageBodyClass(para, value) {
1423    (value) ? $("body").addClass(para + "_" + value) : "";
1424}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.