PageSourceSearch

https://mentalhealth4all.tw/assets/js/main.js

js mentalhealth4all.tw collected 2026-10-08 09:22:19 UTC 23,611 bytes, 860 lines download raw bytes

1(function ($) {
2    "use strict";
3
4    /*--
5        Commons Variables
6    -----------------------------------*/
7    var $window = $(window),
8        $body = $('body');
9
10    /*--
11        Custom script to call Background
12        Image & Color from html data attribute
13    -----------------------------------*/
14    $('[data-bg-image]').each(function () {
15        var $this = $(this),
16            $image = $this.data('bg-image');
17        $this.css('background-image', 'url(' + $image + ')');
18    });
19    $('[data-bg-color]').each(function () {
20        var $this = $(this),
21            $color = $this.data('bg-color');
22        $this.css('background-color', $color);
23    });
24
25    /*------------------------------
26        Parallax Motion Animation 
27    -------------------------------*/
28    $('.scene').each(function () {
29        new Parallax($(this)[0]);
30    });
31
32    /*--
33        Header Sticky
34    -----------------------------------*/
35    $window.on('scroll', function () {
36        if ($window.scrollTop() > 350) {
37            $('.sticky-header').addClass('is-sticky');
38        } else {
39            $('.sticky-header').removeClass('is-sticky');
40        }
41    });
42
43    /*--
44        Off Canvas Function
45    -----------------------------------*/
46    $('.header-mobile-menu-toggle, .mobile-menu-close').on('click', '.toggle', function () {
47        $body.toggleClass('mobile-menu-open');
48    });
49    $('.site-mobile-menu').on('click', '.menu-toggle', function (e) {
50        e.preventDefault();
51        var $this = $(this);
52        if ($this.siblings('.sub-menu:visible, .mega-menu:visible').length) {
53            $this.siblings('.sub-menu, .mega-menu').slideUp().parent().removeClass('open').find('.sub-menu, .mega-menu').slideUp().parent().removeClass('open');
54        } else {
55            $this.siblings('.sub-menu, .mega-menu').slideDown().parent().addClass('open').siblings().find('.sub-menu, .mega-menu').slideUp().parent().removeClass('open');
56        }
57    });
58
59
60    $('.header-search-toggle').on('click', function (e) {
61        e.preventDefault();
62        $(this).siblings('.header-search-form, .header-search-form-2').slideToggle().parent().toggleClass('open');
63    });
64
65    $('.header-fs-search-toggle').on('click', function () {
66        $('#fullscreen-search').addClass('open');
67    });
68    $('.fullscreen-search-close').on('click', '.toggle', function () {
69        $('#fullscreen-search').removeClass('open');
70    });
71
72    $body.on('click', function (e) {
73        if (!$(e.target).closest('.header-search').length && $window.width() < 768) {
74            $('.header-search-form, .header-search-form-2').slideUp().parent().removeClass('open');
75        }
76        if (!$(e.target).closest('.site-main-mobile-menu-inner').length && !$(e.target).closest('.header-mobile-menu-toggle').length) {
77            $body.removeClass('mobile-menu-open');
78        }
79    });
80
81
82    $('.max-popup-close').on('click', function () {
83        var $this = $(this),
84            $popup = $this.closest('#max-popup'),
85            $dialog = $this.parent('.max-popup-dialog');
86        $popup.addClass('close');
87        $dialog.removeClass('fadeInUp').addClass('fadeOutUp');
88    });
89
90
91    /* -----------------------------------
92        Selectric Fake Select Plugin 
93    -------------------------------------*/
94    $('.selectric').selectric({
95        arrowButtonMarkup: '<span class="arrow"><i class="far fa-angle-down"></i></span>',
96        disableOnMobile: false,
97    });
98    $('.sort-by').selectric({
99        arrowButtonMarkup: '<span class="arrow"><i class="far fa-angle-down"></i></span>',
100        labelBuilder: '<i class="far fa-align-left"></i> Sort By: <span>{text}</span>',
101        disableOnMobile: false,
102    });
103
104    /* ----------------------------
105        AOS Scroll Animation 
106    -------------------------------*/
107    AOS.init({
108        offset: 80,
109        duration: 1000,
110        once: true,
111        easing: 'ease',
112    });
113
114
115    /*----------------------------------------
116         SVG Inject With Vivus(After Inject) 
117    ------------------------------------------*/
118    SVGInject(document.querySelectorAll("img.svgInject"), {
119        makeIdsUnique: true,
120        afterInject: function (img, svg) {
121            new Vivus(svg, {
122                duration: 80
123            });
124        }
125    });
126    /* Vivus On Hover */
127    $('[data-vivus-hover]').hover(function () {
128        var svg = $(this).find('svg')[0];
129        new Vivus(svg, {
130            duration: 50
131        });
132    })
133
134    /*----------------------------
135        Justified Gallery 
136    ------------------------------*/
137    var $justifiedGallery = $('.justified-gallery');
138
139    $justifiedGallery.imagesLoaded(function () {
140        $justifiedGallery.justifiedGallery({
141            rowHeight: 440,
142            maxRowHeight: null,
143            margins: 10,
144            border: 0,
145            lastRow: 'nojustify'
146        });
147        
148    });
149
150    /*-----------------------
151        CounterUp JS 
152    -------------------------*/
153    $('.counter').counterUp({
154        time: 2000
155    });
156
157    /*--------------------------------
158        Swiper Slider Activation JS 
159    ----------------------------------*/
160     // Home 7 Slider
161     var intro7Slider = new Swiper('.intro7-slider', {
162        loop: true,
163        speed: 750,
164        spaceBetween: 30,
165        effect: 'fade',
166        pagination: {
167            el: '.home7-slider-pagination',
168            clickable: true,
169        }
170        //autoplay: {},
171    });
172
173    // Home 8 Slider
174    var intro8Slider = new Swiper('.intro8-slider', {
175        loop: true,
176        speed: 750,
177        spaceBetween: 30,
178        effect: 'fade',
179        pagination: {
180            el: '.home8-slider-pagination',
181            clickable: true,
182        },
183        navigation: {
184            nextEl: '.home8-slider-next',
185            prevEl: '.home8-slider-prev',
186        },
187        //autoplay: {},
188    });
189
190    // Home 11 Slider
191    var intro11Slider = new Swiper('.intro11-slider', {
192        loop: true,
193        speed: 750,
194        spaceBetween: 30,
195        effect: 'fade',
196        navigation: {
197            nextEl: '.home11-slider-next',
198            prevEl: '.home11-slider-prev',
199        },
200        //autoplay: {},
201    });
202
203    // Banner Slider
204    var bannerSlider = new Swiper('.banner-slider', {
205        loop: true,
206        speed: 750,
207        spaceBetween: 30,
208        effect: 'fade',
209        navigation: {
210            nextEl: '.banner-slider-next',
211            prevEl: '.banner-slider-prev',
212        },
213        //autoplay: {},
214    });
215
216    // Health Testimonial Slider
217    var testimonialSlider = new Swiper('.health-testimonial-slider', {
218        loop: true,
219        speed: 750,
220        spaceBetween: 30,
221        pagination: {
222            el: '.swiper-pagination',
223            type: 'bullets',
224            clickable: true,
225        }
226        //autoplay: {},
227    });
228
229    // Testimonial Slider
230    var testimonialSlider = new Swiper('.testimonial-slider', {
231        watchSlidesVisibility: true,
232        loop: true,
233        spaceBetween: 50,
234        slidesPerView: 2,
235        autoHeight: true,
236        pagination: {
237            el: '.swiper-pagination',
238            type: 'bullets',
239            clickable: true,
240          },
241        breakpoints: {
242            320: {
243                slidesPerView: 1
244            },
245            992: {
246                slidesPerView: 2
247            }
248        }
249    })
250
251    // Testimonial Slider Two
252    var testimonialSlider = new Swiper('.testimonial-slider-two', {
253        slidesPerView : 1,
254        slidesPerGroup: 1,
255        centeredSlides: true,
256        loop: true,
257        speed: 1000,
258        spaceBetween : 50,
259        autoHeight: true,
260        pagination: {
261            el: '.swiper-pagination',
262            type: 'bullets',
263            clickable: true
264        },
265        breakpoints: {
266            1499:{
267                slidesPerView : 3
268            },
269
270            991:{
271                slidesPerView : 2
272            },
273
274            767:{
275                slidesPerView : 1
276
277            },
278
279            575:{
280                slidesPerView : 1
281            }
282        }
283    });
284
285    // Testimonial Slider Three
286    var testimonialSlider = new Swiper('.testimonial-slider-three', {
287        slidesPerView : 1,
288        slidesPerGroup: 1,
289        loop: true,
290        speed: 1000,
291        autoHeight: true,
292        spaceBetween : 30,
293        navigation: {
294            nextEl: '.swiper-button-next',
295            prevEl: '.swiper-button-prev',
296        },
297        pagination: {
298            el: '.swiper-pagination-t0',
299            type: 'bullets',
300            clickable: true
301        },
302        breakpoints: {
303            1499:{
304                slidesPerView : 1
305            },
306
307            991:{
308                slidesPerView : 1
309            },
310
311            767:{
312                slidesPerView : 1
313
314            },
315
316            575:{
317                slidesPerView : 1
318            }
319        }
320    });
321
322    // Testimonial Slider Vertical
323    var testimonialSlider = new Swiper('.testimonial-slider-vertical', {
324        slidesPerView : 1,
325        slidesPerGroup: 1,
326        effect: 'coverflow',
327        loop: true,
328        speed: 1000,
329        spaceBetween : 30,
330        pagination: {
331            el: '.swiper-pagination',
332            type: 'bullets',
333            clickable: true,
334        },
335        breakpoints: {
336            1499:{
337                slidesPerView : 1
338            },
339
340            991:{
341                slidesPerView : 1
342            },
343
344            767:{
345                slidesPerView : 1
346
347            },
348
349            575:{
350                slidesPerView : 1
351            }
352        }
353    });
354
355    // Home 5 Testimonial Slider
356    var testimonialSlider = new Swiper('.h5-testimonial-slider', {
357        watchSlidesVisibility: true,
358        loop: true,
359        spaceBetween: 30,
360        slidesPerView: 3,
361        pagination: {
362            el: '.swiper-pagination',
363            type: 'bullets',
364            clickable: true,
365          },
366        breakpoints: {
367            1200: {
368                slidesPerView: 3
369            },
370            992: {
371                slidesPerView: 2
372            },
373            768: {
374                slidesPerView: 2
375            },
376            576: {
377                slidesPerView: 1
378            },
379            320: {
380                slidesPerView: 1
381            }
382        }
383    })
384
385
386    // Home 8 Testimonial Slider
387    var testimonialSlider = new Swiper('.testimonial-slider-8', {
388        watchSlidesVisibility: true,
389        loop: true,
390        spaceBetween: 30,
391        slidesPerView: 1,
392        pagination: {
393            el: '.swiper-pagination',
394            type: 'bullets',
395            clickable: true,
396          },
397    })
398
399    // Testimonial Slider Three Item
400    var testimonialSlider = new Swiper('.testimonial-slider-three-item', {
401        watchSlidesVisibility: true,
402        loop: true,
403        autoHeight: true,
404        spaceBetween: 30,
405        slidesPerView: 3,
406        navigation: {
407            nextEl: '.circle-slider-next',
408            prevEl: '.circle-slider-prev',
409        },
410        breakpoints: {
411            1200: {
412                slidesPerView: 3
413            },
414            992: {
415                slidesPerView: 2
416            },
417            768: {
418                slidesPerView: 2
419            },
420            576: {
421                slidesPerView: 1
422            },
423            320: {
424                slidesPerView: 1
425            }
426        }
427    })
428
429    // Motivation Testimonial Slider
430    var testimonialSlider = new Swiper('.motivation-testimonial-slider', {
431        watchSlidesVisibility: true,
432        loop: true,
433        pagination: {
434          el: '.swiper-pagination',
435          type: 'fraction',
436        },
437        navigation: {
438          nextEl: '.swiper-button-next',
439          prevEl: '.swiper-button-prev',
440        },
441      });
442
443    // Brand Carousel Slider
444    var brandSlider = new Swiper('.brand-carousel', {
445        watchSlidesVisibility: true,
446        loop: true,
447        spaceBetween: 30,
448        slidesPerView: 6,
449        breakpoints: {
450            1200: {
451                slidesPerView: 6
452            },
453            992: {
454                slidesPerView: 5
455            },
456            768: {
457                slidesPerView: 5
458            },
459            576: {
460                slidesPerView: 4
461            },
462            320: {
463                slidesPerView: 2
464            }
465        }
466    })
467
468    // Courses Slider
469    var courseSlider = new Swiper('.courses-slider', {
470        watchSlidesVisibility: true,
471        loop: true,
472        spaceBetween: 30,
473        slidesPerView: 3,
474        slidesPerGroup: 3,
475        autoHeight: true,
476        pagination: {
477            el: '.swiper-pagination',
478            type: 'bullets',
479            clickable: true,
480          },
481        breakpoints: {
482            1200: {
483                slidesPerView: 3
484            },
485            992: {
486                slidesPerView: 3
487            },
488            768: {
489                slidesPerView: 2
490            },
491            576: {
492                slidesPerView: 1
493            },
494            320: {
495                slidesPerView: 1
496            }
497        }
498    })
499
500    // Speaker Slider
501    var speakerSlider = new Swiper('.speaker-slider', {
502        watchSlidesVisibility: true,
503        loop: false,
504        spaceBetween: 30,
505        slidesPerView: 5,
506        breakpoints: {
507            1200: {
508                slidesPerView: 5
509            },
510            992: {
511                slidesPerView: 4
512            },
513            768: {
514                slidesPerView: 3
515            },
516            576: {
517                slidesPerView: 2
518            },
519            320: {
520                slidesPerView: 1
521            }
522        }
523    })
524
525    // Event Slider
526    var eventSlider = new Swiper('.event-slider', {
527        watchSlidesVisibility: true,
528        loop: true,
529        spaceBetween: 30,
530        slidesPerView: 3,
531        slidesPerGroup: 1,
532        autoHeight: true,
533        pagination: {
534            el: '.swiper-pagination',
535            type: 'bullets',
536            clickable: true,
537          },
538        breakpoints: {
539            1200: {
540                slidesPerView: 3
541            },
542            992: {
543                slidesPerView: 3
544            },
545            768: {
546                slidesPerView: 2
547            },
548            576: {
549                slidesPerView: 1
550            },
551            320: {
552                slidesPerView: 1
553            }
554        }
555    })
556
557    // Event Slider Four Item
558    var eventSlider = new Swiper('.event-slider-four-item', {
559        watchSlidesVisibility: true,
560        loop: true,
561        spaceBetween: 30,
562        slidesPerView: 4,
563        slidesPerGroup: 1,
564        autoHeight: true,
565        pagination: {
566            el: '.swiper-pagination',
567            type: 'bullets',
568            clickable: true,
569          },
570        breakpoints: {
571            1200: {
572                slidesPerView: 4
573            },
574            992: {
575                slidesPerView: 3
576            },
577            768: {
578                slidesPerView: 2
579            },
580            576: {
581                slidesPerView: 1
582            },
583            320: {
584                slidesPerView: 1
585            }
586        }
587    })
588
589    // Service Slider
590    var serviceSlider = new Swiper('.service-slider', {
591        watchSlidesVisibility: true,
592        loop: true,
593        spaceBetween: 30,
594        slidesPerView: 3,
595        slidesPerGroup: 1,
596        autoHeight: true,
597        pagination: {
598            el: '.swiper-pagination',
599            type: 'bullets',
600            clickable: true,
601          },
602        breakpoints: {
603            320: {
604                slidesPerView: 1
605            },
606            768: {
607                slidesPerView: 2
608            },
609            992: {
610                slidesPerView: 2
611            },
612            1200: {
613                slidesPerView: 3
614            }
615        }
616    })
617
618    // Cooking About Slider
619    var cookingSlider = new Swiper('.cooking-about-slider', {
620        watchSlidesVisibility: true,
621        loop: true,
622        spaceBetween: 30,
623        slidesPerView: 1,
624        slidesPerGroup: 1,
625        pagination: {
626            el: '.swiper-pagination',
627            type: 'bullets',
628            clickable: true,
629          },
630    })
631
632    /*--
633        Isotpe
634    -----------------------------------*/
635    var $isotopeGrid = $('.isotope-grid');
636    var $isotopeFilter = $('.isotope-filter');
637    $isotopeGrid.imagesLoaded(function () {
638        $isotopeGrid.isotope({
639            itemSelector: '.grid-item',
640            masonry: {
641                columnWidth: '.grid-sizer'
642            }
643        });
644        AOS.refresh();
645    });
646    $isotopeFilter.on('click', 'button', function () {
647        var $this = $(this),
648            $filterValue = $this.attr('data-filter'),
649            $targetIsotop = $this.parent().data('target');
650        $this.addClass('active').siblings().removeClass('active');
651        $($targetIsotop).isotope({
652            filter: $filterValue
653        });
654    });
655
656    /*--
657        ion Range Slider
658    -----------------------------------*/
659    $(".price-range").ionRangeSlider({
660        skin: "maxCoach",
661        hide_min_max: true,
662        type: 'double',
663        prefix: "$",
664    });
665
666
667    /*--
668        Jarallax Active
669    -----------------------------------*/
670    $('.jarallax').jarallax({
671        speed: 0.2
672    });
673
674    /*--
675        Rellax Active
676    -----------------------------------*/
677    var rellax = new Rellax('.rellax');
678
679    /*------------------------
680        Sticky Sidebar Active
681    -------------------------*/
682    $('#sticky-sidebar').theiaStickySidebar({
683        // Settings
684        additionalMarginTop: 120
685    });
686
687
688    /*----------------------------------- 
689        Count Down Active 
690    ----------------------------------*/  
691    $('[data-countdown]:not(.pro-countdown-1,.pro-countdown-2)').each(function() {
692        var $this = $(this), finalDate = $(this).data('countdown');
693        $this.countdown(finalDate, function(event) {
694            $this.html(event.strftime('<div class="single-countdown-box"><span>%D</span>Day</div><div class="single-countdown-box"><span>%H</span>Hours</div><div class="single-countdown-box"><span>%M</span>Mins</div><div class="single-countdown-box"><span>%S</span>Secs</div>'));
695        });
696    });
697    $('[data-countdown].pro-countdown-1').each(function() {
698        var $this = $(this), finalDate = $(this).data('countdown');
699        $this.countdown(finalDate, function(event) {
700            $this.html(event.strftime('<div class="single-countdown-box-1"><span>%D</span>Day</div><div class="single-countdown-box-1"><span>%H</span>Hours</div><div class="single-countdown-box-1"><span>%M</span>Mins</div><div class="single-countdown-box-1"><span>%S</span>Secs</div>'));
701        });
702    });
703    $('[data-countdown].pro-countdown-2').each(function() {
704        var $this = $(this), finalDate = $(this).data('countdown');
705        $this.countdown(finalDate, function(event) {
706            $this.html(event.strftime('<div class="countdown-item before-none"><span>%D</span></div><div class="countdown-item"><span>%H</span></div><div class="countdown-item"><span>%M</span></div><div class="countdown-item"><span>%S</span></div>'));
707        });
708    });
709    
710    /*----- 
711        Quantity
712    --------------------------------*/
713    $('.pro-qty').prepend('<button class="dec qtybtn">-</button>');
714    $('.pro-qty').append('<button class="inc qtybtn">+</button>');
715    $('.qtybtn').on('click', function() {
716        var $button = $(this);
717        var oldValue = $button.parent().find('input').val();
718        if ($button.hasClass('inc')) {
719        var newVal = parseFloat(oldValue) + 1;
720        } else {
721        // Don't allow decrementing below zero
722        if (oldValue > 0) {
723            var newVal = parseFloat(oldValue) - 1;
724            } else {
725            newVal = 0;
726        }
727        }
728        $button.parent().find('input').val(newVal);
729    });
730
731    /*----- 
732	Shipping Form Toggle
733    --------------------------------*/ 
734    $('[data-shipping]').on('click', function(){
735        if( $('[data-shipping]:checked').length > 0 ) {
736            $('#shipping-form').slideDown();
737        } else {
738            $('#shipping-form').slideUp();
739        }
740    })
741        
742    /*----- 
743        Payment Method Select
744    --------------------------------*/
745    $('[name="payment-method"]').on('click', function(){
746        
747        var $value = $(this).attr('value');
748
749        $('.single-method p').slideUp();
750        $('[data-method="'+$value+'"]').slideDown();
751        
752    })
753
754    /*----- 
755        Animate Headline Active
756    --------------------------------*/
757    $('.headline-active').animatedHeadline({
758        animationType: 'rotate-2'
759    });
760
761    /*--
762        Magnific Popup
763    -----------------------------------*/
764    $('.video-popup').magnificPopup({
765        type: 'iframe'
766    });
767
768    /*--
769        Scroll Up
770    -----------------------------------*/
771    function scrollToTop() {
772        var $scrollUp = $('#scroll-top'),
773            $lastScrollTop = 0,
774            $window = $(window);
775
776        $window.on('scroll', function () {
777            var st = $(this).scrollTop();
778            if (st > $lastScrollTop) {
779                $scrollUp.removeClass('show');
780            } else {
781                if ($window.scrollTop() > 200) {
782                    $scrollUp.addClass('show');
783                } else {
784                    $scrollUp.removeClass('show');
785                }
786            }
787            $lastScrollTop = st;
788        });
789
790        $scrollUp.on('click', function (evt) {
791            $('html, body').animate({scrollTop: 0}, 600);
792            evt.preventDefault();
793        });
794    }
795    scrollToTop();
796
797
798    /*-------------------------
799        Ajax Contact Form 
800    ---------------------------*/
801    $(function() {
802
803        // Get the form.
804        var form = $('#contact-form');
805
806        // Get the messages div.
807        var formMessages = $('.form-messege');
808
809        // Set up an event listener for the contact form.
810        $(form).submit(function(e) {
811            // Stop the browser from submitting the form.
812            e.preventDefault();
813
814            // Serialize the form data.
815            var formData = $(form).serialize();
816
817            // Submit the form using AJAX.
818            $.ajax({
819                type: 'POST',
820                url: $(form).attr('action'),
821                data: formData
822            })
823            .done(function(response) {
824                // Make sure that the formMessages div has the 'success' class.
825                $(formMessages).removeClass('error');
826                $(formMessages).addClass('success');
827
828                // Set the message text.
829                $(formMessages).text(response);
830
831                // Clear the form.
832                $('#contact-form input,#contact-form textarea').val('');
833            })
834            .fail(function(data) {
835                // Make sure that the formMessages div has the 'error' class.
836                $(formMessages).removeClass('success');
837                $(formMessages).addClass('error');
838
839                // Set the message text.
840                if (data.responseText !== '') {
841                    $(formMessages).text(data.responseText);
842                } else {
843                    $(formMessages).text('Oops! An error occured and your message could not be sent.');
844                }
845            });
846        });
847
848    });
849
850    /*--
851        On Load Function
852    -----------------------------------*/
853    $window.on('load', function () {});
854
855    /*--
856        Resize Function
857    -----------------------------------*/
858    $window.resize(function () {});
859
860})(jQuery);

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.