/*New Script for header background and hover effect*/ $(document).ready(function() { var header = $('header,.top-head'); var tophead = $('.top-head'); var scrollPosition = 50; var isScrollGreaterThan50 = false; // Function to handle scroll event $(window).scroll(function() { if ($(window).scrollTop() > scrollPosition) { if (!isScrollGreaterThan50) { isScrollGreaterThan50 = true; header.addClass('fills fill'); tophead.addClass('fill'); header.off('mouseenter mouseleave'); // Disable hover effect tophead.off('mouseenter mouseleave'); } } else { if (isScrollGreaterThan50) { isScrollGreaterThan50 = false; header.removeClass('fills fill'); tophead.removeClass('fill'); // Re-enable hover effect header.hover( function() { header.addClass('fills fill'); tophead.addClass('fill'); }, function() { header.removeClass('fills fill'); tophead.removeClass('fill'); } ); } } }); // Function to handle hover effect header.hover( function() { header.addClass('fills fill'); tophead.addClass('fill'); }, function() { if (!isScrollGreaterThan50) { header.removeClass('fills fill'); tophead.removeClass('fill'); } } ); // Initial check in case the page is loaded with scroll position > 50 if ($(window).scrollTop() > scrollPosition) { isScrollGreaterThan50 = true; header.addClass('fills fill'); tophead.addClass('fill'); header.off('mouseenter mouseleave'); // Disable hover effect tophead.off('mouseenter mouseleave'); } else { isScrollGreaterThan50 = false; header.removeClass('fills fill'); tophead.removeClass('fill'); // Enable hover effect header.hover( function() { header.addClass('fills fill'); tophead.addClass('fill'); }, function() { header.removeClass('fills fill'); tophead.removeClass('fill'); } ); } }); /*End new script for header*/ $(document).ready(function(){ $(".btn-search").click(function(){ $(".search-box").slideDown(); }); $(".image-wrap.close").click(function(){ $(".search-box").slideUp(); }); }); $(document).mouseup(function(e) { var container = $(".search-box"); // if the target of the click isn't the container nor a descendant of the container if (!container.is(e.target) && container.has(e.target).length === 0) { container.slideUp(); } }); var animations = { counters: [] }; var lastScrollTop = 0; var resourceFilterAjax = null; $(document).ready(function() { InitResizeAdjustments(); InitNav(); InitAddHoverColor(); CheckHeaderFill(); InitScrollUpdateHeaderStyle(); InitAccordions(); InitTabs(); InitCalcAnimation(); InitWalkthroughScroller(); InitSearch(); InitModalTrigger(); InitMatchHeights(); InitFormControls(); InitFilterMenu(); InitLoadResources(); InitShareTriggers(); InitFixedShareSidebar(); InitNavHash(); InitLeadersPopup(); InitCookieDisclaimer(); InitScrollMagic(); InitSlider(); midpageMenuScroll(); midpageMenuSticky(); CheckHeaderFill(); function InitScrollUpdateHeaderStyle() { $(window).scroll(function() { CheckHeaderFill() }); } function CheckHeaderFill() { // var scrollPos = $(document).scrollTop(); // if(scrollPos < 50){ // $(document).ready(function(){ // $('header, .top-head').removeClass('fill'); // $("header,.top-head").hover(function(){ // $(".headerFixed, .top-head").addClass("fill"); // }, function(){ // $(".headerFixed, .top-head").removeClass("fill"); // }); // }); // } // if (scrollPos > 50) { // $('header, .top-head').addClass('fill'); // $("header, .top-head").off('hover'); // } else { // if (!$('.search-input-wrap').hasClass('active')) { // // $('header, .top-head').removeClass('fill') // } // } } $('.hover-blocks .item .article').hover(function(){ $('aside', this).slideDown() }, function() { $('aside', this).slideUp() }); if($(".testimonials.owl-carousel").length) { $(".testimonials.owl-carousel").owlCarousel({ items: 1, loop:true, nav: true }); } if($(".logos-carousel.owl-carousel").length) { $(".logos-carousel.owl-carousel").owlCarousel({ items: 1, loop:true, nav: true }); } if($(".animated-figure .image-carousel.owl-carousel").length) { $(".animated-figure .image-carousel.owl-carousel").owlCarousel({ autoplay:true, autoplayTimeout: 5000, animateOut: 'fadeIn', animateIn: 'fadeOut', smartSpeed:0, items: 1, loop:true, nav: false, dots: false, }); } if($(".small-figure .image-carousel").length) { $(".small-figure .image-carousel").slick({ //dots: true, arrows: false, autoplay: true, autoplaySpeed: 4000, infinite: true, speed: 500, fade: true, cssEase: 'linear' }); } }); function midpageMenuScroll(){ $(document).on('click', '.midpage-click', function(){ var base = $('html, body'); var anchor = "."+$(this).data("anchor"); var height = $('header').height() + $('.midpage-menu').height(); base.animate({scrollTop: ($(anchor).offset().top - height)}, 1000); $('.midpage-menu-container span').removeClass("current-tab"); $(this).addClass("current-tab"); }); } function midpageMenuSticky(){ var distance = ($('.midpage-menu').offset() ? $('.midpage-menu').offset().top : 0) - $('header').height(); var menu = $('.midpage-menu'); $(document).on('scroll', function() { if ($(window).scrollTop() >= distance) { menu.addClass("sticky"); } else { menu.removeClass("sticky"); } }); } function InitSlider(){ if($(".slider-logos.owl-carousel").length) { var num_items = 4; if ($(window).width() < 720) { num_items = 2; } $(".slider-logos.owl-carousel").owlCarousel({ items: num_items, nav: true }); } } function InitResizeAdjustments() { $(window).resize(function() { if ($('.menu.header').hasClass('active')) { if ($(window).width() > 1023) { $('header').removeClass('light-fill') } else { $('header').addClass('light-fill') } } CloseAllNavAccordions() }) } function InitNav() { InitNavToggle(); HandleNavHover() } function InitNavToggle() { $(document).on('click', '.menu-toggle', function() { if (!$(this).hasClass('slidedown-active')) { $(this).toggleClass('active'); $('.menu.header').toggleClass('active'); if ($('.menu.header').hasClass('active')) { $('header .custom-logo-link img.white').addClass('hide'); $('header').removeClass('fill'); if ($(window).width() <= 1023) { $('header').addClass('light-fill') } LockPageScroll() } else { $('header').removeClass('light-fill'); window.setTimeout(function() { $('header .custom-logo-link img.white').removeClass('hide') }, 500); UnlockPageScroll(); //reset //ResetNav(); } } else { $('.slidedown-modal').removeClass('active'); $(this).removeClass('slidedown-active active'); window.setTimeout(function() { $('header').removeClass('fill light-fill') }, 500); UnlockPageScroll(); } }) } function ResetNav() { window.setTimeout(function() { $('.menu-item.primary').removeClass('active'); $('.menu-item.primary').removeClass('selected'); $('.menu-item.primary:first-of-type').addClass('default active selected'); var $activeNav = $('.menu-item.primary.active'); var $screen = $activeNav.find('ul.menu-group').first().clone(true, true); $('.header.menu .screens').html($screen); }, 500); } function InitAddHoverColor() { $(document).on("mouseenter", ".screens .menu-group.secondary .menu-item.secondary h4 > a", function() { $(this).css('color', '#3d5567'); }); $(document).on("mouseleave", ".screens .menu-group.secondary .menu-item.secondary h4 > a", function() { $(this).css('color', '#00a9e0'); }); $(document).on("mouseenter", ".screens .menu-group.secondary .menu-item.secondary .menu-item.tertiary a", function() { $(this).css('color', '#00a9e0'); }); $(document).on("mouseleave", ".screens .menu-group.secondary .menu-item.secondary .menu-item.tertiary a", function() { $(this).css('color', '#556b79'); }); } function HandleNavHover() { hoveringScreen = false; if ($('.menu-item.primary.default').length == 0) { $('.menu-item.primary:first-of-type').addClass('default active selected'); SetNavScreen(); } $(document).on('mouseenter', '.menu-group.primary .menu-item.primary', function() { $('.menu-item.primary').removeClass('active'); $('.menu-item.primary.selected').removeClass('selected'); $(this).addClass('active selected'); SetNavScreen(); }).on('mouseleave', '.menu-group.primary .menu-item.primary', function(e) { //$('.menu-item.primary.active').removeClass('active'); //$('.menu-item.primary.default').addClass('active'); if ($('.menu-item.primary.default').length == 0) { $('.menu-item.primary.selected').addClass('active'); } else { SetNavScreen(); } })/*.on('mouseenter', '.screens', function() { $('.menu-item.primary.active').removeClass('active'); $('.menu-item.primary.selected').addClass('active'); SetNavScreen(); })*/ } function SetNavScreen() { var $activeNav = $('.menu-item.primary.active'); var $screen = $activeNav.find('ul.menu-group').first().clone(true, true); $('.header.menu .screens').html($screen); } function CloseAllNavAccordions() { $.each($('.header.menu [data-accordion-trigger].active'), function(index, value) { ToggleAccordion(value) }) } function InitScrollUpdateHeaderStyle() { $(window).scroll(function() { CheckHeaderFill() }) } function CheckHeaderFill() { var scrollPos = $(document).scrollTop(); if (scrollPos > 50) { $('header').addClass('fill') } else { if (!$('.search-input-wrap').hasClass('active')) { $('header').removeClass('fill') } } } function InitAccordions() { $(document).on('click', '[data-accordion-trigger]', function(e) { var breakpoint = 1023; var mobile = $(window).width() <= breakpoint; var parent = $(e.target).closest('.menu-item'); var ulParent = $(this).closest('ul'); var activeSubs = parent.find('.menu-group.active').length; if(mobile){ if(!activeSubs){ e.preventDefault(); } else return; if($('[data-accordion-trigger].active', ulParent).length) ToggleAccordion($('[data-accordion-trigger].active', ulParent)); //close any open submenu because the secondary click of main menu is for navigation } e.stopPropagation(); var $target = $('[data-accordion="' + $(this).data('accordion-trigger') + '"]'); var enabled = true; if ($(this).closest('.header.menu').length > 0 && !mobile) { enabled = false } if ($target.hasClass('tertiary') && $(window).width() > 768) { enabled = false; window.location.href = $(e.target).attr('href') } if (enabled) { ToggleAccordion($(this)) } }); $('[data-accordion-trigger].default-open').trigger('click') } function ToggleAccordion(trigger) { var animationTime = 500; var $target = $('[data-accordion="' + $(trigger).data('accordion-trigger') + '"]'); $(trigger).toggleClass('active'); $target.toggleClass('active'); if ($target.height() === 0) { AutoHeightAnimate($target, animationTime) } else { $target.stop().animate({ height: '0' }, animationTime, function() { $target.removeAttr('style') }) } } function InitTabs() { InitPreviewTabs() } function InitPreviewTabs() { $(document).on('mouseenter', '.tab-preview .tab', function() { var $data = $(this).find('.description').first().clone(); var image = $(this).data('image'); $(this).closest('.tabs').find('.active').removeClass('active'); $(this).addClass('active'); $(this).closest('.tab-preview').find('.tab-content .content').html($data); $(this).closest('.tab-preview').find('.tab-image img').attr('src', image) }).on('mouseleave', '.tab-preview .tabs', function() {}).on('click', '.tab-preview .tab', function() { var location = $(this).find('.description p:last-of-type a').first().attr('href'); window.location = location; }) } function InitCalcAnimation() { $(window).scroll(function() { $.each($('.stats:not(.triggered)'), function(index, value) { var elem = ElementScrolled(value); if (elem) { $.each(elem.find('.stat .value'), function(index, value) { animations['counters'][index] = window.setInterval(CountUp, 100, index, $(this)) }); elem.addClass('triggered') } }) }) } function CountUp($counterIndex, $elem) { var $symbol = $elem.find('.symbol').clone(); var value = $elem.data('value'); var tempValue = 0; if ($elem.data('temp-value')) { tempValue = $elem.data('temp-value') } else { if (value % 1 === 0) { if (value >= 15) { tempValue = value - 15 } } else { if (value >= 1.5) { tempValue = parseFloat(parseFloat(value - 1.5).toFixed(1)) } } } if (tempValue < value) { if (value % 1 === 0) { tempValue += 1 } else { tempValue = parseFloat(parseFloat(tempValue + 0.1).toFixed(1)) } $elem.html(tempValue).append($symbol); $elem.data('temp-value', tempValue).attr('data-temp-value', tempValue) } else { clearInterval(animations['counters'][$counterIndex]) } } function InitWalkthroughScroller() { $(document).on('click', '.walkthrough-scroller', function(e) { var $target; var scroll = 0; var $nextSection = $(this).parent().next('div'); var $walker = $(this); if ($nextSection.find('h2.title').length > 0) { $target = $nextSection.find('h2.title'); scroll = $target.offset().top - 120 } else { $target = $nextSection; scroll = $target.offset().top } $walker.addClass('active'); $('html, body').animate({ scrollTop: scroll }, 2000, function() { window.setTimeout(function() { $walker.removeClass('active') }, 6000) }) }); $(window).scroll(function() { var st = $(this).scrollTop(); if (st > lastScrollTop) { $.each($('.walkthrough-scroller:not(.active)'), function(index, value) { var elem = ElementScrolled(value); if (elem.length > 0) { if (elem.offset().top <= $(window).scrollTop() + ($(window).height() / 2)) { $(elem.addClass('active')); window.setTimeout(function() { elem.removeClass('active') }, 6000) } } }) } lastScrollTop = st }) } function InitSearch() { var $search = $('.mobile-menu form').clone(); if ($('.header .mobileSearch').length == 0) { $('.header').append('
') } window.$_GET = new URLSearchParams(location.search); var searchTerm = $_GET.get('s'); if ($_GET.get('search')) { searchTerm = $_GET.get('search') } if (searchTerm != null && searchTerm != '') { $('.page-content form[role="search"] input').val(searchTerm); $('.page-content form[role="search"]').addClass('active') } else { $('.page-content form[role="search"]').removeClass('active') } $(document).on('click', 'header .searchIcon', function() { var $inputElem = $(this).closest('.search-input-wrap').find('input'); var $formElem = $(this).closest('form').first(); $('header').addClass('fill'); if ($inputElem.hasClass('active')) { $formElem.submit() } else { $inputElem.addClass('active'); $('header .search-input-wrap').addClass('active') } if ($(window).width() <= 768) { OpenSearchMobile() } }).on('blur', 'header .search-input-wrap input', function() { $(this).removeClass('active'); $('header .search-input-wrap').removeClass('active'); var scrollPos = $(document).scrollTop(); if (scrollPos <= 50) { $('header').removeClass('fill') } CloseSearchMobile() }).on('click', '.page-content', function(e) { if ($(e.target).closest('.header-nav-control').length == 0) { $('header .search-input-wrap input').removeClass('active'); $('header .search-input-wrap').removeClass('active'); var scrollPos = $(document).scrollTop(); if (scrollPos <= 50) { $('header').removeClass('fill') } CloseSearchMobile() } }).on('click', '.page-content form[role="search"] .image-wrap.search', function() { var $formElem = $(this).closest('form').first(); $formElem.submit() }).on('click', '.page-content form[role="search"] .image-wrap.close', function() { var $inputElem = $(this).closest('.search-input-wrap').find('input'); $inputElem.val(''); $('.page-content form[role="search"]').removeClass('active'); var $formElem = $(this).closest('form').first(); $formElem.submit() }).on('submit', '.resource-search', function(e) { e.preventDefault(); if ($(this).find('input').val() != null & $(this).find('input').val() != '') { $(this).addClass('active') } else { $(this).removeClass('active') } ProcessNewFilters($('.filter-radios .radio.active[data-type="resource"]'), $(this).find('input').val()) }) } function OpenSearchMobile() { if ($(window).width() <= 768) { $('.header').addClass('fill'); $('.mobile-menu form input').css({ 'width': '0px', 'opacity': '0' }); $('.mobileSearch').addClass('active') } } function CloseSearchMobile() { if ($(window).width() <= 768) { var scrollPos = $(document).scrollTop(); if (scrollPos <= 50) { $('#primaryHeader').removeClass('fill') } $('.mobileSearch').removeClass('active'); } } function InitModalTrigger() { $(document).on('click', '[data-video-source]', function(e) { e.preventDefault(); e.stopPropagation(); $('.modal').addClass('active'); var id = $(this).data('video-id'); var source = $(this).data('video-source'); if (source == 'YouTube') { $('.modal .video').html('') } else if (source == 'Vimeo') { $('.modal .video').html('') } else if (source == 'HTML') { $('.modal .video').html($(this).next('div').html()); } else { $('.modal .video').html('') } }).on('click', '.modal', function(e) { if ($(e.target).closest('.screen').length == 0) { $('.modal').removeClass('active'); $('.modal .video').html('') } }).on('click', '.modal .close-icon img', function() { $('.modal').removeClass('active'); $('.modal .video').html('') }) } function InitMatchHeights() { var height = 0; $.each($('.featured-posts .content .auto-height'), function(index, item) { if ($(item).outerHeight() > height) { height = $(item).outerHeight() } }); $('.featured-posts .content .auto-height').css({ 'height': height + 'px' }) } function InitFormControls() { $(document).on('click', '.radio', function() { $.each($(this).parent().find('.radio'), function(index, item) { $(item).removeClass('active') }); $(this).toggleClass('active') }).on('click', '.check', function() { $(this).toggleClass('active') }) } function InitFilterMenu() { $(document).on('click', '.filter-trigger', function(e) { e.preventDefault(); e.stopPropagation(); $('.resource-filter').addClass('active') }).on('click', '.resource-filter .close', function() { $('.resource-filter').removeClass('active') }).on('click', '.resource-filter', function(e) { if ($(e.target).closest('.filter-form').length == 0 && !$(e.target).hasClass('filter-form')) { $('.resource-filter').removeClass('active') } }).on('click', '.resource-filter li', function(e) { ProcessNewFilters($(this)) }) } function ProcessNewFilters($trigger, $search = null) { if (history.pushState) { var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname; window.$_GET = new URLSearchParams(location.search); var searchTerm = $_GET.get('s'); var searchTerm2 = $_GET.get('search'); if ($search != null) { searchTerm2 = $search } if (searchTerm != null && searchTerm != '') { newurl += '?s=' + searchTerm } if (searchTerm2 != null && searchTerm2 != '') { newurl += '?search=' + searchTerm2 } window.history.pushState({ path: newurl }, '', newurl) } SetFilterBarOptions(); if ($trigger.data('type') == 'resource') { var category = $trigger.data('value'); if (category != null) { window.location.hash = category } else { window.location.hash = 'all' } } else { UpdateResourcePosts() } } function UpdateResourcePosts() { var url_string = window.location.href; var url = new URL(url_string); var page_num; if (url.searchParams.get("pg") == '') { page_num = 1 } else { page_num = url.searchParams.get("pg") } var category; var filters = { partners: [], topics: [], industries: [] }; $.each($('.resource-filter li'), function(index, item) { if ($(item).hasClass('active')) { if ($(item).data('type') == "resource") { category = $(item).data('value') } else if ($(item).data('type') == "partner") { filters.partners.push($(item).data('value')) } else if ($(item).data('type') == "topic") { filters.topics.push($(item).data('value')) } else if ($(item).data('type') == "industry") { if ($(item).data('value') != 'all') { filters.industries.push($(item).data('value')) } } } }); var firstTitleArea = $('.resource-hero .title-area .title:first-child'); var secondTitleArea = $('.resource-hero .title-area .title:last-child'); var topTitle = ''; if (filters['industries'] != 'all' && filters['industries'] != null) { topTitle += GetTitleFromValue(filters['industries'], false) + ' ' } if (category != 'all' && category != null) { topTitle += GetTitleFromValue(category) } if (topTitle == '' || topTitle == ' ') { switch ($('.resource-header').data('limitations')) { case 'news': firstTitleArea.html('Enterprise Mobility News'); break; case 'blog': firstTitleArea.html('Enterprise Mobility Blog'); break; default: firstTitleArea.html('Enterprise Mobility Resources'); break } window.$_GET = new URLSearchParams(location.search); var searchTerm = $_GET.get('s'); if (searchTerm != null && searchTerm != '') { firstTitleArea.html('Search for "' + searchTerm + '"') } secondTitleArea.addClass('hide') } else { firstTitleArea.html(topTitle); secondTitleArea.removeClass('hide') } $('.resource-list').removeClass('active'); if (resourceFilterAjax != null) { resourceFilterAjax.abort() } resourceFilterAjax = FilterResources(category, page_num, filters) } function SetFilterBarOptions() { var $filtersApplied = []; $.each($('.filter-type li.active'), function(index, item) { if ($(item).data('type') != null) { if ($filtersApplied[$(item).data('type')] == null) { $filtersApplied[$(item).data('type')] = [] } $filtersApplied[$(item).data('type')].push($(item).data('value')) } }); if (Object.keys($filtersApplied).length == 0) { $('.filter-details').html('Click the Filters button to narrow your choices by Topic, Industries, and Partners.') } else { $filterDetails = ' '; if (totalGroups > 0) { $('.filter-details').html($filterDetails) } else { $('.filter-details').html('Click the Filters button to narrow your choices by Topic, Industries, and Partners.') } } $(document).on('click', '.filter-applied', function() { $value = $(this).data('value'); $parentGroup = $(this).parent(); $(this).remove(); if ($parentGroup.find('.filter-applied').length == 0) { $parentGroup.remove() } if ($('.filter-tags .filter-group').length == 0) { $('.filter-details').html('Click the Filters button to narrow your choices by Topic, Industries, and Partners.') } $('.filter-type li[data-value="' + $value + '"]').removeClass('active'); if ($('.filter-type li[data-value="' + $value + '"]').hasClass('radio')) { $('.filter-type li[data-value="' + $value + '"]').parent().find('[data-value="all"]').first().addClass('active') } if ($('.resource-filter li[data-value="' + $value + '"]').data('type') == 'resource') { window.location.hash = 'all' } else { UpdateResourcePosts() } }).on('click', '.filter-clear', function() { $('.filter-details').html('Click the Filters button to narrow your choices by Topic, Industries, and Partners.'); $('.filter-type li.active').removeClass('active'); $('.filter-type li[data-value="all"]').addClass('active'); window.location.hash = 'all' }) } function InitLoadResources() { var category = document.location.hash.replace('#', ''); if (category == '') { $('[data-accordion="resource-filter"] [data-value="all"]').addClass('active') } else { $('[data-accordion="resource-filter"] [data-value="' + category + '"]').addClass('active'); if (category != 'all') { $('.resource-hero .title-area .title:first-child').html(GetTitleFromValue(category)); $('.resource-hero .title-area .title:last-child').removeClass('hide') } } SetFilterBarOptions(); var url_string = window.location.href; var url = new URL(url_string); var page_num; if (url.searchParams.get("pg") == '') { page_num = 1 } else { page_num = url.searchParams.get("pg") } if (category == '') { resourceFilterAjax = FilterResources('all', page_num) } else { resourceFilterAjax = FilterResources(category, page_num) } } function FilterResources($cat, $page_num, $filters = null) { if(!$('.resource-header').length) return false; $posts_per_page = $('.resource-header').data('posts-per-page'); $limitations = $('.resource-header').data('limitations'); var search_type = 'default'; window.$_GET = new URLSearchParams(location.search); var searchTerm = null; if ($_GET.get('s') != null && $_GET.get('s') != '') { searchTerm = $_GET.get('s') } else if ($_GET.get('search') != null && $_GET.get('search') != '') { searchTerm = $_GET.get('search'); search_type = 'resources' } $page_num = $page_num || 1; var data_obj = {}; data_obj = { action: "filter_resources", category: $cat, search_type: search_type, page_num: $page_num, filters: $filters, posts_per_page: $posts_per_page, limitations: $limitations, search: searchTerm }; var $url_filters = $_GET.get('filters'); if($url_filters && JSON.parse($url_filters)) data_obj = JSON.parse($url_filters); data_obj.page_num = $page_num; //$filters = JSON.parse($url_filters); return $.ajax({ type: "POST", dataType: "json", url: "/wp-admin/admin-ajax.php", data: data_obj, success: function(response) { var $posts = ''; if (response['posts'] != null) { $.each(response['posts'], function(index, item) { var link = item.link; var target = ''; var category = item.category; if (category == null) { category = 'page' } if (item.meta.external_link != null && item.meta.external_link[0] != '') { if (item.meta.external_link[0].indexOf("http://") != -1 || item.meta.external_link[0].indexOf("https://") != -1) { link = item.meta.external_link[0] } else { link = 'https://' + item.meta.external_link[0] } target = 'target="_blank"' } $posts += 'No Posts Found
'); $('.page-details').html(''); $('.pagination').html('') } } }) } function InitShareTriggers() { var getWindowOptions = function() { var width = 500; var height = 450; var left = (window.innerWidth / 2) - (width / 2); var top = (window.innerHeight / 2) - (height / 2); return ['resizable,scrollbars,status', 'height=' + height, 'width=' + width, 'left=' + left, 'top=' + top].join() }; var fbBtn = $('.facebook-share'); var shareUrl = 'https://www.facebook.com/sharer/sharer.php?u=' + location.href + '&title=' + $(fbBtn).data('title') + '&picture=' + $(fbBtn).data('image'); $(fbBtn).href = shareUrl; $(fbBtn).on('click', function(e) { e.preventDefault(); var win = window.open(shareUrl, 'ShareOnFb', getWindowOptions()); win.opener = null; }); $(document).on('click', '.share-mail', function(e) { e.preventDefault(); let email = prompt("What email should this be sent to?"); var title = $(this).data('title'); var desc = $(this).data('desc'); if (desc == null) { desc = '' } var link = location.href; var mailTo = 'mailto:' + email + '?subject=' + title + '&body=' + desc + '' + title + ''; if (email != '' && email != null) { window.open(mailTo) } }) } function InitFixedShareSidebar() { $(document).on('scroll', function() { if ($('.post-content-wrap').length > 0) { var maxOffset = $('.post-content-wrap').offset().top + $('.post-content-wrap').outerHeight(); var sidebarOffset = $('.share-post.sidebar').offset().top + $('.share-post.sidebar').outerHeight(); if (sidebarOffset >= maxOffset) { $('.share-post.sidebar').css({ 'position': 'absolute', 'top': ($('.post-content-wrap').outerHeight() - $('.share-post.sidebar').outerHeight()) + 'px' }) } if ($(window).scrollTop() < $('.share-post.sidebar').offset().top) { $('.share-post.sidebar').css({ 'position': 'fixed', 'top': 'initial' }) } } }) } function InitNavHash() { window.addEventListener('popstate', function(event) { if (window.location.hash) { var hash = window.location.hash.split('#')[1]; if (hash != null) { $('header').removeClass('light-fill'); $('.header.menu').removeClass('active'); $('header .menu-toggle').removeClass('active'); UnlockPageScroll(); $('.resource-filter li[data-value="' + hash + '"]').parent().find('li').removeClass('active'); $('.resource-filter li[data-value="' + hash + '"]').addClass('active'); SetFilterBarOptions(); UpdateResourcePosts() } } }); $(document).on('click', 'a', function(e) { if ($(this).attr('href').includes('#')) { $('.resource-filter').removeClass('active'); $('.filter-type li.active:not([data-type="resource"])').removeClass('active'); $('.filter-type li[data-value="all"]:not([data-type="resource"])').addClass('active'); SetFilterBarOptions() } }).on('click', '.anchorable a', function() { if ($(this).attr('href').includes('#')) { target = $(this).attr('href').split('#')[1]; $scrollPos = $('#' + target)[0].offsetTop - 100; $('html,body').animate({ scrollTop: $scrollPos }, 400) } }) } function InitLeadersPopup() { $(document).on('click', '.leaders .leader', function() { var image = $(this).data('image'); var name = $(this).data('name'); var title = $(this).data('title'); var description = $(this).data('description'); var linkedin = $(this).data('linkedin'); var $leaderModal = $('.slidedown-modal .leader-overview'); $('.slidedown-modal').addClass('active'); $('header').removeClass('fill').addClass('light-fill'); $('header .menu-toggle').addClass('active'); LockPageScroll(); $('header .menu-toggle').addClass('slidedown-active'); $leaderModal.find('.leader-image img').attr('src', image); $leaderModal.find('.name').html(name); $leaderModal.find('.title').html(title); $leaderModal.find('.details').html(description); $leaderModal.find('.social').attr('href', linkedin); $('.slidedown-modal').animate({ scrollTop: 0 }, 400) }) $(document).on('click', '.slidedown-modal .close-icon', function() { $('.slidedown-modal').removeClass('active'); $('header').removeClass('light-fill').addClass('fill'); $('header .menu-toggle').removeClass('active slidedown-active'); UnlockPageScroll(); // Assuming you have a function to unlock page scroll }); } function InitCookieDisclaimer() { $(document).on('click', '.cookieDisclaimer .btn', function(e) { e.preventDefault(); e.stopPropagation(); setCookie('acceptCookies2020=true', 10000); $('.cookieDisclaimer').remove() }); if (getCookie('acceptCookies2020') == 'true') { $('.cookieDisclaimer').remove() } else { $('.cookieDisclaimer').removeClass('hide') } } function setCookie(info, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = info + "; " + expires + "; path=/;"; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i += 1) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1) } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length) } } return "" } function AutoHeightAnimate($element, time) { var curHeight = $element.height(); var autoHeight = $element.css('height', 'auto').height(); $element.height(curHeight); $element.stop().animate({ height: autoHeight }, time, function() { $element.css({ 'height': 'auto' }) }); } function ElementScrolled($elem) { var docViewTop = $(window).scrollTop(); var docViewBottom = docViewTop + $(window).height(); var elemTop = $($elem).offset().top; if (((elemTop <= docViewBottom) && (elemTop >= docViewTop))) { return $($elem) } else { return false } } function LockPageScroll() { var scrollPosition = [self.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop]; var html = jQuery('html'); html.data('scroll-position', scrollPosition); html.data('previous-overflow', html.css('overflow')); html.css('overflow', 'hidden'); window.scrollTo(scrollPosition[0], scrollPosition[1]); $('body').addClass('locked') } function UnlockPageScroll() { window.setTimeout(function() { CheckHeaderFill() }, 700); var html = jQuery('html'); var scrollPosition = html.data('scroll-position'); html.css('overflow', html.data('previous-overflow')); if (scrollPosition != null) { window.scrollTo(scrollPosition[0], scrollPosition[1]) } else { window.scrollTo(0, 0) } $('body').removeClass('locked') } function GetTitleFromValue($value, $pluralize = true) { var title = $value; if ($value.indexOf("-") >= 0) { var splitString = $value.split("-"); title = ''; $.each(splitString, function(index, string) { title += string; if (index + 1 != splitString.length) { title += ' ' } }) } var newTitle = ''; if ($pluralize) { if (title.toString().substring(title.toString().length, title.toString().length - 1) == 'y') { newTitle = title.toString().substring(0, title.toString().length - 1) + 'ies' } else if (title.toString().substring(title.toString().length, title.toString().length - 1) == 's') { newTitle = title } else { if (title.toString() != null && title.toString() != '') { newTitle = title.toString() + 's' } else { newTitle = '' } } } else { return title } return newTitle } function InitScrollMagic() { // if ($(window).width() > 980) { // var controller = new ScrollMagic.Controller(); // if ($('.core-value.has-sticky').length > 0) { // var stick = new ScrollMagic.Scene({ // triggerElement: '.core-value.has-sticky', // triggerHook: 0.5, // duration: ($('.core-value:last').offset().top + ($('.core-value:last').outerHeight() / 2)) - ($('.core-value:first').offset().top + ($('.core-value:first').outerHeight() / 2)), // offset: (-1 * $('header').height()) + ($('.core-value.has-sticky img.sticky').outerHeight() / 2) // }).setPin('.core-value.has-sticky .pin', { // pushFollowers: false // }).setClassToggle('.core-value.has-sticky .pin', 'pinned').addTo(controller); // setInterval(function(){ // stick.duration(($('.core-value:last').offset().top + ($('.core-value:last').outerHeight() / 2)) - ($('.core-value:first').offset().top + ($('.core-value:first').outerHeight() / 2))); // }, 1000); // } // } if ($(window).width() > 980) { var controller = new ScrollMagic.Controller(); if ($('.core-value.has-sticky').length > 0) { // Calculate the stopping point 100px above the footer or a specific element var stopAbove = 170; // Adjust this value as needed var stick = new ScrollMagic.Scene({ triggerElement: '.core-value.has-sticky', triggerHook: 0.5, duration: ($('.core-value:last').offset().top + ($('.core-value:last').outerHeight() / 2)) - ($('.core-value:first').offset().top + ($('.core-value:first').outerHeight() / 2)) - stopAbove, // Subtract 100px from the duration offset: (-1 * $('header').height()) + ($('.core-value.has-sticky img.sticky').outerHeight() / 2) }).setPin('.core-value.has-sticky .pin', { pushFollowers: false }).setClassToggle('.core-value.has-sticky .pin', 'pinned').addTo(controller); // Update the duration dynamically every second setInterval(function(){ stick.duration(($('.core-value:last').offset().top + ($('.core-value:last').outerHeight() / 2)) - ($('.core-value:first').offset().top + ($('.core-value:first').outerHeight() / 2)) - stopAbove); // Subtract 100px from the duration }, 1000); } } }