/* ==========================================================================
Document Ready
========================================================================== */
jQuery(document).ready(function($){
/**** Global Elements ****/
/* Global Variables */
var $window = $(window);
var body = $('body');
var globalHeader = $('header.global');
var globalFooter = $('footer.global');
/* Navigation */
// Variables
var menu = $('nav.primary');
var menuParentItem = menu.find('.menu > .menu-item-has-children');
var menuParentItemA = menu.find('.menu > .menu-item-has-children > a');
var subMenu = menu.find('.menu > .menu-item-has-children > .sub-menu');
/* [HANDLED WITH CSS NOW]
// Position submenus
$window.on('load resize', function(){
subMenu.each(function(){
var leftOffset = $(this).outerWidth()/2;
$(this).css('margin-left', -leftOffset);
});
});
*/
/* [DEPRECATED HOVER FUNCTIONALITY]
// Handle dropdowns
$window.on('load resize', function(){
// Menu is mobile, use clicks to operate
if( menu.css('position') == 'fixed' )
{
// Unbind desktop events
menuParentItemA.off();
menuParentItem.off();
// Handle menu item clicks
menuParentItemA.click(function(e){
e.preventDefault();
if(! $(this).hasClass('active') )
{
menuParentItemA.removeClass('active');
subMenu.slideUp();
}
$(this).toggleClass('active');
$(this).next('.sub-menu').slideToggle();
});
}
// Menu is not mobile, use hover to operate
else
{
// Unbind mobile event
menuParentItemA.off();
// Prevent clicks
menuParentItemA.click(function(e){
e.preventDefault();
});
// Handle hover
menuParentItem.hover(
function(){
$(this).children('a').addClass('active');
$(this).children('.sub-menu').slideDown();
},
function(){
$(this).children('a').removeClass('active');
$(this).children('.sub-menu').slideUp();
}
);
}
});
*/
// Set click behavior for menu parents
$('nav.primary .menu > li.menu-item-has-children > a').click(function(e){
e.preventDefault();
if(! $(this).hasClass('active') )
{
$('nav.primary li.menu-item-has-children > a').removeClass('active');
$('nav.primary .sub-menu').slideUp();
$('nav.primary li.current-menu-item').removeClass('inactive');
$('nav.primary li.current-menu-parent').removeClass('inactive');
}
$('nav.primary li.current-menu-item').toggleClass('inactive');
$('nav.primary li.current-menu-parent').toggleClass('inactive');
$(this).toggleClass('active');
$(this).next('.sub-menu').slideToggle("fast");
});
$('nav.primary .menu > li.menu-item-has-children > .sub-menu > .menu-item-has-children > a').click(function(e){
e.preventDefault();
if(! $(this).hasClass('active') )
{
$('nav.primary .menu > li.menu-item-has-children > .sub-menu > .menu-item-has-children > a').removeClass('active');
// $('nav.primary .sub-menu').slideUp();
$('nav.primary li.current-menu-item').removeClass('inactive');
$('nav.primary li.current-menu-parent').removeClass('inactive');
}
$('nav.primary li.current-menu-item').toggleClass('inactive');
$('nav.primary li.current-menu-parent').toggleClass('inactive');
$(this).toggleClass('active');
$(this).next('.sub-menu').slideToggle("fast");
});
// Kill submenus with any click outside of the nav
$(document).mouseup(function(e)
{
var nav = $('nav.primary');
if (! nav.is(e.target) && nav.has(e.target).length === 0)
{
$('nav.primary li.menu-item-has-children > a').removeClass('active');
$('nav.primary .sub-menu').slideUp();
$('nav.primary li.current-menu-item').removeClass('inactive');
$('nav.primary li.current-menu-parent').removeClass('inactive');
}
});
// Mobile Nav Toggle
var toggle = $('#mobile-nav-toggle');
var menus = $('nav.primary, nav.utility');
toggle.click(function(e) {
e.preventDefault();
$(this).toggleClass('active');
menus.fadeToggle();
})
// Intialize Scroll Intent
$window.scrollIntent();
// Add class to header on scroll
$window.scroll(function(){
if( $window.scrollTop() >= 200 ) {
globalHeader.addClass('scrolled');
} else {
globalHeader.removeClass('scrolled');
}
});
// Append Large Menu Items to Primary Nav Submenus
$window.on('load', function(){
// Solutions Menu Handling
var solutionsMenuLinkout = $('.solution-menu-linkout');
var solutionsMenuDescription = $('.solution-menu-description');
var solutionsSubmenu = $('#menu-main-menu .menu-item.solutions .sub-menu')
solutionsSubmenu.each(function(){
var menuItems = $(this).find('.menu-item');
$(this).wrapInner("
");
menuItems.wrapAll("");
solutionsMenuDescription.prependTo('#menu-main-menu .menu-item.solutions .sub-menu > .container');
solutionsMenuLinkout.appendTo('#menu-main-menu .menu-item.solutions .sub-menu > .container');
});
// Service Menu Handling
var servicesMenuLinkout = $('.services-menu-linkout');
var servicesMenuDescription = $('.services-menu-description');
var servicesSubmenu = $('#menu-main-menu .menu-item.services .sub-menu')
servicesSubmenu.each(function(){
var menuItems = $(this).find('.menu-item');
$(this).wrapInner("");
menuItems.wrapAll("");
servicesMenuDescription.prependTo('#menu-main-menu .menu-item.services .sub-menu > .container');
servicesMenuLinkout.appendTo('#menu-main-menu .menu-item.services .sub-menu > .container');
});
// About Menu Handling
var aboutMenuLinkout = $('.about-menu-linkout');
var aboutMenuDescription = $('.about-menu-description');
var aboutSubmenu = $('#menu-main-menu .menu-item.about .sub-menu')
aboutSubmenu.each(function(){
var menuItems = $(this).find('.menu-item');
$(this).wrapInner("");
menuItems.wrapAll("");
aboutMenuDescription.prependTo('#menu-main-menu .menu-item.about .sub-menu > .container');
aboutMenuLinkout.appendTo('#menu-main-menu .menu-item.about .sub-menu > .container');
});
});
//Subnav Menu Handling
var govserviceTrigger = $('.govservice-trigger');
var govmeetingsTrigger = $('.govmeetings-trigger');
var serviceLinkout = $('.govservice-linkout');
govserviceTrigger.on('click', function(e){
e.preventDefault();
var $this = $(this);
var targetSubnav = $('.subnav.govservice');
if($this.hasClass('active') ) {
$(this).toggleClass('active');
targetSubnav.slideToggle("fast");
$('.govservice-linkout').slideToggle("fast");
} else {
$('.subnav-trigger').removeClass('active');
$('.govservice-linkout').slideUp("fast");
$('.subnav').slideUp("fast");
$(this).toggleClass('active');
targetSubnav.slideToggle("fast");
}
});
govmeetingsTrigger.on('click', function(e){
e.preventDefault();
var $this = $(this);
var targetSubnav = $('.subnav.govmeetings');
if($this.hasClass('active') ) {
$(this).toggleClass('active');
targetSubnav.slideToggle("fast");
$('.govservice-linkout').slideToggle("fast");
} else {
$('.subnav-trigger').removeClass('active');
$('.govservice-linkout').slideUp("fast");
$('.subnav').slideUp("fast");
$(this).toggleClass('active');
targetSubnav.slideToggle("fast");
}
});
// Kill clicks on footer menu parent items
var columnHeader = $('nav.footer .column > a');
columnHeader.click(function(e) {
e.preventDefault();
});
/* Add a wrapper around each select element so we can style them better
REMOVED DUE TO LACK OF MARKETO SUPPORT
$('select').each(function(){
$(this).wrap('');
});
*/
/* Utility Functions */
var backToTop = $("a[href='#top']");
backToTop.click(function(e) {
$('html, body').animate({
scrollTop: 0
}, 800);
return false;
});
/* Utility Functions */
var solutionCta = $("a[href='#solution-cta']");
solutionCta.click(function(e) {
e.preventDefault();
console.log('hey');
var $solutionSection = $('#solution-cta');
var $solutionSectionPosition = $solutionSection.offset();
$('html, body').animate({
scrollTop: $solutionSectionPosition.top - 140
}, 800);
return false;
});
// Add smooth scrolling to all links
$(".toc-link").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
var hash = this.hash;
var cleanHash = hash.substring(1);
var d = document.getElementById(cleanHash);
var topPos = d.offsetTop - 150;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: topPos
}, 800, function(){});
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
} // End if
});
/* Generic On Scroll Animations */
// Cards
var cards = $('.cards').not('.post-tiles').not('.home-cards');
if( cards.length )
{
var card = cards.find('.card');
var delay = 0;
$window.load(function(){
card.addClass('animation-ready');
});
$window.on('scroll resize', function(){
if( topIsInViewport(cards) )
{
if( ! card.hasClass('animate') )
{
card.each(function(index)
{
(function(that, i) {
var t = setTimeout(function() {
$(that).addClass('animate');
}, 300 * i);
})(this, index);
});
}
}
});
}
// Mosaic Photo Grid
var mosaic = $('#photo-grid');
if( mosaic.length )
{
var mosaicItem = mosaic.find('.photo, a');
var delay = 0;
$window.load(function(){
mosaicItem.addClass('animation-ready');
});
$window.on('scroll resize', function(){
if( topIsInViewport(mosaic) )
{
if( ! mosaicItem.hasClass('animate') )
{
mosaicItem.each(function(index)
{
(function(that, i) {
var t = setTimeout(function() {
$(that).addClass('animate');
}, 300 * i);
})(this, index);
});
}
}
});
}
//.from-left class
var fromLeft = $('.from-left');
fromLeft.addClass('animation-ready');
$window.scroll(function() {
fromLeft.each(function(){
var $this = $(this);
if( topIsInViewport($this) ) {
$this.addClass('animate');
}
});
});
//.from-right class
var fromRight = $('.from-right');
fromRight.addClass('animation-ready');
$window.scroll(function() {
fromRight.each(function(){
var $this = $(this);
if( topIsInViewport($this) ) {
$this.addClass('animate');
}
});
});
//.from-bottom class
var fromBottom = $('.from-bottom');
fromBottom.addClass('animation-ready');
$window.scroll(function() {
fromBottom.each(function(){
var $this = $(this);
if( topIsInViewport($this) ) {
$this.addClass('animate');
}
});
});
//.scale-in class
var scaleIn = $('.scale-in');
scaleIn.addClass('animation-ready');
$window.scroll(function() {
scaleIn.each(function(){
var $this = $(this);
if( topIsInViewport($this) ) {
$this.addClass('animate');
}
});
});
/* Modals */
var openModal = $('.open-modal');
var closeModal = $('.close-modal');
openModal.click(function(e){
var id = $(this).attr('data-id');
var modal = $('.modal[data-id="'+id+'"]');
e.preventDefault();
body.addClass('no-scroll');
modal.fadeIn();
});
closeModal.click(function(e){
var modal = $(this).parents('.modal');
var iframe = modal.contents().find('iframe');
e.preventDefault();
modal.fadeOut();
body.removeClass('no-scroll');
if( iframe.length )
{
$(iframe).attr("src", $(iframe).attr("src")); // strip and replace the src of the iframe when modal is closed
}
});
/* Subscribe Popover */
var subscribe = $('aside.share .sub');
var popover = $('aside.share .subscribe-pop-over')
subscribe.click(function(e){
e.preventDefault();
popover.toggleClass('active');
});
/* Toggle Search */
var search = $('.post-filters .form-field.search');
var searchToggle = $('.post-filters #search-toggle');
searchToggle.click(function(e){
e.preventDefault();
search.toggleClass('active');
searchToggle.toggleClass('active');
});
/* Toggle Filters */
var filters = $('.post-filters .form');
var filterToggle = $('.post-filters .toggle-filters');
filterToggle.click(function(e){
e.preventDefault();
filters.toggleClass('active');
$(this).toggleClass('active');
});
/**** AJAX FILTERING ****/
/* Global */
// Search
$('#searchform').ajaxFilterLoadMore({
'type' : 'submit'
});
// Load More
$('#load').ajaxFilterLoadMore({
'type' : 'load'
});
/* Blog */
// Category Filter
$('#blog-category').ajaxFilterLoadMore({
'postType' : 'post',
'numberPosts' : 9
});
/* Success Stories */
// Search
$('#successSearchForm').ajaxFilterLoadMore({
'type' : 'submit',
'postType' : 'success_story'
});
// Level Filter
$('.success #level').ajaxFilterLoadMore({
'postType' : 'success_story',
'numberPosts' : 9
});
// Region Filter
$('.success #region').ajaxFilterLoadMore({
'postType' : 'success_story',
'numberPosts' : 9
});
// Area Filter
$('.success #area').ajaxFilterLoadMore({
'postType' : 'success_story',
'numberPosts' : 9
});
// Reset
$('#reset-success').ajaxFilterLoadMore({
'type' : 'reset',
'postType' : 'success_story',
'numberPosts' : 9
});
/* Events */
// Event Type
$('#event_type').ajaxFilterLoadMore({
'postType' : 'event',
'numberPosts' : 6
});
/* Resources */
// Override global load more to show 6 posts per page
$('.page-template-resources #load').off();
$('.page-template-resources #load').ajaxFilterLoadMore({
'type' : 'load',
'numberPosts' : 6
});
// Resource Type Filter
$('#resource_type').ajaxFilterLoadMore({
'postType' : 'resource',
'numberPosts' : 6
});
// Resource Topic Filter
$('#resource_topic').ajaxFilterLoadMore({
'postType' : 'resource',
'numberPosts' : 6
});
// Override global load more to show 6 posts per page
$('.page-template-virtual-events #load').off();
$('.page-template-virtual-events #load').ajaxFilterLoadMore({
'type' : 'load',
'numberPosts' : 6,
preFiltered : true,
preFilteredType : 'taxonomy',
preFilteredKey : 'resource_type',
preFilteredField : 'slug',
preFilteredOperator : 'IN',
preFilteredValue : 'on-demand-webinar',
});
$('.page-template-virtual-events #searchform').off();
$('.page-template-virtual-events #searchform').ajaxFilterLoadMore({
'type' : 'submit',
'numberPosts' : 6,
preFiltered : true,
preFilteredType : 'taxonomy',
preFilteredKey : 'resource_type',
preFilteredField : 'slug',
preFilteredOperator : 'IN',
preFilteredValue : 'on-demand-webinar',
});
// Region Filter
$('.resources #region').ajaxFilterLoadMore({
'postType' : 'resource',
'numberPosts' : 6
});
// Area Filter
$('.resources #area').ajaxFilterLoadMore({
'postType' : 'resource',
'numberPosts' : 6
});
// Reset
$('#reset-resources').ajaxFilterLoadMore({
'type' : 'reset',
'postType' : 'resource',
'numberPosts' : 6
});
/* Pre-select AJAX filters with URL parameters */
jQuery(function() {
function getQueryParams(qs) {
qs = qs.split("+").join(" ");
var params = {},
tokens,
re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])]
= decodeURIComponent(tokens[2]);
}
return params;
}
var $_GET = getQueryParams(document.location.search);
if($_GET['resource_type'])
{
jQuery('#resource_type').val($_GET['resource_type']);
jQuery('#resource_type').change();
}
if($_GET['region'])
{
jQuery('#region').val($_GET['region']);
jQuery('#region').change();
}
if($_GET['area'])
{
jQuery('#area').val($_GET['area']);
jQuery('#area').change();
}
if($_GET['government_level'])
{
jQuery('#level').val($_GET['government_level']);
jQuery('#level').change();
}
});
/* Post Tile Track */
var postTiles = $('.post-tiles');
if( postTiles.length )
{
postTiles.each(function(){
var track = $(this).find('.track');
var trackWidth = track.get(0).scrollWidth;
var controls = $(this).find('.controls');
var scrollLeft = controls.find('.scroll.left');
var scrollRight = controls.find('.scroll.right');
// Determine whether or not to show controls and how to position track
$window.on('load resize', function(){
if( $window.width() < trackWidth ) {
var initialScroll = (trackWidth - $window.width())/2;
} else {
var initialScroll = 0;
controls.hide();
}
track.scrollLeft(initialScroll);
});
// Scroll left using button
scrollLeft.click(function(e){
currentPosition = track.scrollLeft();
newPosition = currentPosition - 600;
track.animate({
scrollLeft: newPosition
}, 500);
scrollRight.removeClass('disabled');
if( newPosition <= 0 ) {
$(this).addClass('disabled');
}
});
// Scroll right using button
scrollRight.click(function(e){
currentPosition = track.scrollLeft();
newPosition = currentPosition + 600;
track.animate({
scrollLeft: newPosition
}, 500);
scrollLeft.removeClass('disabled');
if( newPosition >= (trackWidth - $window.width()) ) {
$(this).addClass('disabled');
}
});
});
}
/**** Single Level Post ****/
// Equalize Tile Heights
if( $('.single-level #success-stories .tiles').length ) {
$window.on('load resize', function(){
//$('#success-stories .tile').css('height', 'auto');
//equalizeHeight($('#success-stories .tile'));
});
}
// Solutions Feature Animations
var solutions = $('.single-level #solutions');
if( solutions.length )
{
var feature = $('#solutions .feature .content');
feature.addClass('animation-ready');
$window.on('scroll resize', function(){
feature.each(function(){
if( topIsInViewport($(this)) ) {
$(this).addClass('animate');
};
});
});
}
/**** Single Success Story Post ****/
// Media Gallery Slider
$('.single-success_story aside.gallery .slides').slick({
dots: true,
appendArrows: '.single-success_story aside.gallery',
appendDots: '.single-success_story aside.gallery'
});
$('.single-resource aside.gallery .slides').slick({
dots: true,
appendArrows: '.single-resource aside.gallery',
appendDots: '.single-resource aside.gallery'
});
/*
// Screenshot Animations
var screenshots = $('.single-success_story #results-1');
if( screenshots.length )
{
var screenshot = $('.single-success_story #results-1 .screenshot img');
$window.load(function(){
screenshot.addClass('animation-ready');
});
$window.on('scroll resize', function(){
screenshot.each(function(){
if( isInViewport($(this)) ) {
$(this).addClass('animate');
};
});
});
}
*/
//Results count and animations
var results2 = $('.single-success_story #results-2');
if( results2.length )
{
//var result = $('.single-success_story #results-2 .number');
var quote = $('.single-success_story #results-2 .quote');
$window.load(function(){
//result.addClass('animation-ready');
quote.addClass('animation-ready');
});
$window.on('scroll resize', function(){
/*
result.each(function(){
if( isInViewport($(this)) ) {
var count = $(this).data('count'),
numAnim = new CountUp(this, 0, count);
numAnim.start();
};
});
*/
if(topIsInViewport(quote) ) {
quote.addClass('animate'); //animates the quote section
};
});
}
/**** Blog Page & Success Stories Page ****/
// Radial Images
if( $('body.blog, body.page-template-success-stories').length )
{
var radialOne = $('body > .radial:first-child');
$window.on('load resize', function(){
radialOnePos = $('#cta').offset().top - 900;
//console.log(radialOne);
radialOne.addClass('left');
radialOne.css({'top': radialOnePos, 'z-index': 0});
radialOne.fadeIn();
});
}
/**** Events Page ****/
// Radial Images
if( $('body.page-template-resources').length )
{
var radialOne = $('body > .radial:first-child');
$window.on('load resize', function(){
radialOnePos = $('#resource-categories').offset().top - 400;
//console.log(radialOne);
radialOne.addClass('left');
radialOne.css('top', radialOnePos);
radialOne.fadeIn();
});
}
// Resource Slider
$('.post-slider').each(function(){
var container = $(this);
var nav = $(this).find('nav.post-slider_nav');
var slider = $(this).find('.post-slider_carousel');
slider.slick({
appendArrows: nav,
dots: false,
infinite: false,
speed: 300,
slidesToShow: 3,
slidesToScroll: 1,
// the magic
responsive: [{
breakpoint: 1000,
settings: {
slidesToShow: 1,
}
}]
});
});
/**** Single Service Post ****/
// Radial Images
if( $('body.single-service').length )
{
var radialOne = $('body > .radial:first-child');
var radialTwo = $('body > .radial:nth-child(2)');
$window.on('load resize', function(){
radialOnePos = $('#team').offset().top;
radialOne.addClass('left');
radialOne.css('top', radialOnePos);
radialOne.fadeIn();
});
}
// Team Card Animations
var team = $('.single-service #team');
if( team.length )
{
var teamCard = $('#team .team-member');
$window.load(function(){
teamCard.addClass('animation-ready');
});
$window.on('scroll resize', function(){
teamCard.each(function(){
if( topIsInViewport($(this)) ) {
$(this).addClass('animate');
};
});
});
}
// Step Number Animations
var steps = $('.single-service #steps');
if( steps.length )
{
var number = $('#steps .step .number');
var delay = 0;
$window.load(function(){
number.addClass('animation-ready');
});
$window.on('scroll resize', function(){
if( topIsInViewport(steps) )
{
if( ! number.hasClass('animate') )
{
number.each(function(index)
{
(function(that, i) {
var t = setTimeout(function() {
$(that).addClass('animate');
}, 1000 * i);
})(this, index);
});
}
}
});
}
/**** Single Solution Post ****/
// Radial Images
if( $('body.single-solution').length )
{
var radialOne = $('body > .radial:first-child');
var radialTwo = $('body > .radial:nth-child(2)');
$window.on('load resize', function(){
/*
radialOnePos = $('#intro').offset().top + 600;
radialOne.addClass('left');
radialOne.css('top', radialOnePos);
radialOne.fadeIn();
*/
});
}
// Gallery Section
$('#gallery .item').on({
click: function(e) {
e.preventDefault();
var selector = $(this).data('id');
console.log(selector);
$('#gallery .item.active').removeClass('active');
$(this).addClass('active');
$('#gallery figure.visible').removeClass('visible');
$('#gallery figure[data-id=' + selector + ']').addClass('visible');
},
mouseenter: function(e) {
e.preventDefault();
var selector = $(this).data('id');
console.log(selector);
$('#gallery .item.active').removeClass('active');
$(this).addClass('active');
$('#gallery figure.visible').removeClass('visible');
$('#gallery figure[data-id=' + selector + ']').addClass('visible');
}
});
// Equalize heights of products
if( $('#products .products').length ) {
$window.on('load resize', function(){
$('#products .product').css('height', 'auto');
equalizeHeight($('#products .sub-products > .product'));
});
}
// Equalize heights of case studies
if( $('#casestudies .quotes').length ) {
$window.on('load resize', function(){
$('#casestudies .quotes .content').css('height', 'auto');
$('#casestudies .quotes .source').css('height', 'auto');
equalizeHeight($('#casestudies .quotes .content'));
equalizeHeight($('#casestudies .quotes .source'));
});
}
// Feature Section Animations
var features = $('.single-solution #features');
if( features.length )
{
var feature = $('#features .feature figure');
$window.load(function(){
feature.addClass('animation-ready');
});
$window.on('scroll resize', function(){
feature.each(function(){
if( topIsInViewport($(this)) ) {
$(this).addClass('animate');
};
});
});
};
// Change tab class and display content
$('.benefits_nav a').on('click', function (event) {
event.preventDefault();
$('.nav-item').removeClass('active');
$(this).addClass('active');
$('.benefits_tab').hide();
$($(this).attr('href')).show();
});
$('.benefits_nav a:first').trigger('click'); // Default
/**** Company Page ****/
// Equalize Executive Tile Heights
if( $('.page-template-company #team').length )
{
$window.load(function(){
equalizeHeight($('#team .executive .tile'));
});
}
// Culture Slider
$('#culture .photos').slick({
appendArrows: '#culture #photo-nav',
dots: false,
infinite: true,
speed: 300,
slidesToShow: 1,
slidesToScroll: 1,
adaptiveHeight: true,
});
/**** Who We Serve Page ****/
$('#success-stories .tiles .tile .static').on({
click: function(e) {
e.preventDefault();
$('#success-stories .tile.active').removeClass('active');
$(this).parent().addClass('active');
},
mouseenter: function(e) {
console.log('enter!');
$('#success-stories .tile.active').removeClass('active');
$(this).parent().addClass('active');
}
});
$('#success-stories .tiles .tile .static .learn').on({
click: function(e) {
e.preventDefault();
var target = $(this).attr('href')
window.location.href = target;
}
});
// Equalize heights of all cards
if( $('.cards-container').length ) {
$window.on('load resize', function(){
$('.cards-container .card header').css('height', 'auto');
equalizeHeight($('.cards-container .card p'));
equalizeHeight($('.cards-container .card header'));
$('.cards-container .card').css('height', 'auto');
equalizeHeight($('.cards-container .card'));
});
}
/**** News/Press Page ****/
// Radial Images
if( $('body.page-template-news').length )
{
var radialOne = $('body > .radial:first-child');
$window.on('load resize', function(){
radialOnePos = $('#cta').offset().top - 900;
console.log(radialOne);
radialOne.addClass('left');
radialOne.css({'top': radialOnePos, 'z-index': 0});
radialOne.fadeIn();
});
}
$('#feed nav a').click(function(e){
e.preventDefault();
var tab = $(this).attr('data-id');
$('#feed .tab.active').removeClass('active');
$('#feed nav a.active').removeClass('active');
$(this).addClass('active');
$('#feed .tab.'+tab).addClass('active');
});
/**** Careers Page ****/
// Radial Images
if( $('body.page-template-careers').length )
{
var radialOne = $('body > .radial:first-child');
var radialTwo = $('body > .radial:nth-child(2)');
$window.on('load resize', function(){
radialOnePos = $('#photo-grid').offset().top + 200;
radialOne.addClass('left');
radialOne.css('top', radialOnePos);
radialOne.fadeIn();
radialTwoPos = $('#stats').offset().top - 200;
radialTwo.addClass('right');
radialTwo.css('top', radialTwoPos);
radialTwo.fadeIn();
});
}
// Gallery Slider
$('.page-template-careers #gallery .slides').slick({
dots: true,
appendArrows: '#gallery nav.slider',
appendDots: '#gallery nav.slider'
});
// Equalize Quote Height
if( $('.page-template-careers #quotes').length ) {
equalizeHeight($('.page-template-careers #quotes .tile .content'));
equalizeHeight($('.page-template-careers #quotes .tile .credit'));
}
// Animate Benefits
var benefits = $('.page-template-careers #benefits');
if( benefits.length )
{
var benefitsItem = benefits.find('.benefit');
var delay = 0;
$window.load(function(){
benefitsItem.addClass('animation-ready');
});
$window.on('scroll resize', function(){
if( topIsInViewport(benefits) )
{
if( ! benefitsItem.hasClass('animate') )
{
benefitsItem.each(function(index)
{
(function(that, i) {
var t = setTimeout(function() {
$(that).addClass('animate');
}, 300 * i);
})(this, index);
});
}
}
});
}
/*** Homepage ***/
// Radial
if( $('body.page-template-home').length )
{
var radialOne = $('body > .radial:first-child');
var radialTwo = $('body > .radial:nth-child(2)');
$window.on('load resize', function(){
radialOnePos = $('.page-template-home #levels').offset().top - 200;
radialOne.addClass('left');
radialOne.css('top', radialOnePos);
radialOne.fadeIn();
radialTwoPos = $('.page-template-home #stories').offset().top - 200;
radialTwo.addClass('right');
radialTwo.css('top', radialTwoPos);
radialTwo.fadeIn();
});
}
// Stats
var stat = $('#numbers .stat .digit');
stat.addClass('animation-ready');
$window.scroll(function() {
stat.each(function(){
var $this = $(this);
//var start = 10;
//var end = 6000;
if( isInViewport($this) ) {
//$this.addClass('counting');
}
});
});
// Equalize quote heights
if( $('.page-template-home #quotes').length ) {
equalizeHeight($('.page-template-home #quotes .tile .content'));
equalizeHeight($('.page-template-home #quotes .tile .source'));
}
// Number & Map Initailize/Animate
var map = $('#numbers #map');
var data = map.attr('data-map');
if(map.length ) {
var statSection = $('#numbers #stats');
var digit = $('digit');
var anim;
var map = document.getElementById('lottie-container');
var animData = {
container: document.getElementById('lottie-container'), // the dom element that will contain the animation
renderer: 'svg',
loop: false,
autoplay: false, /*MAKE SURE THIS IS FALSE*/
rendererSettings: {
progressiveLoad:false
},
path: data // the path to the animation json
};
var anim = lottie.loadAnimation(animData);
var fired = 0;
$window.scroll(function() {
if(topIsInViewport( statSection ) ) {
anim.play();
if (fired < 4) {
$.each($('#stats .digit'), function () {
var count = $(this).data('count'),
numAnim = new CountUp(this, 0, count);
numAnim.start();
fired = fired+1;
});
}
};
});
anim.addEventListener('complete', animateHotspots);
function animateHotspots() {
var spots = $('.map-overlay .hotspot')
// Animate spots
var delay = 200;
var current = 1;
spots.each(function(){
var $this = $(this);
setTimeout(function(){
$this.css('opacity', '1');
}, delay*current);
current++;
});
}
}
// COVID-19 Ticker
if( $('#hero .ticker').length )
{
var ticker = $('#hero .ticker');
var tickerContent = $('#hero .ticker .ticker_container');
tickerContent.marquee({
//duration in milliseconds of the marquee
duration: 17000,
//gap in pixels between the tickers
gap: 300,
//time in milliseconds before the marquee will start animating
delayBeforeStart: 0,
//'left' or 'right'
direction: 'left',
//true or false - should the marquee be duplicated to show an effect of continues flow
duplicated: false
});
};
/* DEPRECATED
// COVID-19 Counter
if( $('#hero .counter').length )
{
var countable = $('.counter .countable');
$window.on('load', function(){
$.each(countable, function () {
console.log('each happened');
var count = $(this).data('count'),
countFrom = $(this).data('countfrom');
$(this).countTo({
from: countFrom,
to: count,
speed: 120000,
refreshInterval: 100,
formatter: function (value, options) {
return value.toFixed(0).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
},
onUpdate: function (value) {
console.debug(this);
},
onComplete: function (value) {
console.debug(this);
this.append("+")
}
});
});
});
};
*/
if($('#video-new-modal').length) {
$(document).on("click", ".close-new-modal", function() {
$("#video-new-modal").each(function() {
$(this).removeClass("active");
});
});
$(document).on("click", ".play-new-video", function() {
$("#video-new-modal").addClass("active");
});
}
});
/* ==========================================================================
Functions
========================================================================== */
/* Equalize Element Heights */
function equalizeHeight(element){
var maxHeight = 0;
jQuery(element).each(function(){
if (jQuery(this).height() > maxHeight) { maxHeight = jQuery(this).height(); }
});
jQuery(element).height(maxHeight);
}
/* Check if an element has scrolled into view */
function isInViewport(element)
{
var viewportTop = jQuery(window).scrollTop();
var viewportBottom = viewportTop + jQuery(window).height();
var elementTop = jQuery(element).offset().top;
var elementBottom = elementTop + (jQuery(element).outerHeight());
return ((elementBottom <= viewportBottom) && (elementTop >= viewportTop));
}
/* Check if an the top of an element has scrolled into view */
function topIsInViewport(element)
{
var viewportTop = jQuery(window).scrollTop();
var viewportBottom = viewportTop + jQuery(window).height();
var elementTop = jQuery(element).offset().top + 100;
return ((elementTop <= viewportBottom));
}
/*
* @author Sanford Whiteman
* @version v1.104
* @license MIT License: This license must appear with all reproductions of this software.
*
* Create a completely barebones, user-styles-only Marketo form
* by removing inline STYLE attributes and disabling STYLE and LINK elements
function destyleMktoForm(mktoForm, moreStyles){
var formEl = mktoForm.getFormElem()[0],
arrayFrom = Function.prototype.call.bind(Array.prototype.slice);
// remove element styles from