1$(function () { 2 /* ========================================================================== 3 links 4 ========================================================================== */ 5 6 links__init(); 7 8 function links__init($context) { 9 $alllinks = $("a").not(".searchpopup-toggle, .mobnav-toggle, .signup__submit"); 10 11 $linksthatwantlines = $("a").not(".noline, .noline a, .line--added, .cli-plugin-button"); 12 $fashapes = $(".fa--shape"); 13 $randomlines = $(".line--random"); 14 15 $linksthatwantlines.each(function () { 16 var $this = $(this); 17 var $icon = $(".fa", $this); 18 19 if ($("img", $this).length < 1) { 20 $this.wrapInner("<span class='linkline'>"); 21 $this.addClass("line--added"); 22 if ($icon.length > 0) { 23 if ($icon.hasClass("fa--left")) { 24 $icon.insertBefore($(".linkline", $this)); 25 } else { 26 $icon.insertAfter($(".linkline", $this)); 27 } 28 } 29 } 30 }); 31 32 //$alllinks.click(function(){ 33 //$('body').removeClass('ready'); 34 // }); 35 36 /* 37 // dummy submit 38 */ 39 $("[data-dummysubmit]").click(function (e) { 40 if (e != undefined) { 41 e.preventDefault(); 42 } 43 if ($(this).hasClass("btn--disabled")) { 44 return false; 45 } 46 $($(this).attr("data-dummysubmit")).trigger("click"); 47 }); 48 49 /* 50 // randomise shapes 51 */ 52 var fashapearray = ["1", "2", "3", "4", "5"]; 53 fashapearray_counter = 0; 54 55 $fashapes.each(function () { 56 $shape = $(this); 57 $shape.addClass("fa--shape--" + fashapearray[fashapearray_counter]); 58 if (fashapearray_counter == fashapearray.length - 1) { 59 fashapearray_counter = 0; 60 } else { 61 fashapearray_counter++; 62 } 63 }); 64 65 /* 66 // randomise line--random 67 */ 68 var linearray = ["line--red", "line--purple", "line--aqua", "line--yellow", "line--teal", "line--pink"]; 69 linearray_counter = 0; 70 71 $randomlines.each(function () { 72 $line = $(this); 73 $line.addClass(linearray[linearray_counter]); 74 if (linearray_counter == linearray.length - 1) { 75 linearray_counter = 0; 76 } else { 77 linearray_counter++; 78 } 79 }); 80 } // links__init() 81 82 /* ========================================================================== 83 pagenav 84 ========================================================================== */ 85 86 $pagenav = $(".pagenav--hideifnone"); 87 88 if ($pagenav.length > 0) { 89 pagenav__init(); 90 } 91 92 function pagenav__init() { 93 if ( 94 $(".current-menu-item.menu-item-has-children, .current-menu-ancestor, .current_page_parent", $pagenav).length > 0 95 ) { 96 // do nothing 97 } else { 98 $pagenav.remove(); 99 } 100 } // pagenav__init(); 101 102 /* ========================================================================== 103 sitefooter 104 ========================================================================== */ 105 106 sitefootershowingclass = "sitefooter--inview"; 107 $sitefooter = $(".sitefooter"); 108 109 $sitefooter.waypoint({ 110 handler: function (direction) { 111 if (direction == "down") { 112 $sitefooter.addClass(sitefootershowingclass); 113 } else { 114 $sitefooter.removeClass(sitefootershowingclass); 115 } 116 }, 117 offset: "90%" 118 }); 119 120 /* ========================================================================== 121 scrolled 122 ========================================================================== */ 123 124 $(document).scroll(function (evt) { 125 var y = $(this).scrollTop(); 126 if (y > 30) { 127 $("body").addClass("hasscrolled"); 128 } else { 129 $("body").removeClass("hasscrolled"); 130 } 131 }); 132 133 /* ========================================================================== 134 heroslides 135 ========================================================================== */ 136 137 $heroslides = $(".herobg"); 138 139 if ($heroslides.length > 0) { 140 $heroslides.cycle({ 141 fx: "fade", 142 speed: 2000, 143 containerResize: false, 144 slideResize: false 145 }); 146 } 147 148 /* ========================================================================== 149 parallax 150 ========================================================================== */ 151 152 $parallax = $(".parallax"); 153 if ($parallax.length > 0) { 154 parallax__init(); 155 } 156 157 function parallax__init() { 158 if (!Modernizr.touch) { 159 $parallax.each(function () { 160 var $this = $(this); 161 if ($this.hasClass("parallax--2")) { 162 $this.parallax("50%", 0.4); 163 } else { 164 $this.parallax("50%", 0.66); 165 } 166 }); 167 } 168 } 169 170 /* ========================================================================== 171 faqs 172 ========================================================================== */ 173 174 $(".faq__question").click(function () { 175 $(this).closest(".faq").toggleClass("faq--open"); 176 }); 177 178 /* ========================================================================== 179 Accordion Carousel
180 ========================================================================== */ 181 182 $(".accordion__question").click(function () { 183 $(this).closest(".accordion").toggleClass("accordion--open"); 184 185 var panel = this.nextElementSibling; 186 if (panel.style.maxHeight) { 187 panel.style.maxHeight = null; 188 panel.style.overflow = "hidden"; 189 } else { 190 panel.style.maxHeight = panel.scrollHeight + "px"; 191 panel.style.overflow = "visible"; 192 } 193 }); 194 195 /* ========================================================================== 196 flexslides 197 ========================================================================== */ 198 199 var $flexslides = $(".flexslides"); 200 201 if ($flexslides.length > 0) { 202 flexslides__init(); 203 } 204 205 function flexslides__init() { 206 $flexslides.each(function () { 207 var $this = $(this); 208 var $this_slidecount = $(".flexslide", $this).length; 209 if ($this_slidecount > 1) { 210 $this.owlCarousel({ 211 loop: true, 212 nav: false, 213 dots: true, 214 items: 1, 215 startPosition: $this_slidecount, 216 //autoplay: true, 217 //autoplayTimeout: 5000, 218 autoHeight: true 219 }); 220 } 221 }); 222 223 $flexslides.on("resized.owl.carousel", function () { 224 $flexslides.trigger("next.owl.carousel"); 225 }); 226 } // flexslides__init() 227 228 /* ========================================================================== 229 mobnav 230 ========================================================================== */ 231 232 var $mobnav = $(".mobnav"); 233 var $mobnavinner = $(".mobnav__bd", $mobnav); 234 var $mobnavtoggle = $(".mobnav-toggle"); 235 var mobnavopenclass = "mobnavopen"; 236 237 mobnav__init(); 238 239 function mobnav__init() { 240 $mobnavtoggle.on("click touchend", function (e) { 241 e.preventDefault(); 242 if ($mobnav.attr("data-status") != "open") { 243 // it's not open 244 $mobnav.height($mobnavinner.outerHeight(false)).attr("data-status", "open"); 245 $("body").addClass(mobnavopenclass); 246 } else { 247 // it's open 248 $mobnav.height(0).attr("data-status", "closed"); 249 $("body").removeClass(mobnavopenclass); 250 } 251 }); 252 253 $(window).resize(mobnav__resize); 254 } // mobnav__init() 255 256 function mobnav__resize() { 257 if ($mobnav.attr("data-status") == "open") { 258 $mobnav.height($mobnavinner.outerHeight(true)).attr("data-status", "open"); 259 } 260 } // mobnav__resize() 261 262 /* ========================================================================== 263 fancybox 264 ========================================================================== */ 265 266 $('a[href$=".jpg"], a[href$=".jpeg"], a[href$=".png"], a[href$=".gif"]').fancybox({ 267 padding: "0", 268 live: true, 269 helpers: { 270 overlay: { 271 locked: false 272 } 273 } 274 }); 275 276 /* ========================================================================== 277 effects 278 ========================================================================== */ 279 280 var $effects = $(".effect"); 281 //var effectwaypoints = false; 282 283 if ($effects.length > 0) { 284 effects__init(); 285 } 286 287 function effects__init() { 288 $effects.each(function () { 289 var $el = $(this); 290 $el.waypoint({ 291 handler: function (direction) { 292 if (direction == "down") { 293 $el.addClass("effect--ready"); 294 } 295 }, 296 offset: "90%" 297 }); 298 }); 299 } // effects__init() 300 301 /* ========================================================================== 302 pageheader background 303 ========================================================================== */ 304 305 // Fadein page header imagec 306 $(".pageheader__img").bgLoaded({ 307 afterLoaded: function () { 308 $("body").addClass("pageheaderimg--loaded"); 309 } 310 }); 311 312 /* ========================================================================== 313 pageheader video background 314 ========================================================================== */ 315 316 var videoisrunning = false; 317 var videosetup = false; 318 var touch = Modernizr.touch; 319 var $videocontainer = $(".pageheader__video"); 320 321 if ($videocontainer.length > 0) { 322 pageheadervideo__init(); 323 } 324 325 function pageheadervideo__init() { 326 if ($videocontainer.length < 1) { 327 $("body").addClass("noyoutube"); 328 return false;
329 } 330 331 if (!touch && $videocontainer.length > 0) { 332 pageheadervideo__setup(); 333 $("body").addClass("has-videoheader"); 334 } else { 335 $("body").addClass("novideo"); 336 } 337 } // hpvideo__init() 338 339 function pageheadervideo__setup() { 340 $videocontainer.vide( 341 { 342 mp4: $videocontainer.attr("data-video-mp4"), 343 webm: $videocontainer.attr("data-video-webm"), 344 ogv: $videocontainer.attr("data-video-ogv"), 345 poster: $videocontainer.attr("data-video-poster") 346 }, 347 { 348 muted: true, 349 loop: true, 350 autoplay: true, 351 position: "50% 50%", 352 resizing: true, 353 posterType: "none" 354 } 355 ); 356 357 var instance = $videocontainer.data("vide"); 358 var videoinstance = instance.getVideoObject(); 359 360 videoinstance.addEventListener( 361 "play", 362 function (e) { 363 $("body").addClass("has-videoheader--playing"); 364 }, 365 true 366 ); 367 368 videosetup = true; 369 videoisrunning = true; 370 } // pageheadervideo__setup() 371 372 /* ========================================================================== 373 popupsearch 374 ========================================================================== */ 375 376 var $searchtoggle = $(".searchpopup-toggle"); 377 var searchtoggleopenclass = "popupsearch--open"; 378 var $searchform = $(".searchpopupform"); 379 var $searchinput = $('input[name="s"]', $searchform); 380 search__init(); 381 382 function search__init() { 383 $searchtoggle.on("click touchend", function (e) { 384 e.preventDefault(); 385 if (!$("body").hasClass(searchtoggleopenclass)) { 386 // it's not open 387 $("body").addClass(searchtoggleopenclass); 388 if (!Modernizr.touch) { 389 $searchinput.focus(); 390 } 391 } else { 392 // it's open 393 $("body").removeClass(searchtoggleopenclass); 394 } 395 }); 396 397 $(".searchsubmit").click(function (e) { 398 e.preventDefault(); 399 $searchform.submit(); 400 }); 401 402 $(document).keyup(function (e) { 403 if ($("body").hasClass(searchtoggleopenclass)) { 404 if (e.keyCode == 27) { 405 $("body").removeClass(searchtoggleopenclass); 406 } 407 408 if (e.keyCode == 13) { 409 $searchform.submit(); 410 } 411 } 412 }); 413 } // search__init() 414 415 /* ========================================================================== 416 newsletter signup 417 ========================================================================== */ 418 419 $signup = $(".signupform"); 420 $signupform = $("form", $signup); 421 $emailfield = $(".signup__field", $signup); 422 $emailinput = $("input", $emailfield); 423 424 signup__init(); 425 426 function signup__init() { 427 $signupform.submit(function (e) { 428 if (!signup__validate_email($emailinput.val())) { 429 e.preventDefault(); 430 $signup.addClass("signupform--invalid"); 431 } else { 432 $signup.removeClass("signupform--invalid"); 433 } 434 }); 435 } // signup__init(); 436 437 function signup__validate_email(email) { 438 var re = 439 /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 440 return re.test(email); 441 } 442 443 /* ========================================================================== 444 clients 445 ========================================================================== */ 446 447 $clientsection = $(".clientsection"); 448 449 if ($clientsection.length > 0) { 450 clients__init(); 451 } 452 453 function clients__init() { 454 $(window).resize(function () { 455 $(".clientsection__client.active").trigger("click"); 456 }); 457 $(".clientsection__client").click(function () { 458 $(".client_blurb").remove(); 459 460 if ($(this).hasClass("active")) { 461 $(".clientsection__client").removeClass("active"); 462 return false; 463 } 464 465 $(".clientsection__client").removeClass("active"); 466 467 var parent_ID = $(this).parents(".clientsection").attr("id"), 468 index = $("#" + parent_ID + " .clientsection__client").index($(this)), 469 copy = $(this).find(".client__copy").html(), 470 pos = 0; 471 472 if (copy != "") { 473 $(this).addClass("active"); 474 475 if ($(window).width() > 1200) { 476 // 5 items per row 477 pos = parseInt(index / 5) * 5; 478 if (pos == 0) 479 $("#" + parent_ID + " .clientsection__client:first-child()").before( 480 '<div class="gd-u gd-u-1 client_blurb"><div class="padder"><div class="copy__wrapper sml"><div class="content fontsize--sml">' + 481 copy + 482 "</div></div></div></div>" 483 ); 484 else 485 $("#" + parent_ID + " .clientsection__client:nth-child(" + pos + ")").after( 486 '<div class="gd-u gd-u-1 client_blurb"><div class="padder"><div class="copy__wrapper sml"><div class="content fontsize--sml">' + 487 copy + 488 "</div></div></div></div>" 489 ); 490 } else if ($(window).width() > 700) { 491 // 4 items per row 492 pos = parseInt(index / 4) * 4; 493 if (pos == 0) 494 $("#" + parent_ID + " .clientsection__client:first-child()").before( 495 '<div class="gd-u gd-u-1 client_blurb"><div class="padder"><div class="copy__wrapper sml"><div class="content fontsize--sml">' + 496 copy + 497 "</div></div></div></div>" 498 ); 499 else 500 $("#" + parent_ID + " .clientsection__client:nth-child(" + pos + ")").after( 501 '<div class="gd-u gd-u-1 client_blurb"><div class="padder"><div class="copy__wrapper sml"><div class="content fontsize--sml">' + 502 copy + 503 "</div></div></div></div>" 504 ); 505 } else if ($(window).width() > 550) { 506 // 3 items per row 507 pos = parseInt(index / 3) * 3; 508 if (pos == 0) 509 $("#" + parent_ID + " .clientsection__client:first-child()").before( 510 '<div class="gd-u gd-u-1 client_blurb"><div class="padder"><div class="copy__wrapper sml"><div class="content fontsize--sml">' + 511 copy + 512 "</div></div></div></div>" 513 ); 514 else 515 $("#" + parent_ID + " .clientsection__client:nth-child(" + pos + ")").after( 516 '<div class="gd-u gd-u-1 client_blurb"><div class="padder"><div class="copy__wrapper sml"><div class="content fontsize--sml">' + 517 copy + 518 "</div></div></div></div>" 519 ); 520 } else { 521 // 2 items per row 522 pos = parseInt(index / 2) * 2; 523 if (pos == 0) 524 $("#" + parent_ID + " .clientsection__client:first-child()").before( 525 '<div class="gd-u gd-u-1 client_blurb"><div class="padder"><div class="copy__wrapper sml"><div class="content fontsize--sml">' + 526 copy + 527 "</div></div></div></div>" 528 ); 529 else 530 $("#" + parent_ID + " .clientsection__client:nth-child(" + pos + ")").after( 531 '<div class="gd-u gd-u-1 client_blurb"><div class="padder"><div class="copy__wrapper sml"><div class="content fontsize--sml">' + 532 copy + 533 "</div></div></div></div>" 534 ); 535 } 536 } 537 }); 538 } 539 540 /* ========================================================================== 541 maps 542 ========================================================================== */ 543 544 var $maps = $(".map"); 545 $maps.each(function () { 546 $map = $(this); 547 var $mapcanvas = $(".map__canvas", $map); 548 var markers = new Array(); 549 var markerbounds; 550 var googlemap; 551 var $tooltip = false;
552 var $tooltip_name = false; 553 var currentmarker = false; 554 var defaultmapzoom = $map.data("defaultzoom") > 0 ? $map.data("defaultzoom") : 3; 555 556 if ($map.length > 0) { 557 map__init(); 558 } 559 560 function map__init() { 561 if ($map.length < 1) { 562 return false; 563 } 564 565 var defaultmapcenter = new google.maps.LatLng(51.521568, -0.135541); 566 567 $mapcanvas.gmap({ 568 center: defaultmapcenter, 569 zoom: defaultmapzoom, 570 styles: mapstyles, 571 backgroundColor: "#340d5c", 572 disableDefaultUI: true, 573 panControl: false, 574 zoomControl: false, 575 scrollwheel: false 576 }); 577 578 if ($("[data-marker]", $map).length > 1) { 579 $("body").append( 580 '<div class="maptooltip"><div class="maptooltip__inner sml"><div class="maptooltip__name"></div></div></div>' 581 ); 582 $tooltip = $(".maptooltip"); 583 $tooltip_name = $(".maptooltip__name", $tooltip); 584 $(".map").mousemove(map__mousemove); 585 } 586 587 $(window).bind("debouncedresize", function () { 588 map__update(); 589 }); 590 591 map__addstories(); 592 } // map__init() 593 594 function map__mousemove(e) { 595 $tooltip.css({ 596 top: e.pageY + 20, 597 left: e.pageX 598 }); 599 } // heromousemove 600 601 function map__addstories() { 602 // init array we will build to create marker bounds later 603 604 $("[data-marker]", $map).each(function (i) { 605 var $marker = $(this); 606 var markerposition = new google.maps.LatLng($marker.data("marker-lat"), $marker.data("marker-lng")); 607 608 if ($marker.data("marker") == "current") { 609 currentmarker = markerposition; 610 } 611 612 $mapcanvas.gmap( 613 "addMarker", 614 { 615 position: markerposition, 616 bounds: false 617 }, 618 function (map, marker) { 619 // callback 620 googlemap = map; 621 var imagelink = $marker.data("marker-img"); 622 623 marker.set("name", $marker.data("marker-name")); 624 marker.set("link", $marker.data("marker-link")); 625 626 // apply marker styles 627 marker.setOptions({ 628 icon: imagelink, 629 title: "" 630 }); 631 632 // build arrray of markers to set bounds later 633 markers.push(markerposition); 634 635 google.maps.event.addListener(marker, "click", function () { 636 var markerlink = marker.get("link"); 637 if (markerlink != "" && markerlink != undefined) { 638 document.location.href = markerlink; 639 } else { 640 return false; 641 } 642 }); 643 644 if ($tooltip) { 645 google.maps.event.addListener(marker, "mouseover", function () { 646 marker.setOptions({ zIndex: 4 }); 647 if (marker.get("name").length > 0 && $(window).width() > 600) { 648 $tooltip_name.html(marker.get("name")); 649 $tooltip.stop(true, false).fadeTo(250, 1); 650 } 651 }); 652 653 google.maps.event.addListener(marker, "mouseout", function () { 654 $tooltip.stop(true, false).fadeTo(250, 0); 655 }); 656 } //if($tooltip) 657 } // end of add marker callback 658 ); // end of add marker 659 }); // end of marker.each() 660 661 markerbounds = new google.maps.LatLngBounds(); 662 for (var i = 0; i < markers.length; i++) { 663 markerbounds.extend(markers[i]); 664 } 665 666 if (googlemap != undefined && currentmarker) { 667 googlemap.setCenter(currentmarker); 668 } else { 669 googlemap.fitBounds(markerbounds); 670 } 671 } //map__addstories() 672 673 function map__update() { 674 if ($map.length < 1) { 675 return false; 676 } 677 if (googlemap != undefined && currentmarker) { 678 googlemap.setCenter(currentmarker); 679 } else { 680 googlemap.fitBounds(markerbounds); 681 } 682 } // map__update() 683 }); // $maps.each(); 684 685 $("body").addClass("ready"); 686}); // Domready 687 688var mapstyles = [ 689 { 690 featureType: "all", 691 elementType: "all", 692 stylers: [ 693 { 694 visibility: "simplified" 695 }, 696 { 697 hue: "#bc00ff" 698 }, 699 { 700 saturation: "0" 701 } 702 ] 703 }, 704 { 705 featureType: "all", 706 elementType: "labels", 707 stylers: [ 708 { 709 visibility: "off" 710 } 711 ] 712 }, 713 { 714 featureType: "administrative", 715 elementType: "all", 716 stylers: [ 717 { 718 visibility: "simplified" 719 } 720 ] 721 }, 722 { 723 featureType: "landscape", 724 elementType: "all", 725 stylers: [ 726 { 727 color: "#3e114e" 728 }, 729 { 730 visibility: "simplified" 731 } 732 ] 733 }, 734 { 735 featureType: "landscape.natural", 736 elementType: "all", 737 stylers: [ 738 { 739 visibility: "simplified" 740 }, 741 { 742 color: "#2e093b" 743 } 744 ] 745 }, 746 { 747 featureType: "landscape.natural.landcover", 748 elementType: "all", 749 stylers: [ 750 { 751 visibility: "simplified" 752 }, 753 { 754 color: "#58176e" 755 } 756 ] 757 }, 758 { 759 featureType: "poi", 760 elementType: "all", 761 stylers: [ 762 { 763 visibility: "off" 764 } 765 ] 766 }, 767 { 768 featureType: "poi.business", 769 elementType: "all", 770 stylers: [ 771 { 772 visibility: "off" 773 } 774 ] 775 }, 776 { 777 featureType: "road", 778 elementType: "all", 779 stylers: [ 780 { 781 saturation: -100 782 }, 783 { 784 lightness: 45 785 } 786 ] 787 }, 788 { 789 featureType: "road", 790 elementType: "geometry", 791 stylers: [ 792 { 793 visibility: "simplified" 794 }, 795 { 796 color: "#a02aca" 797 } 798 ] 799 }, 800 { 801 featureType: "road.highway", 802 elementType: "all", 803 stylers: [ 804 { 805 visibility: "simplified" 806 } 807 ] 808 }, 809 { 810 featureType: "road.highway", 811 elementType: "geometry", 812 stylers: [ 813 { 814 visibility: "simplified" 815 }, 816 { 817 color: "#a02aca" 818 } 819 ] 820 }, 821 { 822 featureType: "road.arterial", 823 elementType: "geometry", 824 stylers: [ 825 { 826 color: "#6d2388" 827 } 828 ] 829 }, 830 { 831 featureType: "transit", 832 elementType: "all", 833 stylers: [ 834 { 835 visibility: "off" 836 } 837 ] 838 }, 839 { 840 featureType: "water", 841 elementType: "all", 842 stylers: [ 843 { 844 color: "#b7918f" 845 }, 846 { 847 visibility: "on" 848 } 849 ] 850 }, 851 { 852 featureType: "water", 853 elementType: "geometry", 854 stylers: [ 855 { 856 color: "#280b33" 857 } 858 ] 859 } 860]; 861 862/* ========================================================================== 863 GTAG for downloads 864 ========================================================================== */ 865$("a[href$='.pdf'], a[href$='.doc']").click(function () { 866 var href = $(this).attr("href"); 867 gtag("event", "download", { event_category: "download", event_action: "pdf", event_label: href }); 868}); 869 870/* ========================================================================== 871 Popup Sign up 872 ========================================================================== */ 873 874// Trigger hidden button to open the sign up popup 875$(document).ready(function () { 876 // Only run if #signup__popup exists 877 if ($("#signup__popup").length) { 878 if ($.cookie("newsletter") != "closed" && $.cookie("newsletter") != "signedup") { 879 window.setTimeout(function () { 880 $.fancybox.open({ 881 src: "#signup__popup", 882 type: "inline", 883 opts: { 884 afterShow: function (instance, current) {}, 885 touch: false 886 } 887 }); 888 }, 9000); 889
890 $(document).off("click.validate", ".nf-form-cont *"); 891 $(document).on("click.nf", "#nf-field-36", function (e) { 892 e.preventDefault(); 893 $(this).closest("form").submit(); // let NF handle real submit 894 }); 895 jQuery(document).on("submit", "form", function (e) { 896 console.log("Form actually submitted:", e.target); 897 }); 898 $("#close__signup__popup").on("click", function (e) { 899 e.preventDefault(); // stop any default action 900 e.stopPropagation(); // stop bubbling up to parent elements 901 e.preventDefault(); 902 parent.$.fancybox.close(); 903 $(".fancybox-bg").hide(); 904 905 // Setting cookie 906 var date = new Date(); 907 date.setMonth(date.getMonth() + 3); // 3 months ahead 908 date.setDate(1); // first of that month 909 910 $.cookie("newsletter", "closed", { expires: date, path: "/" }); 911 }); 912 } 913 } 914}); 915 916var $grid_sizes = { 917 gt420: "700", 918 gt1000: "1000" 919}; 920 921/* ========================================================================== 922 Grid Carousel (Currently used on Featured Posts) 923 ========================================================================== */ 924 925var $grid_carousels = $(".gd-g--carousel .owl-carousel").not(".owl-case-studies"); 926 927if ($grid_carousels.length > 0) { 928 gridcarousel__init(); 929} 930 931function gridcarousel__init() { 932 $grid_carousels.each(function () { 933 var $this = $(this); 934 var $this_slidecount = $(".gd-u", $this).length; 935 if ($this_slidecount > 1) { 936 // We did not use the responsive array because we could not get it to work with the old grid system. 937 $this.owlCarousel({ 938 nav: true, 939 dots: false, 940 navText: ["<i class='fa fal fa-arrow-left'></i>", "<i class='fa fal fa-arrow-right'></i>"], 941 responsive: { 942 0: { 943 items: 1 944 }, 945 600: { 946 items: 2 947 }, 948 1000: { 949 items: 3 950 } 951 }, 952 startPosition: $this_slidecount, 953 autoHeight: true 954 }); 955 } 956 }); 957 958 $grid_carousels.on("resized.owl.carousel", function () { 959 $grid_carousels.trigger("next.owl.carousel"); 960 }); 961} // flexslides__init() 962 963/* ========================================================================== 964 Case Studies Carousel 965 ========================================================================== */ 966 967var $case_carousels = $(".gd-g--carousel .owl-case-studies"); 968 969if ($case_carousels.length > 0) { 970 case_carousels__init(); 971} 972 973function case_carousels__init() { 974 $case_carousels.each(function () { 975 var $this = $(this); 976 var $this_slidecount = $(".gd-u", $this).length; 977 if ($this_slidecount > 1) { 978 // We did not use the responsive array because we could not get it to work with the old grid system. 979 $this.owlCarousel({ 980 nav: true, 981 dots: false, 982 items: 1, 983 navText: ["<i class='fa fal fa-chevron-left'></i>", "<i class='fa fal fa-chevron-right'></i>"], 984 startPosition: $this_slidecount, 985 autoHeight: true 986 }); 987 } 988 }); 989 990 $case_carousels.on("resized.owl.carousel", function () { 991 $case_carousels.trigger("next.owl.carousel"); 992 }); 993} // case_carousels__init() 994 995/* ========================================================================== 996 AJAX load more / paging 997 ========================================================================== */ 998 999$(".paging__loadmore--toolkit").click(function () { 1000 var button = $(this); 1001 var data = { 1002 action: "loadmore", 1003 query: php_variables.posts, // that's how we get params from wp_localize_script() function 1004 page: php_variables.current_page 1005 }; 1006 var button_text; // create variable to store button text 1007 1008 // This AJAX triggers a PHP hook within function-hooks.php called ajax_loadmore_handler 1009 $.ajax({ 1010 url: php_variables.ajax_url, // AJAX handler 1011 data: data, 1012 type: "POST", 1013 beforeSend: function (xhr) { 1014 if (!button.hasClass("paging__loadmore--scailmail")) { 1015 button_text = button.html(); // store current button text 1016 button.text("Loading...");
1016 // change the button text, to let the user know we are loading more posts 1017 } 1018 }, 1019 success: function (data) { 1020 if (data) { 1021 if (!button.hasClass("paging__loadmore--scailmail")) { 1022 button.html(button_text); // set back to previous button text 1023 } 1024 $(".posts-container").append(data); // insert new posts to the posts-container, this should be the row that includes the posts 1025 php_variables.current_page++; 1026 // if last page, remove the button.. 1027 if (parseInt(php_variables.current_page) === parseInt(php_variables.max_page)) { 1028 button.hide(); 1029 } 1030 // Re-init links to make sure linklines on newly loaded content still work 1031 links__init(); 1032 } else { 1033 button.remove(); // if no data, remove the button as well 1034 } 1035 } 1036 }); 1037}); 1038 1039/* ========================================================================== 1040 FILTERING - URL Parameter functions 1041 ========================================================================== */ 1042 1043/* UPDATE URL PARAMETERS */ 1044function filters__update_url(filter_data, search_data, submitted) { 1045 var url_params = ""; 1046 1047 $.each(filter_data, function (key, value) { 1048 if (!$.isEmptyObject(value)) { 1049 if (url_params === "") { 1050 url_params = url_params + "?"; 1051 } else { 1052 url_params = url_params + "&"; 1053 } 1054 // Convert values to comma seperated string 1055 let values = Object.keys(value) 1056 .map(function (k) { 1057 return value[k]; 1058 }) 1059 .join(","); 1060 url_params = url_params + "filter_" + key + "=" + values; 1061 } 1062 }); 1063 1064 if (search_data) { 1065 if (url_params === "") { 1066 url_params = url_params + "?"; 1067 } else { 1068 url_params = url_params + "&"; 1069 } 1070 url_params = url_params + "search=" + search_data; 1071 } 1072 1073 var action_url = $(".filters").attr("action"); 1074 1075 if (submitted && page_url != action_url) { 1076 // window.location.replace(action_url + url_params); 1077 1078 var $filterPin = $(".filters-pin"); 1079 1080 if ($filterPin.length) { 1081 var scrollTop = $filterPin.offset().top - 200; 1082 1083 $("html, body").animate( 1084 { 1085 scrollTop: scrollTop 1086 }, 1087 600 1088 ); 1089 } 1090 } 1091 1092 var page_url = window.location.href.split("?")[0]; 1093 var new_url = page_url + url_params; 1094 1095 if (history.pushState) { 1096 window.history.pushState({ path: new_url }, "", new_url); 1097 } 1098} 1099 1100/* ========================================================================== 1101 FILTERING - Filter posts 1102 ========================================================================== */ 1103 1104// Scalemail category filters should behave like a single-select list. 1105function filters__normalise_scalemail_filters(form, selectedInput) { 1106 let $forms = form && form.length ? form.filter(".filters--scalemail") : $(".filters--scalemail"); 1107 1108 $forms.each(function () { 1109 let $checkedFilters = $(this).find("input[type=checkbox]:checked"); 1110 let $selectedFilter = 1111 selectedInput && $.contains(this, selectedInput) && $(selectedInput).is(":checked") 1112 ? $(selectedInput) 1113 : $checkedFilters.first(); 1114 1115 $(this).find(".filters__clearall").toggleClass("filters__fieldset__field--active", !$selectedFilter.length); 1116 1117 if ($selectedFilter.length) { 1118 $checkedFilters 1119 .not($selectedFilter) 1120 .prop("checked", false) 1121 .closest(".filters__fieldset__field") 1122 .removeClass("filters__fieldset__field--active"); 1123 } 1124 }); 1125} 1126 1127// Get current filters data from form inputs 1128function filters__get_filter_data(form, filters) { 1129 filters__normalise_scalemail_filters(form); 1130 1131 let filter_data = {}; 1132 $(filters).each(function () { 1133 filter_data[this.name] = {}; 1134 $("input[type=checkbox][name=" + this.name + "]:checked").each(function (index) { 1135 filter_data[this.name][index] = $(this).val(); 1136 }); 1137 }); 1138 return filter_data; 1139} 1140 1141// Setup styling classes on new filter 1142function filters__update_styling(filter_data) { 1143 // Reset styles 1144 $(".filters__fieldset").removeClass("filters__fieldset--active"); 1145 $(".filters__fieldset__field").removeClass("filters__fieldset__field--active"); 1146 1147 // Reset tags 1148 $(".filters__tags").removeClass("filters__tags--active"); 1149 $(".filters__activetags__tags").html(""); 1150 1151 $.each(filter_data, function (key, values) { 1152 if (!$.isEmptyObject(values)) { 1153 let filter_name = key; 1154 // Make field group active 1155 $(".filters__fieldset[data-value='" + key + "']").addClass("filters__fieldset--active"); 1156 $.each(values, function (key, value) { 1157 // Make input field active 1158 let filter_input = $("input[name='" + filter_name + "'][value='" + value + "']").closest( 1159 ".filters__fieldset__field" 1160 ); 1161 $(filter_input).addClass("filters__fieldset__field--active"); 1162 // Show active tags 1163 $(".filters__tags").addClass("filters__tags--active"); 1164 // Add tag 1165 let filter_input_name = $(filter_input).find(".filters__fieldset__field__label").html(); 1166 $(".filters__activetags__tags").append( 1167 "<div class='filters__tag filters__tag--" + 1168 value + 1169 "' data-name='" + 1170 filter_name + 1171 "' data-value='" + 1172 value + 1173 "'>" + 1174 filter_input_name + 1175 "</div>" 1176 ); 1177 }); 1178 } 1179 }); 1180} 1181 1182function filters__filter_posts(submitted = false) { 1183 // Get filters and search passed in to main.js via filters.php 1184 let filters = filter_settings.filters; 1185 let search = filter_settings.search; 1186 1187 let filter_data = filters__get_filter_data($(".filters"), filters); 1188 1189 let search_data = false;
1190 if (search) { 1191 search_data = $(".filters__search input").val(); 1192 } 1193 1194 if (filter_data || search_data) { 1195 // Update filter styling and tags 1196 filters__update_styling(filter_data); 1197 1198 // Update url 1199 filters__update_url(filter_data, search_data, submitted); 1200 1201 // If is initial load and there is active tags on search data then trigger ajax, if not initial load then trigger everytime 1202 if ( 1203 (filters_initial_load && ($(".filters__tags").hasClass("filters__tags--active") || search_data)) || 1204 !filters_initial_load 1205 ) { 1206 filters_initial_load = false; 1207 1208 // If there's an active search, open the search field 1209 if (search_data) { 1210 $(".filters__search").addClass("filters__search--open"); 1211 } 1212 1213 // Start filtering 1214 $(".posts-container").addClass("filtering"); 1215 1216 // Trigger ajax 1217 var data = { 1218 action: "filter", 1219 query: php_variables.posts, // that's how we get params from wp_localize_script() function in enqueue-scripts.php 1220 page: php_variables.current_page, 1221 filter_settings: filter_settings, // passed in via wp_localize_script in filters.php 1222 filter_data: filter_data, 1223 search_data: search_data 1224 }; 1225 1226 $.ajax({ 1227 url: php_variables.ajax_url, 1228 data: data, // form data 1229 dataType: "json", // this data type allows us to receive objects from the server 1230 type: "POST", 1231 beforeSend: function (xhr) { 1232 $(".filters").find("button").text("Filtering..."); 1233 }, 1234 success: function (data) { 1235 // when filter applied: 1236 // set the current page to 1 1237 php_variables.current_page = 1; 1238 1239 // set the new query parameters 1240 php_variables.posts = data.posts; 1241 1242 // set the new max page parameter 1243 php_variables.max_page = data.max_page; 1244 1245 // change the button label back 1246 $(".filters").find("button").text("Apply filter"); 1247 1248 // insert the posts to the container 1249 $(".posts-container").html(data.content); 1250 1251 // hide load more button, if there are not enough posts for the second page 1252 if (data.max_page < 2) { 1253 $(".paging__loadmore").hide(); 1254 } else { 1255 $(".paging__loadmore").show(); 1256 } 1257 1258 // Loop through the page numbers and hide if necessary 1259 $(".page-numbers").each(function () { 1260 const id = $(this).attr("id"); 1261 if (id && id.startsWith("number-")) { 1262 const num = parseInt(id.replace("number-", "")); 1263 if (num > data.max_page) { 1264 $(this).hide(); 1265 } else { 1266 $(this).show(); 1267 } 1268 } 1269 }); 1270 1271 // Finish filtering 1272 $(".posts-container").removeClass("filtering"); 1273 }, 1274 error: function (data) {} 1275 }); 1276 } 1277 } 1278} 1279 1280// Setup an trigger filtering 1281let filters_initial_load = true; 1282 1283if ($(".filters").length) { 1284 // Filter on page load 1285 filters__filter_posts(); 1286 1287 // Filter on submit 1288 $(".filters").submit(function (e) { 1289 filters__filter_posts(true); 1290 1291 // do not submit the form 1292 return false; 1293 }); 1294 1295 if (window.location.search.includes("filter_category")) { 1296 var $filterPin = $(".filters-pin"); 1297 1298 if ($filterPin.length) { 1299 var scrollTop = $filterPin.offset().top - 200; 1300 1301 $("html, body").animate( 1302 { 1303 scrollTop: scrollTop 1304 }, 1305 600 1306 ); 1307 } 1308 } 1309 1310 $(".filters__submit").click(function () { 1311 $(".filters").submit(); 1312 // Close dropdown 1313 $(".filters").removeClass("filters--dropdownopen"); 1314 }); 1315 1316 // Submit for on checkbox click 1317 $(".filters").on("change", "input:checkbox", function () { 1318 filters__normalise_scalemail_filters($(this).closest(".filters"), this); 1319 1320 if ($(this).is(":checked")) { 1321 $(this).closest(".filters__fieldset__field").addClass("filters__fieldset__field--active"); 1322 } else { 1323 $(this).closest(".filters__fieldset__field").removeClass("filters__fieldset__field--active"); 1324 } 1325 1326 if ($("body").hasClass("page-template-template-scalemail")) { 1327 filters__filter_posts(true); 1328 } 1329 }); 1330 1331 // Dropdown open & close 1332 (() => { 1333 const navSearchButton = document.querySelector(".filters__dropdownbtn"); 1334 const searchDropdown = document.querySelector(".filters__dropdown"); 1335 const form = document.querySelector(".filters"); 1336 1337 const toggleSearch = event => { 1338 event.stopPropagation(); 1339 1340 if (!event.target.closest(".filters__dropdown")) { 1341 searchDropdown.classList.toggle("is-active"); 1342 navSearchButton.classList.toggle("is-active"); 1343 1344 searchDropdown.classList.contains("is-active") 1345 ? document.addEventListener("click", toggleSearch) 1346 : document.removeEventListener("click", toggleSearch); 1347 1348 navSearchButton.classList.contains("is-active") 1349 ? document.addEventListener("click", toggleSearch) 1350 : document.removeEventListener("click", toggleSearch); 1351 } else { 1352 } 1353 }; 1354 1355 if (navSearchButton) { 1356 navSearchButton.addEventListener("click", toggleSearch); 1357 } 1358 })(); 1359 1360 // Search open & close 1361 $(".filters__search__icon").click(function () { 1362 if ($(this).closest(".filters__search").hasClass("filters__search--open")) { 1363 $(this).closest(".filters__search").removeClass("filters__search--open"); 1364 } else { 1365 $(this).closest(".filters__search").addClass("filters__search--open"); 1366 $(this).closest(".filters__search").find("input").focus(); 1367 } 1368 }); 1369 1370 // Remove tags on click 1371 $(".filters__activetags__tags").on("click", ".filters__tag", function () { 1372 let filter_name = $(this).data("name"); 1373 let filter_value = $(this).data("value"); 1374 // Unselect input checkbox 1375 let filter_input = $("input[name='" + filter_name + "'][value='" + filter_value + "']").prop("checked", false); 1376 // Remove tag 1377 $(this).remove(); 1378 // Trigger filter 1379 filters__filter_posts(); 1380 }); 1381 1382 // Clear all 1383 $(".filters__clearall").click(function () { 1384 // Clear search 1385 $(".filters__search").find("input").val(""); 1386 $(".filters__search").removeClass("filters__search--open"); 1387 // Remove all tags 1388 $(".filters__tags").removeClass("filters__tags--active"); 1389 $(".filters__activetags__tags").html(""); 1390 // Uncheck all inputs 1391 $(".filters input").prop("checked", false); 1392 // Trigger filter 1393 filters__filter_posts(); 1394 }); 1395} 1396 1397$stagegif = $(".stagegif"); 1398 1399if ($stagegif.length > 0) { 1400 new Freezeframe(".stagegif"); 1401} 1402 1403/* ========================================================================== 1404 Case Studies Carousel
1405 ========================================================================== */ 1406 1407var $quoteCarousel = $(".flexquote--carousel .quote__carousel"); 1408 1409if ($quoteCarousel.length > 0) { 1410 quoteCarousel__init(); 1411} 1412 1413function quoteCarousel__init() { 1414 $quoteCarousel.each(function () { 1415 var $this = $(this); 1416 var $this_slidecount = $(".quote", $this).length; 1417 if ($this_slidecount > 1) { 1418 // We did not use the responsive array because we could not get it to work with the old grid system. 1419 $this.owlCarousel({ 1420 nav: false, 1421 dots: false, 1422 items: 1, 1423 navText: ["<i class='fa fal fa-chevron-left'></i>", "<i class='fa fal fa-chevron-right'></i>"], 1424 startPosition: $this_slidecount, 1425 autoHeight: false, 1426 autoplay: false, 1427 autoplayTimeout: 6000, 1428 loop: true, 1429 responsive: { 1430 0: { 1431 items: 1 1432 }, 1433 700: { 1434 items: 2 1435 } 1436 } 1437 }); 1438 } 1439 }); 1440 1441 $quoteCarousel.on("resized.owl.carousel", function () { 1442 $quoteCarousel.trigger("next.owl.carousel"); 1443 }); 1444} // quoteCarousel__init()
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.