Blame view

website/assets/js/main.js 8.42 KB
1
(function ($) {
wangtao authored
2
    "use strict";
3 4 5 6


    // Loading Box (Preloader)
    function handlePreloader() {
wangtao authored
7 8 9 10 11
        setTimeout(function (){
            if ($('.preloader').length) {
                $('.preloader').delay(200).fadeOut(500);
            }
        },1000);
12 13 14 15 16 17 18 19 20 21 22 23
    }


    // Header Style and Scroll to Top
    function headerStyle() {
        if ($('.main-header').length) {
            var windowpos = $(window).scrollTop();
            var siteHeader = $('.main-header');
            var scrollLink = $('.scroll-top');
            if (windowpos >= 250) {
                siteHeader.addClass('fixed-header');
                scrollLink.fadeIn(300);
24 25 26
                //lsq 设置滚动之后的logo图片 2022-09-20
                $('.logo-outer .hg-logo').attr('src','assets/img/logo.png');
                $('.navigation').removeClass('navigation-white');
27 28 29
            } else {
                siteHeader.removeClass('fixed-header');
                scrollLink.fadeOut(300);
30
                //lsq 设置置顶之后的logo图片 2022-09-20
31 32
                let path=window.location.hash;
                let pathArr=path.split('/');
33
                if(pathArr.length>2 && window.location.hash.indexOf('#/about')==-1){
34 35 36 37 38 39 40
                    $('.logo-outer .hg-logo').attr('src','assets/img/logo.png');
                    $('.navigation').removeClass('navigation-white');
                }else{
                    $('.logo-outer .hg-logo').attr('src','assets/img/logo-footer.png');
                    $('.navigation').addClass('navigation-white');
                }
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
            }
        }
    }

    headerStyle();

    // dropdown menu

    var mobileWidth = 991;
    var navcollapse = $('.navigation li.dropdown');

    $(window).on('resize', function () {
        navcollapse.children('ul').hide();
    });

    navcollapse.hover(function () {
        if ($(window).innerWidth() >= mobileWidth) {
            $(this).children('ul').stop(true, false, true).slideToggle(300);
            $(this).children('.megamenu').stop(true, false, true).slideToggle(300);
        }
    });


    //Submenu Dropdown Toggle
    if ($('.navigation li.dropdown ul').length) {
        $('.navigation li.dropdown').append('<div class="dropdown-btn"><span class="fa fa-angle-right"></span></div>');

        //Dropdown Button
        $('.navigation li.dropdown .dropdown-btn').on('click', function () {
            $(this).prev('ul').slideToggle(500);
            $(this).prev('.megamenu').slideToggle(800);
        });

        //Disable dropdown parent link
        $('.navigation li.dropdown > a').on('click', function (e) {
            e.preventDefault();
        });
    }

    //Submenu Dropdown Toggle
    if ($('.main-header .main-menu').length) {
        $('.main-header .main-menu .navbar-toggle').on('click', function () {
            $(this).prev().prev().next().next().children('li.dropdown').hide();
        });

    }
    // End Main menu

    new WOW().init();
wangtao authored
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
    /* Fact Counter + Text Count */
    if ($('.success-box').length) {
        $('.success-box').appear(function () {

            var $t = $(this),
                n = $t.find(".count-text").attr("data-stop"),
                r = parseInt($t.find(".count-text").attr("data-speed"), 10);

            if (!$t.hasClass("counted")) {
                $t.addClass("counted");
                $({
                    countNum: $t.find(".count-text").text()
                }).animate({
                    countNum: n
                }, {
                    duration: r,
                    easing: "linear",
                    step: function () {
                        $t.find(".count-text").text(Math.floor(this.countNum));
                    },
                    complete: function () {
                        $t.find(".count-text").text(this.countNum);
                    }
                });
            }

        }, {
            accY: 0
        });
    }
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158


    /*========== Start Portfolio isotop Js ==========*/
    // isotop
    // init Isotope
    var $grid = $('.custom-row').isotope({
        itemSelector: '.grid-item',
        percentPosition: true,
        masonry: {
            // use outer width of grid-sizer for columnWidth
            columnWidth: 1,
        }
    });


    // magnificPopup
    if ($('.projects-popup-link').length) {
        $('.projects-popup-link').magnificPopup({
            type: 'image',
            gallery: {
                enabled: true
            },
        });
    }


    /*============================== start video element     ========================================*/

    // magnificPopup start
    $('.vedio-play').magnificPopup({
        type: 'video',
    });
    // magnificPopup end


    //service-carousel
    if ($('.service-carousel').length) {
        $('.service-carousel').owlCarousel({
wangtao authored
159
            loop: true,
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
            items: 3,
            margin: 20,
            nav: false,
            dots: true,
            active: true,
            dotsEach: 2,
            smartSpeed: 1000,
            autoplay: 5000,
            responsive: {
                0: {
                    items: 1,
                },
                575: {
                    items: 1,
                },
                768: {
                    items: 2,
                },
                992: {
                    items: 3,
                },
                1200: {
                    items: 3,
                }
            }
        });
    }


    //team-carousel
    if ($('.team-carousel').length) {
        $('.team-carousel').owlCarousel({
wangtao authored
192
            loop: true,
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
            items: 3,
            margin: 20,
            nav: true,
            dots: false,
            active: true,
            dotsEach: 2,
            smartSpeed: 1000,
            autoplay: 5000,
            navText: ['<span class="flaticon-left-arrow"></span>', '<span class="flaticon-right-arrow"></span>'],
            responsive: {
                0: {
                    items: 1,
                },
                575: {
                    items: 1,
                },
                768: {
                    items: 2,
                },
                992: {
                    items: 3,
                },
                1200: {
                    items: 3,
                }
            }
        });
    }


    // Scroll to a Specific Div
    if ($('.scroll-to-target').length) {
        $(".scroll-to-target").on('click', function () {
            var target = $(this).attr('data-target');
            // animate
            $('html, body').animate({
                scrollTop: $(target).offset().top
            }, 1000);

        });
    }
wangtao authored
234 235

236 237 238 239 240 241 242 243 244 245
    $('.testi-image-wrap').slick({
        slidesToShow: 3,
        slidesToScroll: 1,
        asNavFor: '.testi-content-wrap',
        dots: false,
        focusOnSelect: true,
        prevArrow: '<i class="flaticon-left-arrow left"></i>',
        nextArrow: '<i class="flaticon-right-arrow right"></i>',
        responsive: [
            {
wangtao authored
246 247 248 249
                breakpoint: 500,
                settings: {
                    slidesToShow: 1,
                }
250 251 252
            },
        ]
    });
wangtao authored
253 254

255 256 257 258 259 260 261 262
    $('.testi-content-wrap').slick({
        asNavFor: '.testi-image-wrap',
        slidesToShow: 1,
        slidesToScroll: 1,
        arrows: false,
        fade: true,
        dots: false,
    });
wangtao authored
263 264

265 266 267 268 269 270 271 272 273 274
    $('.testimonial-two-wrap').slick({
        slidesToShow: 1,
        slidesToScroll: 1,
        arrows: true,
        fade: true,
        dots: false,
        autoplay: true,
        prevArrow: '<i class="flaticon-left-arrow left"></i>',
        nextArrow: '<i class="flaticon-right-arrow right"></i>',
    });
wangtao authored
275
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291

    /* ==========================================================================
       When document is scroll, do
       ========================================================================== */

    $(window).on('scroll', function () {
        headerStyle();
    });

    /* ==========================================================================
       When document is loaded, do
       ========================================================================== */

    $(window).on('load', function () {
        handlePreloader();
wangtao authored
292 293 294 295 296 297 298 299 300 301 302 303
        /*========== Start Portfolio isotop Js ==========*/
        // isotop
        // init Isotope
        var $grid = $('.custom-row').isotope({
            itemSelector: '.grid-item',
            percentPosition: true,
            masonry: {
                // use outer width of grid-sizer for columnWidth
                columnWidth: 1,
            }
        });
304 305 306 307

    });

wangtao authored
308
})(jQuery);