1(function($){ 2 "use strict"; // Start of use strict 3 4 5 /* --------------------------------------------- 6 Scripts initialization 7 --------------------------------------------- */ 8 9 $(window).on("load", function(){ 10 11 // Page loader 12 $(".page-loader div").fadeOut(); 13 $(".page-loader").delay(200).fadeOut("slow"); 14 15 init_text_rotator(); 16 initWorkFilter(); 17 init_scroll_navigate(); 18 init_wow(); 19 init_parallax(); 20 initPageSliders(); 21 22 $(window).trigger("scroll"); 23 $(window).trigger("resize"); 24 25 // Hash menu forwarding 26 if ((window.location.hash) && ($(window.location.hash).length)) { 27 var hash_offset = $(window.location.hash).offset().top; 28 $("html, body").animate({ 29 scrollTop: hash_offset 30 }); 31 } 32 33 }); 34 35 $(document).ready(function(){ 36 $(window).trigger("resize"); 37 init_classic_menu(); 38 init_lightbox(); 39 init_team(); 40 init_services(); 41 init_map(); 42 init_bg_video(); 43 Splitting(); 44 init_shortcodes(); 45 init_tooltips(); 46 init_masonry(); 47 }); 48 49 $(window).resize(function(){ 50 init_classic_menu_resize(); 51 // 100vh height on mobile devices 52 var vh = $(window).height() * 0.01; 53 $("html").css("--vh", vh + "px"); 54 }); 55 56 57 /* -------------------------------------------- 58 Platform detect 59 --------------------------------------------- */ 60 61 var mobileTest; 62 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) { 63 mobileTest = true; 64 $("html").addClass("mobile"); 65 } 66 else { 67 mobileTest = false; 68 $("html").addClass("no-mobile"); 69 } 70 var mozillaTest; 71 if (/mozilla/.test(navigator.userAgent)) { 72 mozillaTest = true; 73 } 74 else { 75 mozillaTest = false; 76 } 77 var safariTest; 78 if (/safari/.test(navigator.userAgent)) { 79 safariTest = true; 80 } 81 else { 82 safariTest = false; 83 } 84 85 // Detect touch devices 86 if (!("ontouchstart" in document.documentElement)) { 87 document.documentElement.className += " no-touch"; 88 } else { 89 document.documentElement.className += " touch"; 90 } 91 92 93 /* --------------------------------------------- 94 Sections helpers 95 --------------------------------------------- */ 96 97 // Sections backgrounds 98 var pageSection = $(".home-section, .page-section, .small-section, .split-section"); 99 pageSection.each(function(indx){ 100 if ($(this).attr("data-background")){ 101 $(this).css("background-image", "url(" + $(this).data("background") + ")"); 102 } 103 }); 104 105 // Function for block height 100% 106 function height_line(height_object, height_donor){ 107 height_object.height(height_donor.height()); 108 height_object.css({ 109 "line-height": height_donor.height() + "px" 110 }); 111 } 112 function height_line_s(height_object, height_donor){ 113 height_object.height(height_donor.height()); 114 height_object.css({ 115 "line-height": height_donor.height() - 2 + "px" 116 }); 117 } 118 119 // Progress bars 120 var progressBar = $(".progress-bar"); 121 progressBar.each(function(indx){ 122 $(this).css("width", $(this).attr("aria-valuenow") + "%"); 123 }); 124 125 126 /* --------------------------------------------- 127 Nav panel classic 128 --------------------------------------------- */ 129 130 var mobile_nav = $(".mobile-nav"); 131 var desktop_nav = $(".desktop-nav"); 132 133 mobile_nav.attr("aria-expanded", "false"); 134 135 function init_classic_menu_resize(){ 136 137 // Mobile menu max height 138 $(".mobile-on .desktop-nav >
138 ul").css("max-height", $(window).height() - $(".main-nav").height() - 20 + "px"); 139 140 // Mobile menu style toggle 141 if ($(window).width() <= 1024) { 142 $(".main-nav").addClass("mobile-on"); 143 $(".mobile-cart").show(); 144 } 145 else 146 if ($(window).width() > 1024) { 147 $(".main-nav").removeClass("mobile-on"); 148 desktop_nav.show(); 149 $(".mobile-cart").hide(); 150 } 151 } 152 153 function init_classic_menu(){ 154 155 if ($(".main-nav").hasClass("transparent")){ 156 height_line($(".inner-nav > ul > li > a"), $(".main-nav")); 157 } else { 158 height_line_s($(".inner-nav > ul > li > a"), $(".main-nav")); 159 } 160 height_line(mobile_nav, $(".main-nav")); 161 height_line($(".mobile-cart"), $(".main-nav")); 162 163 // Transpaner menu 164 165 if ($(".main-nav").hasClass("transparent")){ 166 $(".main-nav").addClass("js-transparent"); 167 } else if (!($(".main-nav").hasClass("dark"))){ 168 $(".main-nav").addClass("js-no-transparent-white"); 169 } 170 171 $(window).scroll(function(){ 172 173 if ($(window).scrollTop() > 0) { 174 $(".js-transparent").removeClass("transparent"); 175 $(".main-nav, .nav-logo-wrap .logo, .mobile-nav, .mobile-cart").addClass("small-height"); 176 $(".light-after-scroll").removeClass("dark"); 177 $(".main-nav").addClass("body-scrolled"); 178 } 179 else if ($(window).scrollTop() === 0){ 180 $(".js-transparent").addClass("transparent"); 181 $(".main-nav, .nav-logo-wrap .logo, .mobile-nav, .mobile-cart").removeClass("small-height"); 182 $(".light-after-scroll").addClass("dark"); 183 $(".main-nav").removeClass("body-scrolled"); 184 } 185 186 187 }); 188 189 // Mobile menu toggle 190 191 mobile_nav.click(function(){ 192 193 if (desktop_nav.hasClass("js-opened")) { 194 desktop_nav.slideUp("slow", "easeOutExpo").removeClass("js-opened"); 195 $(this).removeClass("active"); 196 $(this).attr("aria-expanded", "false"); 197 } 198 else { 199 desktop_nav.slideDown("slow", "easeOutQuart").addClass("js-opened"); 200 $(this).addClass("active"); 201 $(this).attr("aria-expanded", "true"); 202 // Fix for responsive menu 203 if ($(".main-nav").hasClass("not-top")){ 204 $(window).scrollTo(".main-nav", "slow"); 205 } 206 } 207 208 }); 209 210 $(document).on("click", function(event){ 211 if ($(window).width() <= 1024) { 212 var $trigger = $(".main-nav"); 213 if ($trigger !== event.target && !$trigger.has(event.target).length) { 214 desktop_nav.slideUp("slow", "easeOutExpo").removeClass("js-opened"); 215 mobile_nav.removeClass("active"); 216 mobile_nav.attr("aria-expanded", "false"); 217 } 218 } 219 }); 220 221 mobile_nav.keydown(function(e){ 222 if (e.keyCode == 13 || e.keyCode == 32) { 223 if (desktop_nav.hasClass("js-opened")) { 224 desktop_nav.slideUp("slow", "easeOutExpo").removeClass("js-opened"); 225 $(this).removeClass("active"); 226 $(this).attr("aria-expanded", "false"); 227 } 228 else { 229 desktop_nav.slideDown("slow", "easeOutQuart").addClass("js-opened"); 230 $(this).addClass("active"); 231 $(this).attr("aria-expanded", "true"); 232 // Fix for responsive menu 233 if ($(".main-nav").hasClass("not-top")) { 234 $(window).scrollTo(".main-nav", "slow"); 235 } 236 } 237 } 238 }); 239 240 desktop_nav.find("a:not(.mn-has-sub)").click(function(){ 241 if (mobile_nav.hasClass("active")) { 242 desktop_nav.slideUp("slow", "easeOutExpo").removeClass("js-opened"); 243 mobile_nav.removeClass("active"); 244 mobile_nav.attr("aria-expanded", "false"); 245 } 246 }); 247 248 249 // Sub menu 250 251 var mnHasSub = $(".mn-has-sub"); 252 var mnThisLi; 253 254 mnHasSub.attr({ 255 "role": "button", 256 "aria-expanded": "false", 257 "aria-haspopup": "true" 258 }); 259 260 mnHasSub.click(function(){ 261 262 if ($(".main-nav").hasClass("mobile-on")) { 263 mnThisLi = $(this).parent("li:first"); 264 if (mnThisLi.hasClass("js-opened")) { 265 $(this).attr("aria-expanded", "false"); 266 mnThisLi.find(".mn-sub:first").slideUp(function(){ 267 mnThisLi.removeClass("js-opened"); 268 }); 269 } 270 else { 271 $(this).attr("aria-expanded", "true"); 272 mnThisLi.addClass("js-opened"); 273 mnThisLi.find(".mn-sub:first").slideDown(); 274 } 275 276 return false; 277 } 278 279 }); 280 281 mnThisLi = mnHasSub.parent("li"); 282 mnThisLi.hover(function(){ 283 284 if (!($(".main-nav").hasClass("mobile-on"))) { 285 $(this).find(".mn-has-sub:first") 286 .attr("aria-expanded", "true") 287 .addClass("js-opened"); 288 $(this).find(".mn-sub:first").stop(true, true).fadeIn("fast"); 289 } 290 291 }, function(){ 292 293 if (!($(".main-nav").hasClass("mobile-on"))) { 294 $(this).find(".mn-has-sub:first") 295 .attr("aria-expanded", "false") 296 .removeClass("js-opened"); 297 $(this).find(".mn-sub:first").stop(true, true).delay(100).fadeOut("fast"); 298 } 299 300 }); 301 302 /* Keyboard navigation for main menu */ 303 304 mnHasSub.keydown(function(e){ 305 306 if ($(".main-nav").hasClass("mobile-on")) { 307 if (e.keyCode == 13 || e.keyCode == 32) { 308 mnThisLi = $(this).parent("li:first"); 309 if (mnThisLi.hasClass("js-opened")) { 310 $(this).attr("aria-expanded", "false"); 311 mnThisLi.find(".mn-sub:first").slideUp(function(){ 312 mnThisLi.removeClass("js-opened"); 313 }); 314 } 315 else { 316 $(this).attr("aria-expanded", "true"); 317 mnThisLi.addClass("js-opened"); 318 mnThisLi.find(".mn-sub:first").slideDown(); 319 } 320 321 return false; 322 } 323 } 324 325 }); 326 327 $(".inner-nav a").focus(function(){ 328 if (!($(".main-nav").hasClass("mobile-on")) && ($("html").hasClass("no-touch")) && (!($(this).parent("li").find(".mn-sub:first").is(":visible")))) { 329 $(this).parent("li").parent().children().find(".mn-has-sub:first") 330 .attr("aria-expanded", "false") 331 .removeClass("js-opened"); 332 $(this).parent("li").parent().children().find(".mn-sub:first").stop(true, true).delay(100).fadeOut("fast"); 333 } 334 }); 335 336 $(".inner-nav a").first().keydown(function(e){
337 if (!($(".main-nav").hasClass("mobile-on"))) { 338 if (e.shiftKey && e.keyCode == 9) { 339 $(this).parent("li").find(".mn-has-sub:first") 340 .attr("aria-expanded", "false") 341 .removeClass("js-opened"); 342 $(this).parent("li").find(".mn-sub:first").stop(true, true).delay(100).fadeOut("fast"); 343 } 344 } 345 }); 346 347 $(".mn-sub li:last a").keydown(function(e){ 348 if (!($(".main-nav").hasClass("mobile-on"))) { 349 if (!e.shiftKey && e.keyCode == 9) { 350 $(this).parent("li").parent().parent().find(".mn-has-sub:first") 351 .attr("aria-expanded", "false") 352 .removeClass("js-opened"); 353 $(this).parent("li").parent().stop(true, true).delay(100).fadeOut("fast"); 354 } 355 } 356 }); 357 358 $(document).keydown(function(e){ 359 if (!($(".main-nav").hasClass("mobile-on"))) { 360 if (e.keyCode == 27) { 361 if (mnHasSub.parent("li").find(".mn-sub:first li .mn-sub").is(":visible")){ 362 mnHasSub.parent("li").find(".mn-sub:first li .mn-has-sub") 363 .attr("aria-expanded", "false") 364 .removeClass("js-opened"); 365 mnHasSub.parent("li").find(".mn-sub:first li .mn-sub").stop(true, true).delay(100).fadeOut("fast"); 366 } else{ 367 mnHasSub.parent("li").find(".mn-has-sub:first") 368 .attr("aria-expanded", "false") 369 .removeClass("js-opened"); 370 mnHasSub.parent("li").find(".mn-sub:first").stop(true, true).delay(100).fadeOut("fast"); 371 } 372 373 } 374 } 375 }); 376 377 mnHasSub.on("click", function () { 378 if (!($(".main-nav").hasClass("mobile-on"))) { 379 if (!($(this).hasClass("js-opened"))){ 380 $(this).addClass("js-opened"); 381 $(this).attr("aria-expanded", "true"); 382 $(this).parent("li").find(".mn-sub:first").fadeIn("fast"); 383 return false; 384 } 385 else{ 386 $(this).removeClass("js-opened"); 387 $(this).attr("aria-expanded", "false"); 388 $(this).parent("li").find(".mn-sub:first").fadeOut("fast"); 389 return false; 390 } 391 } 392 }); 393 394 } 395 396 397 /* --------------------------------------------- 398 Scroll navigation 399 --------------------------------------------- */ 400 401 function init_scroll_navigate(){ 402 403 $(".local-scroll").localScroll({ 404 target: "body", 405 duration: 1500, 406 offset: 0, 407 easing: "easeInOutQuart", 408 onAfter: function(anchor, settings){ 409 anchor.focus(); 410 if (anchor.is(":focus")) { 411 return !1; 412 } 413 else { 414 anchor.attr("tabindex", "-1"); 415 anchor.focus() 416 } 417 } 418 }); 419 420 var sections = $(".home-section, .split-section, .page-section"); 421 var menu_links = $(".scroll-nav li a"); 422 423 $(window).scroll(function(){ 424 425 sections.filter(":in-viewport:first").each(function(){ 426 var active_section = $(this); 427 var active_link = $('.scroll-nav li a[href="#' + active_section.attr("id") + '"]'); 428 menu_links.removeClass("active"); 429 active_link.addClass("active"); 430 }); 431 432 }); 433 434 } 435 436 437 /* --------------------------------------------- 438 Lightboxes 439 --------------------------------------------- */ 440 441 function init_lightbox(){ 442 443 // Works Item Lightbox 444 $(".work-lightbox-link").magnificPopup({ 445 gallery: { 446 enabled: true 447 }, 448 mainClass: "mfp-fade" 449 }); 450 451 // Other Custom Lightbox 452 $(".lightbox-gallery-1").magnificPopup({ 453 gallery: { 454 enabled: true 455 }, 456 mainClass: "mfp-fade" 457 }); 458 $(".lightbox-gallery-2").magnificPopup({ 459 gallery: { 460 enabled: true 461 }, 462 mainClass: "mfp-fade" 463 }); 464 $(".lightbox-gallery-3").magnificPopup({ 465 gallery: { 466 enabled: true 467 }, 468 mainClass: "mfp-fade" 469 }); 470 $(".lightbox-gallery-4").magnificPopup({ 471 gallery: { 472 enabled: true 473 }, 474 mainClass: "mfp-fade" 475 }); 476 $(".lightbox-gallery-5").magnificPopup({ 477 gallery: { 478 enabled: true 479 }, 480 mainClass: "mfp-fade" 481 }); 482 $(".lightbox-gallery-6").magnificPopup({ 483 gallery: { 484 enabled: true 485 }, 486 mainClass: "mfp-fade" 487 }); 488 $(".lightbox-gallery-7").magnificPopup({ 489 gallery: { 490 enabled: true 491 }, 492 mainClass: "mfp-fade" 493 }); 494 $(".lightbox-gallery-8").magnificPopup({ 495 gallery: { 496 enabled: true 497 }, 498 mainClass: "mfp-fade" 499 }); 500 $(".lightbox-gallery-9").magnificPopup({ 501 gallery: { 502 enabled: true 503 }, 504 mainClass: "mfp-fade" 505 }); 506 $(".lightbox-gallery-10").magnificPopup({ 507 gallery: { 508 enabled: true 509 }, 510 mainClass: "mfp-fade" 511 }); 512 $(".lightbox").magnificPopup({ 513 gallery: { 514 enabled: true 515 }, 516 mainClass: "mfp-fade" 517 }); 518 519 } 520 521 522 /* ------------------------------------------- 523 Parallax 524 --------------------------------------------- */ 525 526 function init_parallax(){ 527 if (($(window).width() >= 1024) && (mobileTest == false) && $("html").hasClass("no-touch")) { 528 $(".parallax-1").each(function(){$(this).parallax("50%", 0.1);}); 529 $(".parallax-2").each(function(){$(this).parallax("50%", 0.2);}); 530 $(".parallax-3").each(function(){$(this).parallax("50%", 0.3);}); 531 $(".parallax-4").each(function(){$(this).parallax("50%", 0.4);}); 532 $(".parallax-5").each(function(){$(this).parallax("50%", 0.5);}); 533 $(".parallax-6").each(function(){$(this).parallax("50%", 0.6);}); 534 $(".parallax-7").each(function(){$(this).parallax("50%", 0.7);}); 535 $(".parallax-8").each(function(){$(this).parallax("50%", 0.8);}); 536 $(".parallax-9").each(function(){$(this).parallax("50%", 0.9);}); 537 $(".parallax-10").each(function(){$(this).parallax("50%", 0.1);}); 538 } 539 } 540 541 542 /* ------------------------------------------- 543 Text Rotator 544 --------------------------------------------- */ 545 546 function init_text_rotator(){ 547 $(".text-rotate").each(function(){ 548 var text_rotator = $(this); 549 var text_rotator_cont = text_rotator.html(); 550 text_rotator.attr("aria-hidden", "true"); 551 text_rotator.before("<span class='sr-only'>" + text_rotator_cont + "</span>"); 552 text_rotator.Morphext({ 553 animation: "fadeIn", 554 separator: ",", 555 speed: 4000 556 }); 557 }); 558 } 559 560 561 /* --------------------------------------------- 562 Shortcodes 563 --------------------------------------------- */ 564 565 function init_shortcodes(){ 566 567 // Accordion 568 $(".accordion").each(function(){ 569 var allPanels = $(this).children("dd").hide(); 570 var allTabs = $(this).children("dt").children("a"); 571 allTabs.attr("role", "button"); 572 $(this).children("dd").first().slideDown("easeOutExpo"); 573 $(this).children("dt").children("a").first().addClass("active"); 574 $(this).children("dt").children("a").attr("aria-expanded", "false"); 575 $(this).children("dt").children("a").first().attr("aria-expanded", "true"); 576 577 $(this).children("dt").children("a").click(function(){ 578 var current = $(this).parent().next("dd"); 579 allTabs.removeClass("active"); 580 $(this).addClass("active"); 581 allTabs.attr("aria-expanded", "false"); 582 $(this).attr("aria-expanded", "true");
583 allPanels.not(current).slideUp("easeInExpo"); 584 $(this).parent().next().slideDown("easeOutExpo"); 585 return false; 586 }); 587 588 }); 589 590 // Toggle 591 var allToggles = $(".toggle > dd").hide(); 592 var allTabs = $(".toggle > dt > a"); 593 allTabs.attr({ 594 "role": "button", 595 "aria-expanded": "false" 596 }); 597 598 $(".toggle > dt > a").click(function(){ 599 600 if ($(this).hasClass("active")) { 601 $(this).parent().next().slideUp("easeOutExpo"); 602 $(this).removeClass("active"); 603 $(this).attr("aria-expanded", "false"); 604 } 605 else { 606 var current = $(this).parent().next("dd"); 607 $(this).addClass("active"); 608 $(this).attr("aria-expanded", "true"); 609 $(this).parent().next().slideDown("easeOutExpo"); 610 } 611 612 return false; 613 }); 614 615 // Responsive video 616 $(".video, .resp-media, .blog-media").fitVids(); 617 $(".work-full-media").fitVids(); 618 619 } 620 621 622 /* --------------------------------------------- 623 Tooltips (bootstrap plugin activated) 624 --------------------------------------------- */ 625 626 function init_tooltips(){ 627 var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) 628 var tooltipList = tooltipTriggerList.map(function(tooltipTriggerEl){ 629 return new bootstrap.Tooltip(tooltipTriggerEl) 630 }) 631 } 632 633 634 /* --------------------------------------------- 635 Team 636 --------------------------------------------- */ 637 638 function init_team(){ 639 640 // Hover 641 $(".team-item").click(function(){ 642 if ($("html").hasClass("mobile")) { 643 $(this).toggleClass("js-active"); 644 } 645 }); 646 647 // Keayboar navigation for team section 648 $(".team-social-links > a").on("focus blur", function(){ 649 if (!($("html").hasClass("mobile"))) { 650 $(this).parent().parent().parent().parent().toggleClass("js-active"); 651 } 652 }); 653 654 } 655 656 657 /* --------------------------------------------- 658 Services 659 --------------------------------------------- */ 660 661 function init_services(){ 662 var services_more; 663 var services_title; 664 $(".services-item").each(function(){ 665 services_title = $(this).find(".services-title").html(); 666 services_more = $(this).find(".services-more > .text-link").html(); 667 $(this).find(".services-more > .text-link").html(services_more + '<span class="sr-only"> about ' + services_title + '</span>'); 668 }); 669 } 670 671 672})(jQuery); // End of use strict 673 674 675/* --------------------------------------------- 676 Sliders 677 --------------------------------------------- */ 678 679function initPageSliders(){ 680 (function($){ 681 "use strict"; 682 683 function owl_keynav(el){ 684 el.attr({ 685 "role": "region", 686 "aria-roledescription": "carousel" 687 }); 688 el.find(".owl-prev, .owl-next").attr({ 689 "role": "button", 690 "tabindex": "0" 691 }); 692 el.prepend(el.find(".owl-controls")); 693 el.on("click", ".owl-page, .owl-prev, .owl-next", function(e){ 694 var this_owl = el.data("owlCarousel"); 695 this_owl.stop(); 696 }); 697 el.on("keydown", ".owl-prev", function(e){ 698 if (e.keyCode == 13 || e.keyCode == 32) { 699 var this_owl = el.data("owlCarousel"); 700 this_owl.prev(); 701 return false; 702 } 703 });
704 el.on("keydown", ".owl-next", function(e){ 705 if (e.keyCode == 13 || e.keyCode == 32) { 706 var this_owl = el.data("owlCarousel"); 707 this_owl.next(); 708 return false; 709 } 710 }); 711 } 712 713 function owl_update(el){ 714 el.find(".owl-item").attr({ 715 "aria-hidden": "true" 716 }); 717 el.find(".owl-item.active").removeAttr("aria-hidden"); 718 el.find(".owl-item a, .owl-item button, .owl-item input").attr({ 719 "tabindex": "-1" 720 }); 721 el.find(".owl-item.active a, .owl-item.active button, .owl-item.active input").attr({ 722 "tabindex": "0" 723 }); 724 } 725 726 // Fullwidth slider 727 $(".fullwidth-slider").owlCarousel({ 728 slideSpeed: 350, 729 singleItem: true, 730 autoHeight: true, 731 navigation: true, 732 lazyLoad: true, 733 addClassActive : true, 734 navigationText: ['<span class="sr-only">Previous Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M5.005,28.500 L27.000,54.494 L24.000,56.994 L0.005,28.500 L24.000,0.006 L27.000,2.506 L5.005,28.500 Z"/></svg>', '<span class="sr-only">Next Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M21.995,28.500 L-0.000,54.494 L3.000,56.994 L26.995,28.500 L3.000,0.006 L-0.000,2.506 L21.995,28.500 Z"/></svg>'], 735 afterInit: owl_keynav, 736 afterAction: owl_update 737 }); 738 739 // Fullwidth slider fade 740 $(".fullwidth-slider-fade").owlCarousel({ 741 transitionStyle: "fade", 742 slideSpeed: 350, 743 singleItem: true, 744 autoHeight: true, 745 navigation: true, 746 lazyLoad: true, 747 addClassActive : true, 748 navigationText: ['<span class="sr-only">Previous Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M5.005,28.500 L27.000,54.494 L24.000,56.994 L0.005,28.500 L24.000,0.006 L27.000,2.506 L5.005,28.500 Z"/></svg>', '<span class="sr-only">Next Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M21.995,28.500 L-0.000,54.494 L3.000,56.994 L26.995,28.500 L3.000,0.006 L-0.000,2.506 L21.995,28.500 Z"/></svg>'], 749 afterInit: owl_keynav, 750 afterAction: owl_update 751 }); 752 753 // Fullwidth slider fadezoom 754 $(".fullwidth-slider-fadezoom").owlCarousel({ 755 transitionStyle: "fadeUp", 756 slideSpeed: 350, 757 singleItem: true, 758 autoHeight: true, 759 navigation: true, 760 lazyLoad: true, 761 addClassActive : true, 762 navigationText: ['<span class="sr-only">Previous Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M5.005,28.500 L27.000,54.494 L24.000,56.994 L0.005,28.500 L24.000,0.006 L27.000,2.506 L5.005,28.500 Z"/></svg>', '<span class="sr-only">Next Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M21.995,28.500 L-0.000,54.494 L3.000,56.994 L26.995,28.500 L3.000,0.006 L-0.000,2.506 L21.995,28.500 Z"/></svg>'], 763 afterInit: owl_keynav, 764 afterAction: owl_update 765 }); 766 767 // Text slider 768 $(".text-slider").owlCarousel({ 769 slideSpeed: 350, 770 singleItem: true, 771 autoHeight: true, 772 navigation: true, 773 lazyLoad: true, 774 addClassActive : true, 775 navigationText: ['<span class="sr-only">
775Previous Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M5.005,28.500 L27.000,54.494 L24.000,56.994 L0.005,28.500 L24.000,0.006 L27.000,2.506 L5.005,28.500 Z"/></svg>', '<span class="sr-only">Next Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M21.995,28.500 L-0.000,54.494 L3.000,56.994 L26.995,28.500 L3.000,0.006 L-0.000,2.506 L21.995,28.500 Z"/></svg>'], 776 afterInit: owl_keynav, 777 afterAction: owl_update 778 }); 779 780 // Fullwidth gallery 781 $(".fullwidth-gallery").owlCarousel({ 782 transitionStyle: "fade", 783 autoPlay: 5000, 784 slideSpeed: 700, 785 singleItem: true, 786 autoHeight: true, 787 navigation: false, 788 pagination: false, 789 lazyLoad: true, 790 addClassActive : true, 791 afterInit: owl_keynav, 792 afterAction: owl_update 793 }); 794 795 // Item carousel 796 $(".item-carousel").owlCarousel({ 797 autoPlay: 3500, 798 stopOnHover: false, 799 items: 3, 800 itemsDesktop: [1199, 3], 801 itemsTabletSmall: [768, 3], 802 itemsMobile: [480, 1], 803 navigation: true, 804 lazyLoad: true, 805 addClassActive : true, 806 navigationText: ['<span class="sr-only">Previous Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M5.005,28.500 L27.000,54.494 L24.000,56.994 L0.005,28.500 L24.000,0.006 L27.000,2.506 L5.005,28.500 Z"/></svg>', '<span class="sr-only">Next Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M21.995,28.500 L-0.000,54.494 L3.000,56.994 L26.995,28.500 L3.000,0.006 L-0.000,2.506 L21.995,28.500 Z"/></svg>'], 807 afterInit: owl_keynav, 808 afterAction: owl_update 809 }); 810 811 // Small item carousel 812 $(".small-item-carousel").owlCarousel({ 813 autoPlay: 2500, 814 stopOnHover: true, 815 items: 6, 816 itemsDesktop: [1199, 4], 817 itemsTabletSmall: [768, 3], 818 itemsMobile: [480, 2], 819 pagination: false, 820 navigation: true, 821 lazyLoad: true, 822 addClassActive : true, 823 navigationText: ["<span class='sr-only'>Previous Slide</span><i class='fa fa-angle-left' aria-hidden='true'></i>", "<span class='sr-only'>Next Slide</span><i class='fa fa-angle-right' aria-hidden='true'></i>"], 824 afterInit: owl_keynav, 825 afterAction: owl_update 826 }); 827 828 // Single carousel 829 $(".single-carousel").owlCarousel({ 830 singleItem: true, 831 autoHeight: true, 832 navigation: true, 833 lazyLoad: true, 834 addClassActive : true, 835 navigationText: ["<span class='sr-only'>Previous Slide</span><i class='fa fa-angle-left' aria-hidden='true'></i>", "<span class='sr-only'>Next Slide</span><i class='fa fa-angle-right' aria-hidden='true'></i>"], 836 afterInit: owl_keynav, 837 afterAction: owl_update 838 }); 839 840 // Content Slider 841 $(".content-slider").owlCarousel({ 842 slideSpeed: 350, 843 singleItem: true, 844 autoHeight: true, 845 navigation: true, 846 lazyLoad: true, 847 addClassActive : true, 848 navigationText: ['<span class="sr-only">Previous Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false">
848<path d="M5.005,28.500 L27.000,54.494 L24.000,56.994 L0.005,28.500 L24.000,0.006 L27.000,2.506 L5.005,28.500 Z"/></svg>', '<span class="sr-only">Next Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M21.995,28.500 L-0.000,54.494 L3.000,56.994 L26.995,28.500 L3.000,0.006 L-0.000,2.506 L21.995,28.500 Z"/></svg>'], 849 afterInit: owl_keynav, 850 afterAction: owl_update 851 }); 852 853 // Photo slider 854 $(".photo-slider").owlCarousel({ 855 slideSpeed: 350, 856 items: 4, 857 itemsDesktop: [1199, 4], 858 itemsTabletSmall: [768, 2], 859 itemsMobile: [480, 1], 860 autoHeight: true, 861 navigation: true, 862 lazyLoad: true, 863 addClassActive : true, 864 navigationText: ["<span class='sr-only'>Previous Slide</span><i class='fa fa-angle-left' aria-hidden='true'></i>", "<span class='sr-only'>Next Slide</span><i class='fa fa-angle-right' aria-hidden='true'></i>"], 865 afterInit: owl_keynav, 866 afterAction: owl_update 867 }); 868 869 // Work slider 870 $(".simple-slider").owlCarousel({ 871 slideSpeed : 350, 872 singleItem: true, 873 autoHeight: true, 874 navigation: true, 875 lazyLoad: true, 876 addClassActive : true, 877 navigationText: ['<span class="sr-only">Previous Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M5.005,28.500 L27.000,54.494 L24.000,56.994 L0.005,28.500 L24.000,0.006 L27.000,2.506 L5.005,28.500 Z"/></svg>', '<span class="sr-only">Next Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M21.995,28.500 L-0.000,54.494 L3.000,56.994 L26.995,28.500 L3.000,0.006 L-0.000,2.506 L21.995,28.500 Z"/></svg>'], 878 afterInit: owl_keynav, 879 afterAction: owl_update 880 }); 881 882 // Work slider 883 $(".work-full-slider").owlCarousel({ 884 slideSpeed : 350, 885 singleItem: true, 886 autoHeight: true, 887 navigation: true, 888 lazyLoad: true, 889 addClassActive : true, 890 navigationText: ['<span class="sr-only">Previous Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M5.005,28.500 L27.000,54.494 L24.000,56.994 L0.005,28.500 L24.000,0.006 L27.000,2.506 L5.005,28.500 Z"/></svg>', '<span class="sr-only">Next Slide</span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="27px" height="57px" viewBox="0 0 27 57" fill="currentColor" aria-hidden="true" focusable="false"><path d="M21.995,28.500 L-0.000,54.494 L3.000,56.994 L26.995,28.500 L3.000,0.006 L-0.000,2.506 L21.995,28.500 Z"/></svg>'], 891 afterInit: owl_keynav, 892 afterAction: owl_update 893 }); 894 895 // Blog posts carousel 896 $(".blog-posts-carousel").owlCarousel({ 897 autoPlay: 5000, 898 stopOnHover: true, 899 items: 3, 900 itemsDesktop: [1199, 3], 901 itemsTabletSmall: [768, 2], 902 itemsMobile: [480, 1], 903 pagination: false, 904 navigation: true, 905 lazyLoad: true, 906 addClassActive : true, 907 navigationText: ["<span class='sr-only'>Previous Slide</span><i class='fa fa-angle-left' aria-hidden='true'></i>", "<span class='sr-only'>Next Slide</span><i class='fa fa-angle-right' aria-hidden='true'></i>"], 908 afterInit: owl_keynav, 909 afterAction: owl_update 910 }); 911 912 // Blog posts carousel alt 913 $(".blog-posts-carousel-alt").owlCarousel({ 914 autoPlay: 3500, 915 stopOnHover: true, 916 slideSpeed: 350, 917 singleItem: true, 918 autoHeight: true, 919 pagination: false, 920 navigation: true, 921 lazyLoad: true, 922 addClassActive : true, 923 navigationText: ["<span class='sr-only'>
923Previous Slide</span><i class='fa fa-angle-left' aria-hidden='true'></i>", "<span class='sr-only'>Next Slide</span><i class='fa fa-angle-right' aria-hidden='true'></i>"], 924 afterInit: owl_keynav, 925 afterAction: owl_update 926 }); 927 928 // Image carousel 929 $(".image-carousel").owlCarousel({ 930 autoPlay: 5000, 931 stopOnHover: true, 932 items: 4, 933 itemsDesktop: [1199, 3], 934 itemsTabletSmall: [768, 2], 935 itemsMobile: [480, 1], 936 navigation: true, 937 lazyLoad: true, 938 addClassActive : true, 939 navigationText: ["<span class='sr-only'>Previous Slide</span><i class='fa fa-angle-left' aria-hidden='true'></i>", "<span class='sr-only'>Next Slide</span><i class='fa fa-angle-right' aria-hidden='true'></i>"], 940 afterInit: owl_keynav, 941 afterAction: owl_update 942 }); 943 944 })(jQuery); 945}; 946 947 948/* --------------------------------------------- 949 Portfolio section 950 --------------------------------------------- */ 951 952// Projects filtering 953 954var fselector = 0; 955var work_grid = $("#work-grid, #isotope"); 956 957function initWorkFilter(){ 958 (function($){ 959 "use strict"; 960 var isotope_mode; 961 if (work_grid.hasClass("masonry")){ 962 isotope_mode = "masonry"; 963 } else{ 964 isotope_mode = "fitRows" 965 } 966 967 $(".filter").click(function(){ 968 $(".filter").removeClass("active").attr("aria-pressed", "false"); 969 $(this).addClass("active").attr("aria-pressed", "true"); 970 fselector = $(this).attr("data-filter"); 971 var transition_duration = "0.4s"; 972 if (($("body").hasClass("appear-animate")) && (!($("html").hasClass("mobile")) && (work_grid.find(".wow-p").length))){ 973 transition_duration = 0; 974 } 975 work_grid.imagesLoaded(function(){ 976 work_grid.isotope({ 977 itemSelector: ".mix", 978 layoutMode: isotope_mode, 979 filter: fselector, 980 transitionDuration: transition_duration 981 }); 982 }); 983 984 if ($("body").hasClass("appear-animate")) { 985 var wow_p = new WOW({ 986 boxClass: "wow-p", 987 animateClass: "animated", 988 offset: 100, 989 mobile: false, 990 live: true, 991 callback: function(box){ 992 setInterval(function(){ 993 $(box).removeClass("no-animate"); 994 }, 1500); 995 } 996 }); 997 wow_p.init(); 998 } 999 1000 return false; 1001 }); 1002 1003 if (window.location.hash) { 1004 $(".filter").each(function(){ 1005 if ($(this).attr("data-filter") == "." + window.location.hash.replace("#", "")) { 1006 $(this).trigger("click"); 1007 if ($("#portfolio").length) { 1008 $("html, body").animate({ 1009 scrollTop: $("#portfolio").offset().top 1010 }); 1011 } 1012 1013 } 1014 }); 1015 } 1016 1017 work_grid.imagesLoaded(function(){ 1018 work_grid.isotope({ 1019 itemSelector: ".mix", 1020 layoutMode: isotope_mode, 1021 filter: fselector 1022 }); 1023 }); 1024 1025 // Lazy loading plus isotope filter 1026 1027 $(".img-lazy-work").on("load", function(){ 1028 masonry_update(); 1029 }); 1030 function masonry_update(){ 1031 work_grid.imagesLoaded(function(){ 1032 work_grid.isotope({ 1033 itemSelector: ".mix", 1034 layoutMode: isotope_mode, 1035 filter: fselector 1036 }); 1037 }); 1038 } 1039 work_grid.on("arrangeComplete", function(){ 1040 $(window).trigger("scroll"); 1041 }); 1042 1043 })(jQuery); 1044} 1045 1046 1047/* --------------------------------------------- 1048 Google map 1049 --------------------------------------------- */ 1050 1051function init_map(){ 1052 (function($){ 1053 1054 $(".map-section").click(function(){ 1055 $(this).toggleClass("js-active"); 1056 $(this).find(".mt-open").toggle(); 1057 $(this).find(".mt-close").toggle(); 1058 return false; 1059 }); 1060 1061 })(jQuery); 1062} 1063 1064 1065/* --------------------------------------------- 1066 HTML5 background video 1067 --------------------------------------------- */ 1068 1069function init_bg_video(){ 1070 (function($){ 1071 1072 $(".bg-video-button-muted").click(function(){ 1073 if ($(this).prev().find(".bg-video").prop('muted')) { 1074 $(this).prev().find(".bg-video").prop('muted', false); 1075 $(this).find("i").removeClass("fa-volume-off").addClass("fa-volume-up"); 1076 } 1077 else { 1078 $(this).prev().find(".bg-video").prop('muted', true); 1079 $(this).find("i").removeClass("fa-volume-up").addClass("fa-volume-off"); 1080 } 1081 1082 return false; 1083 });
1084 1085 })(jQuery); 1086} 1087 1088 1089/* --------------------------------------------- 1090 WOW animations 1091 --------------------------------------------- */ 1092 1093function init_wow(){ 1094 (function($){ 1095 1096 /* Wow init */ 1097 1098 if ($("body").hasClass("appear-animate")) { 1099 $(".wow").addClass("no-animate"); 1100 } 1101 var wow = new WOW({ 1102 boxClass: 'wow', 1103 animateClass: 'animated', 1104 offset: 100, 1105 mobile: false, 1106 live: true, 1107 callback: function(box){ 1108 setInterval(function(){ $(box).removeClass("no-animate"); }, 1500); 1109 } 1110 }); 1111 1112 if ($("body").hasClass("appear-animate")){ 1113 wow.init(); 1114 } else{ 1115 $(".wow").css("opacity", "1"); 1116 } 1117 1118 /* Wow for portfolio init */ 1119 1120 if ($("body").hasClass("appear-animate")) { 1121 $(".wow-p").addClass("no-animate"); 1122 } 1123 var wow_p = new WOW({ 1124 boxClass: 'wow-p', 1125 animateClass: 'animated', 1126 offset: 100, 1127 mobile: false, 1128 live: true, 1129 callback: function(box){ 1130 setInterval(function(){ $(box).removeClass("no-animate"); }, 1500); 1131 } 1132 }); 1133 1134 if ($("body").hasClass("appear-animate")){ 1135 wow_p.init(); 1136 } else{ 1137 $(".wow-p").css("opacity", "1"); 1138 } 1139 1140 /* Wow for menu bar init */ 1141 1142 if (($("body").hasClass("appear-animate")) && ($(window).width() >= 1024) && ($("html").hasClass("no-mobile"))){ 1143 $(".wow-menubar").addClass("no-animate").addClass("fadeInDownShort").addClass("animated"); 1144 setInterval(function(){ $(".wow-menubar").removeClass("no-animate"); }, 1500); 1145 } else{ 1146 $(".wow-menubar").css("opacity", "1"); 1147 } 1148 1149 })(jQuery); 1150} 1151 1152 1153/* --------------------------------------------- 1154 Masonry 1155 --------------------------------------------- */ 1156 1157function init_masonry(){ 1158 (function($){ 1159 1160 $(".masonry").imagesLoaded(function(){ 1161 $(".masonry").masonry(); 1162 }); 1163 1164 })(jQuery); 1165} 1166 1167 1168/* --------------------------------------------- 1169 Polyfill for :focus-visible 1170 --------------------------------------------- */ 1171 1172/** 1173 * https://github.com/WICG/focus-visible 1174 */ 1175function init() { 1176 var hadKeyboardEvent = true; 1177 var hadFocusVisibleRecently = false; 1178 var hadFocusVisibleRecentlyTimeout = null; 1179 1180 var inputTypesWhitelist = { 1181 text: true, 1182 search: true, 1183 url: true, 1184 tel: true, 1185 email: true, 1186 password: true, 1187 number: true, 1188 date: true, 1189 month: true, 1190 week: true, 1191 time: true, 1192 datetime: true, 1193 'datetime-local': true 1194 }; 1195 1196 /** 1197 * Helper function for legacy browsers and iframes which sometimes focus 1198 * elements like document, body, and non-interactive SVG. 1199 * @param {Element} el 1200 */ 1201 function isValidFocusTarget(el) { 1202 if ( 1203 el && 1204 el !== document && 1205 el.nodeName !== 'HTML' && 1206 el.nodeName !== 'BODY' && 1207 'classList' in el && 1208 'contains' in el.classList 1209 ) { 1210 return true; 1211 } 1212 return false; 1213 } 1214 1215 /** 1216 * Computes whether the given element should automatically trigger the 1217 * `focus-visible` class being added, i.e. whether it should always match 1218 * `:focus-visible` when focused. 1219 * @param {Element} el 1220 * @return {boolean} 1221 */ 1222 function focusTriggersKeyboardModality(el) { 1223 var type = el.type; 1224 var tagName = el.tagName; 1225 1226 if (tagName == 'INPUT' && inputTypesWhitelist[type] && !el.readOnly) { 1227 return true; 1228 } 1229 1230 if (tagName == 'TEXTAREA' && !el.readOnly) { 1231 return true; 1232 } 1233 1234 if (el.isContentEditable) { 1235 return true; 1236 } 1237 1238 return false; 1239 } 1240 1241 /** 1242 * Add the `focus-visible` class to the given element if it was not added by 1243 * the author. 1244 * @param {Element} el 1245 */ 1246 function addFocusVisibleClass(el) { 1247 if (el.classList.contains('focus-visible')) { 1248 return; 1249 } 1250 el.classList.add('focus-visible'); 1251 el.setAttribute('data-focus-visible-added', ''); 1252 } 1253 1254 /** 1255 * Remove the `focus-visible` class from the given element if it was not 1256 * originally added by the author. 1257 * @param {Element} el 1258 */ 1259 function removeFocusVisibleClass(el) { 1260 if (!el.hasAttribute('data-focus-visible-added')) { 1261 return; 1262 } 1263 el.classList.remove('focus-visible'); 1264 el.removeAttribute('data-focus-visible-added'); 1265 } 1266 1267 /** 1268 * Treat `keydown` as a signal that the user is in keyboard modality. 1269 * Apply `focus-visible` to any current active element and keep track 1270 * of our keyboard modality state with `hadKeyboardEvent`. 1271 * @param {Event} e 1272 */ 1273 function onKeyDown(e) { 1274 if (isValidFocusTarget(document.activeElement)) { 1275 addFocusVisibleClass(document.activeElement); 1276 } 1277 1278 hadKeyboardEvent = true; 1279 } 1280 1281 /** 1282 * If at any point a user clicks with a pointing device, ensure that we change 1283 * the modality away from keyboard. 1284 * This avoids the situation where a user presses a key on an already focused 1285 * element, and then clicks on a different element, focusing it with a 1286 * pointing device, while we still think we're in keyboard modality. 1287 * @param {Event} e 1288 */ 1289 function onPointerDown(e) { 1290 hadKeyboardEvent = false; 1291 } 1292 1293 /** 1294 * On `focus`, add the `focus-visible` class to the target if: 1295 * - the target received focus as a result of keyboard navigation, or 1296 * - the event target is an element that will likely require interaction 1297 * via the keyboard (e.g. a text box) 1298 * @param {Event} e 1299 */ 1300 function onFocus(e) { 1301 // Prevent IE from focusing the document or HTML element. 1302 if (!isValidFocusTarget(e.target)) { 1303 return; 1304 } 1305 1306 if (hadKeyboardEvent || focusTriggersKeyboardModality(e.target)) { 1307 addFocusVisibleClass(e.target); 1308 } 1309 } 1310 1311 /** 1312 * On `blur`, remove the `focus-visible` class from the target. 1313 * @param {Event} e 1314 */ 1315 function onBlur(e) { 1316 if (!isValidFocusTarget(e.target)) { 1317 return; 1318 } 1319 1320 if ( 1321 e.target.classList.contains('focus-visible') || 1322 e.target.hasAttribute('data-focus-visible-added') 1323 ) { 1324 // To detect a tab/window switch, we look for a blur event followed 1325 // rapidly by a visibility change. 1326 // If we don't see a visibility change within 100ms, it's probably a 1327 // regular focus change. 1328 hadFocusVisibleRecently = true; 1329 window.clearTimeout(hadFocusVisibleRecentlyTimeout); 1330 hadFocusVisibleRecentlyTimeout = window.setTimeout(function() { 1331 hadFocusVisibleRecently = false; 1332 window.clearTimeout(hadFocusVisibleRecentlyTimeout); 1333 }, 100); 1334 removeFocusVisibleClass(e.target); 1335 } 1336 } 1337 1338 /** 1339 * If the user changes tabs, keep track of whether or not the previously 1340 * focused element had .focus-visible. 1341 * @param {Event} e 1342 */ 1343 function onVisibilityChange(e) { 1344 if (document.visibilityState == 'hidden') { 1345 // If the tab becomes active again, the browser will handle calling focus 1346 // on the element (Safari actually calls it twice). 1347 // If this tab change caused a blur on an element with focus-visible, 1348 // re-apply the class when the user switches back to the tab. 1349 if (hadFocusVisibleRecently) { 1350 hadKeyboardEvent = true; 1351 } 1352 addInitialPointerMoveListeners(); 1353 } 1354 } 1355 1356 /** 1357 * Add a group of listeners to detect usage of any pointing devices. 1358 * These listeners will be added when the polyfill first loads, and anytime 1359 * the window is blurred, so that they are active when the window regains 1360 * focus. 1361 */ 1362 function addInitialPointerMoveListeners() { 1363 document.addEventListener('mousemove', onInitialPointerMove); 1364 document.addEventListener('mousedown', onInitialPointerMove); 1365 document.addEventListener('mouseup', onInitialPointerMove); 1366 document.addEventListener('pointermove', onInitialPointerMove); 1367 document.addEventListener('pointerdown', onInitialPointerMove); 1368 document.addEventListener('pointerup', onInitialPointerMove); 1369 document.addEventListener('touchmove', onInitialPointerMove); 1370 document.addEventListener('touchstart', onInitialPointerMove); 1371 document.addEventListener('touchend', onInitialPointerMove); 1372 } 1373 1374 function removeInitialPointerMoveListeners() { 1375 document.removeEventListener('mousemove', onInitialPointerMove); 1376 document.removeEventListener('mousedown', onInitialPointerMove); 1377 document.removeEventListener('mouseup', onInitialPointerMove); 1378 document.removeEventListener('pointermove', onInitialPointerMove); 1379 document.removeEventListener('pointerdown', onInitialPointerMove); 1380 document.removeEventListener('pointerup', onInitialPointerMove); 1381 document.removeEventListener('touchmove', onInitialPointerMove); 1382 document.removeEventListener('touchstart', onInitialPointerMove); 1383 document.removeEventListener('touchend', onInitialPointerMove); 1384 } 1385 1386 /** 1387 * When the polfyill first loads, assume the user is in keyboard modality. 1388 * If any event is received from a pointing device (e.g. mouse, pointer, 1389 * touch), turn off keyboard modality. 1390 * This accounts for situations where focus enters the page from the URL bar. 1391 * @param {Event} e 1392 */ 1393 function onInitialPointerMove(e) { 1394 // Work around a Safari quirk that fires a mousemove on <html> whenever the 1395 // window blurs, even if you're tabbing out of the page. ¯\_(ã)_/¯ 1396 if (e.target.nodeName.toLowerCase() === 'html') { 1397 return; 1398 } 1399 1400 hadKeyboardEvent = false; 1401 removeInitialPointerMoveListeners(); 1402 } 1403 1404 document.addEventListener('keydown', onKeyDown, true); 1405 document.addEventListener('mousedown', onPointerDown, true); 1406 document.addEventListener('pointerdown', onPointerDown, true); 1407 document.addEventListener('touchstart', onPointerDown, true); 1408 document.addEventListener('focus', onFocus, true); 1409 document.addEventListener('blur', onBlur, true); 1410 document.addEventListener('visibilitychange', onVisibilityChange, true); 1411 addInitialPointerMoveListeners(); 1412 1413 document.body.classList.add('js-focus-visible'); 1414} 1415 1416/** 1417 * Subscription when the DOM is ready 1418 * @param {Function} callback 1419 */ 1420function onDOMReady(callback) { 1421 var loaded; 1422 1423 /** 1424 * Callback wrapper for check loaded state 1425 */ 1426 function load() { 1427 if (!loaded) { 1428 loaded = true; 1429 1430 callback(); 1431 } 1432 } 1433 1434 if (['interactive', 'complete'].indexOf(document.readyState) >= 0) { 1435 callback(); 1436 } else { 1437 loaded = false; 1438 document.addEventListener('DOMContentLoaded', load, false); 1439 window.addEventListener('load', load, false); 1440 } 1441} 1442 1443if (typeof document !== 'undefined') { 1444 onDOMReady(init); 1445} 1446 1447 1448/* --------------------------------------------- 1449 Adding aria-hidden to Font Awesome 1450 icons 1451 --------------------------------------------- */ 1452 1453(function(){ 1454 let getIcons = document.querySelectorAll('i.fa, i.fab, i.far, i.fas'); 1455 getIcons.forEach(function(iconEach) 1456 { 1457 let getIconAttr = iconEach.getAttribute('aria-hidden'); 1458 if (!getIconAttr) 1459 { 1460 iconEach.setAttribute('aria-hidden','true'); 1461 } 1462 });
vendor: 5 bytes, line 1463
1463})();
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.