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