script.js (19021B)
1 (function($) { 2 3 "use strict"; 4 5 6 7 function marginClc() { 8 if ($(".industries-covered .outer-box").length) { 9 var windowSize = $(window).width(); 10 11 if (windowSize >= 1200) { 12 var width = ($(window).width() - 1200), 13 margin = (width / 2); 14 $(".industries-covered .outer-box").css("margin-right", margin); 15 } 16 } 17 } 18 marginClc(); 19 20 //Hide Loading Box (Preloader) 21 function handlePreloader() { 22 if($('.loader-wrap').length){ 23 $('.loader-wrap').delay(1000).fadeOut(500); 24 } 25 TweenMax.to($(".loader-wrap .overlay"), 1.2, { 26 force3D: true, 27 left : "100%", 28 ease : Expo.easeInOut, 29 }); 30 } 31 32 //Event Countdown Timer 33 if($('.time-countdown').length){ 34 $('.time-countdown').each(function() { 35 var $this = $(this), finalDate = $(this).data('countdown'); 36 $this.countdown(finalDate, function(event) { 37 var $this = $(this).html(event.strftime('' + '<div class="counter-column"><span class="count">%D</span>Days</div> ' + '<div class="counter-column"><span class="count">%H</span>Hours</div> ' + '<div class="counter-column"><span class="count">%M</span>Minutes</div> ' + '<div class="counter-column"><span class="count">%S</span>Seconds</div>')); 38 }); 39 }); 40 } 41 42 if ($(".preloader-close").length) { 43 $(".preloader-close").on("click", function(){ 44 $('.loader-wrap').delay(200).fadeOut(500); 45 }) 46 } 47 48 function dynamicCurrentMenuClass(selector) { 49 let FileName = window.location.href.split('/').reverse()[0]; 50 51 selector.find('li').each(function () { 52 let anchor = $(this).find('a'); 53 if ($(anchor).attr('href') == FileName) { 54 $(this).addClass('current'); 55 } 56 }); 57 // if any li has .current elmnt add class 58 selector.children('li').each(function () { 59 if ($(this).find('.current').length) { 60 $(this).addClass('current'); 61 } 62 }); 63 // if no file name return 64 if ('' == FileName) { 65 selector.find('li').eq(0).addClass('current'); 66 } 67 } 68 69 // dynamic current class 70 let mainNavUL = $('.main-menu').find('.navigation'); 71 dynamicCurrentMenuClass(mainNavUL); 72 73 //Update Header Style and Scroll to Top 74 function headerStyle() { 75 if($('.main-header').length){ 76 var windowpos = $(window).scrollTop(); 77 var siteHeader = $('.main-header'); 78 var scrollLink = $('.scroll-to-top'); 79 var sticky_header = $('.main-header .sticky-header'); 80 if (windowpos > 100) { 81 siteHeader.addClass('fixed-header'); 82 sticky_header.addClass("animated slideInDown"); 83 scrollLink.fadeIn(300); 84 } else { 85 siteHeader.removeClass('fixed-header'); 86 sticky_header.removeClass("animated slideInDown"); 87 scrollLink.fadeOut(300); 88 } 89 } 90 } 91 92 headerStyle(); 93 94 //Submenu Dropdown Toggle 95 if($('.main-header li.menu-item-has-children ul').length){ 96 $('.main-header .navigation li.menu-item-has-children').append('<div class="dropdown-btn"><span class="fa fa-angle-right"></span></div>'); 97 } 98 99 //Hidden Sidebar 100 if($('.hidden-sidebar').length){ 101 102 var animButton = $(".sidemenu-nav-toggler"), 103 hiddenBar = $(".hidden-sidebar"), 104 navOverlay = $(".nav-overlay"), 105 hiddenBarClose = $(".hidden-sidebar-close"); 106 107 function showMenu() { 108 TweenMax.to(hiddenBar, 0.6, { 109 force3D: false, 110 left : "0", 111 ease : Expo.easeInOut 112 }); 113 hiddenBar.removeClass("close-sidebar"); 114 navOverlay.fadeIn(500); 115 } 116 117 function hideMenu() { 118 TweenMax.to(hiddenBar, 0.6, { 119 force3D: false, 120 left : "-480px", 121 ease : Expo.easeInOut 122 }); 123 hiddenBar.addClass("close-sidebar"); 124 navOverlay.fadeOut(500); 125 } 126 animButton.on("click", function() { 127 if (hiddenBar.hasClass("close-sidebar")) showMenu(); 128 else hideMenu(); 129 }); 130 navOverlay.on("click", function() { 131 hideMenu(); 132 }); 133 hiddenBarClose.on("click", function() { 134 hideMenu(); 135 }); 136 } 137 138 if ($('.nav-overlay').length) { 139 // / cursor / 140 var cursor = $(".nav-overlay .cursor"), 141 follower = $(".nav-overlay .cursor-follower"); 142 143 var posX = 0, 144 posY = 0; 145 146 var mouseX = 0, 147 mouseY = 0; 148 149 TweenMax.to({}, 0.016, { 150 repeat : -1, 151 onRepeat: function() { 152 posX += (mouseX - posX) / 9; 153 posY += (mouseY - posY) / 9; 154 155 TweenMax.set(follower, { 156 css: { 157 left: posX - 22, 158 top : posY - 22 159 } 160 }); 161 162 TweenMax.set(cursor, { 163 css: { 164 left: mouseX, 165 top : mouseY 166 } 167 }); 168 169 } 170 }); 171 172 $(document).on("mousemove", function(e) { 173 var scrollTop = window.pageYOffset || document.documentElement.scrollTop; 174 mouseX = e.pageX; 175 mouseY = e.pageY - scrollTop; 176 }); 177 $("button, a").on("mouseenter", function() { 178 cursor.addClass("active"); 179 follower.addClass("active"); 180 }); 181 $("button, a").on("mouseleave", function() { 182 cursor.removeClass("active"); 183 follower.removeClass("active"); 184 }); 185 $(".nav-overlay").on("mouseenter", function() { 186 cursor.addClass("close-cursor"); 187 follower.addClass("close-cursor"); 188 }); 189 $(".nav-overlay").on("mouseleave", function() { 190 cursor.removeClass("close-cursor"); 191 follower.removeClass("close-cursor"); 192 }); 193 } 194 195 //Mobile Nav Hide Show 196 if($('.mobile-menu').length){ 197 198 // $('.mobile-menu .menu-box').mCustomScrollbar(); 199 200 var mobileMenuContent = $('.main-header .nav-outer .main-menu').html(); 201 $('.mobile-menu .menu-box .menu-outer').append(mobileMenuContent); 202 $('.sticky-header .main-menu').append(mobileMenuContent); 203 204 //Dropdown Button 205 $('.mobile-menu li.menu-item-has-children .dropdown-btn').on('click', function() { 206 $(this).toggleClass('open'); 207 $(this).prev('ul').slideToggle(500); 208 }); 209 //Menu Toggle Btn 210 $('.mobile-nav-toggler').on('click', function() { 211 $('body').addClass('mobile-menu-visible'); 212 }); 213 214 //Menu Toggle Btn 215 $('.mobile-menu .menu-backdrop,.mobile-menu .close-btn,.scroll-nav li a').on('click', function() { 216 $('body').removeClass('mobile-menu-visible'); 217 }); 218 } 219 220 //Sidemenu Nav Hide Show 221 if($('.side-menu').length){ 222 223 $('.side-menu .menu-box').mCustomScrollbar(); 224 225 //Dropdown Button 226 $('.side-menu li.menu-item-has-children .dropdown-btn').on('click', function() { 227 $(this).toggleClass('open'); 228 $(this).prev('ul').slideToggle(500); 229 }); 230 231 $('body').addClass('side-menu-visible'); 232 //Menu Toggle Btn 233 $('.side-nav-toggler').on('click', function() { 234 $('body').addClass('side-menu-visible'); 235 }); 236 237 //Menu Toggle Btn 238 $('.side-menu .side-menu-resize').on('click', function() { 239 $('body').toggleClass('side-menu-visible'); 240 }); 241 242 //Menu Toggle Btn 243 $('.main-header .mobile-nav-toggler-two').on('click', function() { 244 $('body').addClass('side-menu-visible-s2'); 245 }); 246 247 //Menu Overlay 248 $('.main-header .side-menu-overlay').on('click', function() { 249 $('body').removeClass('side-menu-visible-s2'); 250 }); 251 } 252 253 //Search Popup 254 if($('#search-popup').length){ 255 256 //Show Popup 257 $('.search-toggler').on('click', function() { 258 $('#search-popup').addClass('popup-visible'); 259 }); 260 $(document).keydown(function(e){ 261 if(e.keyCode === 27) { 262 $('#search-popup').removeClass('popup-visible'); 263 } 264 }); 265 //Hide Popup 266 $('.close-search,.search-popup .overlay-layer').on('click', function() { 267 $('#search-popup').removeClass('popup-visible'); 268 }); 269 } 270 271 // Testimonial 272 var galleryThumbs = new Swiper('.testimonial-thumbs', { 273 loop : false, 274 spaceBetween : 10, 275 slidesPerView : 3, 276 initialSlide : 1, 277 freeMode : true, 278 speed : 1400, 279 watchSlidesVisibility: true, 280 watchSlidesProgress : true, 281 centeredSlides : true, 282 autoplay : { 283 delay: 5000, 284 }, 285 }); 286 var totalSlides = $(".swiper-container").length; 287 var galleryTop = new Swiper('.testimonial-content', { 288 spaceBetween : 10, 289 slidesPerView: 1, 290 mousewheel : true, 291 autoplay : { 292 delay: 5000, 293 }, 294 loop : false, 295 speed : 1400, 296 navigation: { 297 nextEl: '.swiper-button-next', 298 prevEl: '.swiper-button-prev', 299 }, 300 thumbs: { 301 swiper: galleryThumbs 302 } 303 }); 304 305 // Language Selector 306 $(".languages").click(function(){ 307 $(".languages ul").show(); 308 }) 309 $(".languages ul").mouseleave(function(){ 310 $(".languages ul").hide(); 311 }); 312 313 $(".languages li a").click(function(){ 314 $(".languages li a").removeClass('sel'); 315 $(this).addClass('sel'); 316 var selectedValue = $(this).text(); 317 var showLang = selectedValue.substring(0, 2); 318 $('.languages .current').html(showLang); 319 $('.languages .current').attr("title", selectedValue); 320 $('.languages .hover').html(selectedValue); 321 }) 322 323 function bannerSlider() { 324 if ($(".banner-slider").length > 0) { 325 326 // Banner Slider 327 var bannerSlider = new Swiper('.banner-slider', { 328 preloadImages : false, 329 loop : true, 330 grabCursor : true, 331 centeredSlides : false, 332 resistance : true, 333 resistanceRatio: 0.6, 334 speed : 1400, 335 spaceBetween : 0, 336 parallax : false, 337 effect : "slide", 338 autoplay : { 339 delay : 400000000, 340 disableOnInteraction: false 341 }, 342 pagination: { 343 el : '.banner-slider-pagination', 344 clickable: true, 345 }, 346 navigation: { 347 nextEl: '.banner-slider-button-next', 348 prevEl: '.banner-slider-button-prev', 349 }, 350 }); 351 } 352 353 354 } 355 356 //Price Range Slider 357 if($('.price-range-slider').length){ 358 $( ".price-range-slider" ).slider({ 359 range : true, 360 min : 10, 361 max : 200, 362 values: [ 10, 99 ], 363 slide : function( event, ui ) { 364 $( "input.property-amount" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] ); 365 } 366 }); 367 368 $( "input.property-amount" ).val( $( ".price-range-slider" ).slider( "values", 0 ) + " - $" + $( ".price-range-slider" ).slider( "values", 1 ) ); 369 } 370 371 // Lazyload Images 372 if($('.lazy-image').length){ 373 new LazyLoad({ 374 elements_selector: ".lazy-image", 375 load_delay : 0, 376 threshold : 300 377 }); 378 } 379 380 ///////////////////////////// 381 //Universal Code for All Owl Carousel Sliders 382 ///////////////////////////// 383 384 // Donation Progress Bar 385 if ($('.count-bar').length) { 386 $('.count-bar').appear(function(){ 387 var el = $(this); 388 var percent = el.data('percent'); 389 $(el).css('width',percent).addClass('counted'); 390 },{accY: -50}); 391 392 } 393 394 //Jquery Spinner / Quantity Spinner 395 if($('.quantity-spinner').length){ 396 $("input.quantity-spinner").TouchSpin({ 397 verticalbuttons: true 398 }); 399 } 400 401 //Fact Counter + Text Count 402 if($('.count-box').length){ 403 $('.count-box').appear(function(){ 404 405 var $t = $(this), 406 n = $t.find(".count-text").attr("data-stop"), 407 r = parseInt($t.find(".count-text").attr("data-speed"), 10); 408 409 if (!$t.hasClass("counted")) { 410 $t.addClass("counted"); 411 $({ 412 countNum: $t.find(".count-text").text() 413 }).animate({ 414 countNum: n 415 }, { 416 duration: r, 417 easing : "linear", 418 step : function() { 419 $t.find(".count-text").text(Math.floor(this.countNum)); 420 }, 421 complete: function() { 422 $t.find(".count-text").text(this.countNum); 423 } 424 }); 425 } 426 427 },{accY: 0}); 428 } 429 430 //Tabs Box 431 if($('.tabs-box').length){ 432 $('.tabs-box .tab-buttons .tab-btn').on('click', function(e) { 433 e.preventDefault(); 434 var target = $($(this).attr('data-tab')); 435 436 if ($(target).is(':visible')){ 437 return false; 438 }else{ 439 target.parents('.tabs-box').find('.tab-buttons').find('.tab-btn').removeClass('active-btn'); 440 $(this).addClass('active-btn'); 441 target.parents('.tabs-box').find('.tabs-content').find('.tab').fadeOut(0); 442 target.parents('.tabs-box').find('.tabs-content').find('.tab').removeClass('active-tab'); 443 $(target).fadeIn(300); 444 $(target).addClass('active-tab'); 445 } 446 }); 447 } 448 449 //Accordion Box 450 if($('.accordion-box').length){ 451 $(".accordion-box").on('click', '.acc-btn', function() { 452 453 var outerBox = $(this).parents('.accordion-box'); 454 var target = $(this).parents('.accordion'); 455 456 if($(this).hasClass('active')!==true){ 457 $(outerBox).find('.accordion .acc-btn').removeClass('active'); 458 } 459 460 if ($(this).next('.acc-content').is(':visible')){ 461 return false; 462 }else{ 463 $(this).addClass('active'); 464 $(outerBox).children('.accordion').removeClass('active-block'); 465 $(outerBox).find('.accordion').children('.acc-content').slideUp(300); 466 target.addClass('active-block'); 467 $(this).next('.acc-content').slideDown(300); 468 } 469 }); 470 } 471 472 473 //LightBox / Fancybox 474 if($('.lightbox-image').length) { 475 $('.lightbox-image').fancybox({ 476 openEffect : 'fade', 477 closeEffect: 'fade', 478 helpers : { 479 media: {} 480 } 481 }); 482 } 483 484 //Sortable Masonary with Filters 485 function sortableMasonry() { 486 if ($('.sortable-masonry').length) { 487 var winDow = $(window); 488 // Needed variables 489 var $container = $('.sortable-masonry .items-container'); 490 var $filter = $('.filter-btns'); 491 $container.isotope({ 492 filter : '.all', 493 animationOptions: { 494 duration: 500, 495 easing : 'linear' 496 } 497 }); 498 // Isotope Filter 499 $filter.find('li').on('click', function() { 500 var selector = $(this).attr('data-filter'); 501 try { 502 $container.isotope({ 503 filter : selector, 504 animationOptions: { 505 duration: 500, 506 easing : 'linear', 507 queue : false 508 } 509 }); 510 } catch (err) {} 511 return false; 512 }); 513 winDow.on('resize', function() { 514 var selector = $filter.find('li.active').attr('data-filter'); 515 $container.isotope({ 516 filter : selector, 517 animationOptions: { 518 duration: 500, 519 easing : 'linear', 520 queue : false 521 } 522 }); 523 $container.isotope() 524 }); 525 var filterItemA = $('.filter-btns li'); 526 filterItemA.on('click', function() { 527 var $this = $(this); 528 if (!$this.hasClass('active')) { 529 filterItemA.removeClass('active'); 530 $this.addClass('active'); 531 } 532 }); 533 $container.isotope("on", "layoutComplete", function(a, b) { 534 var a = b.length, 535 pcn = $(".filters .count"); 536 pcn.html(a); 537 }); 538 } 539 } 540 sortableMasonry(); 541 542 543 // Testimonial 544 if ($('.testimonial-carousel').length) { 545 var testimonialThumb = new Swiper('.testimonial-thumbs', { 546 preloadImages : false, 547 loop : true, 548 speed : 2400, 549 slidesPerView : 3, 550 centeredSlides: true, 551 spaceBetween : 0, 552 effect : "slide", 553 }); 554 var totalSlides = $(".swiper-container").length; 555 var testimonialContent = new Swiper('.testimonial-content', { 556 preloadImages: false, 557 loop : true, 558 speed : 2400, 559 spaceBetween : 0, 560 effect : "slide", 561 thumbs : { 562 swiper: testimonialThumb 563 } 564 565 }); 566 567 } 568 569 570 // Single Image Carousel 571 if ($('.single-image-carousel').length) { 572 var productThumbs = new Swiper('.single-image-carousel', { 573 preloadImages: false, 574 loop : true, 575 speed : 1400, 576 spaceBetween : 0, 577 effect : "fade", 578 autoplay : { 579 delay : 5000, 580 disableOnInteraction: false 581 }, 582 583 navigation: { 584 nextEl: '.slider-button-next', 585 prevEl: '.slider-button-prev', 586 }, 587 }); 588 589 } 590 591 //Projects Tabs 592 if($('.project-tab').length){ 593 $('.project-tab .project-tab-btns .p-tab-btn').on('click', function(e) { 594 e.preventDefault(); 595 var target = $($(this).attr('data-tab')); 596 597 if ($(target).hasClass('actve-tab')){ 598 return false; 599 }else{ 600 $('.project-tab .project-tab-btns .p-tab-btn').removeClass('active-btn'); 601 $(this).addClass('active-btn'); 602 $('.project-tab .p-tabs-content .p-tab').removeClass('active-tab'); 603 $(target).addClass('active-tab'); 604 } 605 }); 606 } 607 608 // Isotop Layout 609 function isotopeBlock() { 610 if($(".isotope-block").length){ 611 var $grid = $('.isotope-block').isotope(); 612 613 } 614 } 615 616 isotopeBlock(); 617 618 //Progress Bar / Levels 619 if ($('.progress-levels .progress-box .bar-fill').length) { 620 $(".progress-box .bar-fill").each(function() { 621 var progressWidth = $(this).attr('data-percent'); 622 $(this).css('width', progressWidth + '%'); 623 $(this).children('.percent').html(progressWidth + '%'); 624 }); 625 } 626 627 // Scroll to a Specific Div 628 if($('.scroll-to-target').length){ 629 $(".scroll-to-target").on('click', function() { 630 var target = $(this).attr('data-target'); 631 // animate 632 $('html, body').animate({ 633 scrollTop: $(target).offset().top 634 }, 1500); 635 }); 636 } 637 638 639 // Elements Animation 640 if($('.wow').length){ 641 var wow = new WOW( 642 { 643 boxClass : 'wow', // animated element css class (default is wow) 644 animateClass: 'animated', // animation css class (default is animated) 645 offset : 0, // distance to the element when triggering the animation (default is 0) 646 mobile : true, // trigger animations on mobile devices (default is true) 647 live : true // act on asynchronously loaded content (default is true) 648 } 649 ); 650 wow.init(); 651 } 652 653 //Add One Page nav 654 if($('.scroll-nav').length) { 655 $('.scroll-nav ul').onePageNav(); 656 } 657 658 659 /* ========================================================================== 660 When document is Resize, do 661 ========================================================================= = */ 662 663 $(window).on('resize', function() { 664 marginClc(); 665 }); 666 667 /* ========================================================================== 668 When document is Scrollig, do 669 ========================================================================= = */ 670 671 $(window).on('scroll', function() { 672 headerStyle(); 673 }); 674 675 /* ========================================================================== 676 When document is loading, do 677 ========================================================================= = */ 678 679 $(window).on('load', function() { 680 handlePreloader(); 681 sortableMasonry(); 682 isotopeBlock(); 683 bannerSlider(); 684 }); 685 686 })(window.jQuery);