'use strict'; $(document).ready(function() { // 2023-05-25: Migrated from coffee.js while // removing CoffeeScript support. window.lazySizesConfig = { // clearAttr: true addClasses: true, preloadAfterLoad: false, threshold: 1 }; $('.carousel-deepdive').slick({ infinite: true, slidesToShow: 4, slidesToScroll: 4, responsive: [ { breakpoint: 980, // notebook breakpoint settings: { slidesToShow: 3, slidesToScroll: 3 } }, { breakpoint: 768, // tablet breakpoint settings: { slidesToShow: 2, slidesToScroll: 2 } }, { breakpoint: 480, // mobile breakpoint settings: { slidesToShow: 1, slidesToScroll: 1 } } ] }); // Mobile Conditional var isMobile = window.matchMedia("only screen and (max-width: 767px)"); // Carousel Height $('.carousel-deepdive').on('setPosition', function () { $(this).find('.slick-slide').height('auto'); var slickTrack = $(this).find('.slick-track'); var slickTrackHeight = $(slickTrack).height(); $(this).find('.slick-slide').css('height', slickTrackHeight + 'px'); }); $('.carousel-deepdive').on('init', function(event, slick){ $('.carousel-deepdive img').each(function(){ imageFit(this); }); }); // Responsive Menu $('.oco-hed__menu--toggle').click(function(){ $('.oco-hed__menu').toggleClass('active'); $('body').toggleClass('freeze'); $('.programs a').first().attr('href','#'); if ( $('.menu-item__shape').length < 1 && $('.oco-hed__menu').hasClass('active')) { $('.active .programs a').first().append(''); } }); $(window).resize(function(){ if ($(window).width() >= 768){ $('.oco-hed__menu').removeClass('active'); $('body').removeClass('freeze'); $('.programs a').first().attr('href','/programs'); $('.programs a svg').detach(); } }); $('.programs').click(function(){ $('.programs a').toggleClass('menu-item__shape--rotate'); $('.tidepool').toggleClass('on'); }); $(window).resize(function(){ if ($(window).width() <= 768){ $('.tidepool').removeClass('on'); } }); // Deep Dive Nav var $nav = $('.deepdive-nav'); var $btn = $('.deepdive-nav__more'); var $vlinks = $('.deepdive-nav__visible-links'); var $hlinks = $('.deepdive-nav__hidden-links'); var breaks = []; function updateNav() { if ($('.deepdive-nav')[0]) { console.log($nav); var availableSpace = $btn.hasClass('hidden') ? $nav.width() : $nav.width() - $btn.width() - 30; // The visible list is overflowing the nav if($vlinks.width() > availableSpace) { // Record the width of the list breaks.push($vlinks.width()); // Move item to the hidden list $vlinks.children().last().prependTo($hlinks); // Show the dropdown btn if($btn.hasClass('hidden')) { $btn.removeClass('hidden'); } // The visible list is not overflowing } else { // There is space for another item in the nav if(availableSpace > breaks[breaks.length-1]) { // Move the item to the visible list $hlinks.children().first().appendTo($vlinks); breaks.pop(); } // Hide the dropdown btn if hidden list is empty if(breaks.length < 1) { $btn.addClass('hidden'); $hlinks.addClass('hidden'); } } // Keep counter updated $btn.attr("count", breaks.length); // Recur if the visible list is still overflowing the nav if($vlinks.width() > availableSpace) { updateNav(); } } } if($('.deepdive-nav').length>0) { updateNav(); } // Window listeners $(window).resize(function() { updateNav(); }); $btn.on('click', function() { $hlinks.toggleClass('hidden'); }); // Remove/add titles from links on hover $('[title]').each(function(){ $(this).data('original-title', $(this).attr('title')); }).hover( function () { $(this).attr('title','') }, function () { $(this).attr('title',$(this).data('original-title')) }); // Video Scroll and Take Action function b/c they both are similar / don't want multiple window scroll functions var lastScrollTop = 0, yOff = Math.ceil(window.pageYOffset), scrollDir = ''; $(window).on('scroll', function(){ // Scroll Direction var yOff = Math.ceil(window.pageYOffset); if (yOff > lastScrollTop) { scrollDir = 'down'; } else { scrollDir = 'up'; } lastScrollTop = yOff; // Forshore and Fixed CTA foreshoreGone(yOff); fixedCTA(yOff); }); // Foreshore Gone foreshoreGone(yOff); function foreshoreGone(yOff){ if ($('.foreshore').length) { var action = $('.take-action'), ocoHed = $('.oco-hed'), footer = $('.oco-fot'), hpContainer = ($('.hp-content').length) ? $('body') : false; // Display Stuff if(yOff >= $('.foreshore').outerHeight()){ // Sticy Take Action if (!action.hasClass('reveal')) { action.addClass('reveal'); footer.addClass('oco-fot--btmg'); } // Sticky Header if ('up' === scrollDir && !ocoHed.hasClass('oco-hed--fixed')) { showFixedNav(ocoHed); } // HP Curtain if (hpContainer && !hpContainer.hasClass('unfix')) { hpContainer.addClass('unfix'); } } else { // Sticy Take Action if (action.hasClass('reveal')) { action.removeClass('reveal'); footer.removeClass('oco-fot--btmg'); } // Sticky Header if (ocoHed.hasClass('oco-hed--fixed')) { hideFixedNav(ocoHed); } // HP Curtain if (hpContainer && hpContainer.hasClass('unfix')) { hpContainer.removeClass('unfix'); } } // Sticky Header if ('down' === scrollDir && ocoHed.hasClass('oco-hed--fixed')) { hideFixedNav(ocoHed); } } } function showFixedNav(ocoHed){ $('.oco-hed--logo').attr('src', '/wp-content/themes/oco-wp/images/logo-wide-min.png'); ocoHed.addClass('oco-hed--fixed'); setTimeout(function () { ocoHed.addClass('oco-hed--reveal'); }, 1); } function hideFixedNav(ocoHed){ ocoHed.removeClass('oco-hed--reveal'); ocoHed.removeClass('oco-hed--fixed'); /* setTimeout(function () { ocoHed.removeClass('oco-hed--fixed'); $('.oco-hed--logo').attr('src', '/wp-content/themes/oco-wp/images/logo-min.png'); }, 300); */ } // Popup window $('.popup').click(function(event) { var width = 575, height = 400, left = ($(window).width() - width) / 2, top = ($(window).height() - height) / 2, url = this.href, opts = 'status=1' + ',width=' + width + ',height=' + height + ',top=' + top + ',left=' + left; window.open(url, '_blank', opts); return false; }); // Move last 2 uprush slides to begining $('.uprush__carousel .uprush').each(function(i){ if ($(this).is(':last-of-type')) { $(this).css('order', -1); } else if ($(this).is(':nth-last-of-type(2)')) { $(this).css('order', -2); } else { $(this).css('order', i); } }); // One at a time, wait for animation var carouselAnimating = false; // Carousel Nav $('.uprush__carousel--link').click(function(e){ e.preventDefault(); var dir = ($(this).hasClass('carousel-next')) ? 'next' : 'prev'; if (carouselAnimating === false) { carouselAnimating = true; moveSlides(dir); slidesReset(dir); } }); // Carousel Swipe $('.gulf-carousel').on('swipeleft', function(){ if (carouselAnimating === false) { carouselAnimating = true; moveSlides('next'); slidesReset('next'); } }); $('.gulf-carousel').on('swiperight', function(){ if (carouselAnimating === false) { carouselAnimating = true; moveSlides('prev'); slidesReset('prev'); } }); // Carousel moves all slides left or right by one slide function moveSlides(dir){ var dir = (typeof dir !== "undefined") ? dir : 'next', currentLeft = parseFloat($('.uprush__carousel').css('margin-left')), slideWidth = $('.uprush__carousel .uprush').outerWidth(true); slideWidth = (dir === 'next') ? slideWidth * -1 : slideWidth; $('.uprush__carousel').removeClass('noanimate'); $('.uprush__carousel').css('margin-left', (currentLeft + slideWidth) + 'px'); } // Reset Slides next For infinite display function slidesReset(dir) { var dir = (typeof dir !== "undefined") ? dir : 'next'; setTimeout(function(){ // don't animate order/carousel shift $('.uprush__carousel').addClass('noanimate'); var slides = $('.uprush__carousel .uprush'); // Next if (dir === 'next') { $(slides).each(function(){ if (-2 === parseInt($(this).css('order'))) { $(this).css('order', slides.length - 3); } else { $(this).css('order', parseInt($(this).css('order')) - 1); } }); // Prev } else { $(slides).each(function(){ if (slides.length === parseInt($(this).css('order')) + 3) { $(this).css('order', -2); } else { $(this).css('order', parseInt($(this).css('order')) + 1); } }); } $('.uprush__carousel').removeAttr('style'); carouselAnimating = false; }, 600); } // Mobile Eddy doMobileEddy(); // run again on window resize window.onresize = function(event) { doMobileEddy(); $('.ft-donation__image img, .dek__image img, .breaker__image img, .prog-dek__image img, .modal__image img').each(function(){ imageFit(this); }); }; function doMobileEddy() { $('.eddy').each(function(){ var nav = $(this).find('.eddy__nav-list'), breadcrumbs = $(this).find('.breadcrumbs'), bcWidth = (breadcrumbs.length) ? breadcrumbs.outerWidth(true) : 0, nrSearch = ($('.nr-search-form').length) ? $('.nr-search-form').innerWidth() : 0, eddyHed = $(this).find('.eddy--hed'), hedWidth = (eddyHed.length && 'none' !== eddyHed.css('display')) ? eddyHed.outerWidth(true) : 0, viewWidth = $(this).width(), paddedLeft = (!$(this).hasClass('eddy__programs')) ? 16 : 0; // programs nav doesn't need extra space... // Figure width of nav by adding all the
  • var navWidth = bcWidth + hedWidth + nrSearch; $(this).find('.eddy__nav-list > li').each(function(){ navWidth += $(this).width(); }); var minLeft = -1*(navWidth - viewWidth + paddedLeft), minLeft = (breadcrumbs.length) ? minLeft - 40 : minLeft, maxLeft = paddedLeft, maxLeft = (breadcrumbs.length && 'static' === $('.social-nav').css('position')) ? maxLeft - 16 : maxLeft; // Set initial target to find current var current = $(nav).children('.current-menu-item, .current_page_item, .current_page_ancestor, .current-page-ancestor, .post-type-archive .eddy__programs li:first-child, .tax-ptypes li.partner-link, .page-template-page-partners-all li.partner-link, .single-partner li.partner-link'); if (navWidth > viewWidth && $(current).length) { var currentLeft = -1 * Math.round(current.position().left); // extra 16 prevents overlap with gradient currentLeft = (currentLeft < minLeft) ? minLeft : currentLeft + paddedLeft; currentLeft = (currentLeft > maxLeft) ? maxLeft : currentLeft; // extra bit for breadcrumb navs currentLeft = currentLeft - bcWidth; nav = ($(this).find('.nav-wrapper').length) ? $(this).find('.nav-wrapper') : nav; $(nav).css('left', (currentLeft) + 'px'); disableEddyButton(currentLeft, minLeft, maxLeft); // Show gradients $(this).addClass('eddy--gradients'); // Eddy Swipe $(this).on('swipeleft', function(){ eddySlide(nav, 'left', viewWidth, minLeft, maxLeft); }); $(this).on('swiperight', function(){ eddySlide(nav, 'right', viewWidth, minLeft, maxLeft); }); // Eddy Left/Right Buttons (show if hidden first) $(this).children('.eddy__scroll').removeClass('eddy__scroll--hide'); $(this).children('.eddy__scroll').click(function(e){ e.preventDefault(); if ($(this).hasClass('eddy--left')) { eddySlide(nav, 'right', viewWidth, minLeft, maxLeft); } else { eddySlide(nav, 'left', viewWidth, minLeft, maxLeft); } }); } else { // Hide gradients $(this).removeClass('eddy--gradients'); // Hide scroll buttons $(this).children('.eddy__scroll').addClass('eddy__scroll--hide'); // remove left setting when removing scroll (in case) $(nav).removeAttr('style'); // remove swipe events $(this).off('swipeleft swiperight'); } }); } function eddySlide(nav, dir, viewWidth, minLeft, maxLeft) { // current left var currentLeft = parseInt($(nav).css('left')); // Left or Right if ('left' === dir) { var targetLeft = currentLeft - viewWidth + 80; targetLeft = (targetLeft < minLeft) ? minLeft : targetLeft; } else { var targetLeft = currentLeft + viewWidth - 80; targetLeft = (targetLeft > maxLeft) ? maxLeft : targetLeft; } // Slide nav! $(nav).css('left', targetLeft + 'px'); disableEddyButton(targetLeft, minLeft, maxLeft); } function disableEddyButton(position, minLeft, maxLeft) { if (position === minLeft) { $('.eddy__scroll').removeClass('inactive'); $('.eddy--right').addClass('inactive'); } else if (position === maxLeft) { $('.eddy__scroll').removeClass('inactive'); $('.eddy--left').addClass('inactive'); } else { $('.eddy__scroll').removeClass('inactive'); } } $("#revere-sync").on("sync_form_success", function(){ $('.mobile-signup__label').remove(); }); // current time (blog, single posts) if ($('.current-time').length) { var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; $('.current-time').each(function(){ var time = new Date(), timestampString = time.getFullYear() + '-' + ('0' + (time.getMonth() + 1)).slice(-2) + '-' + ('0' + time.getDate()).slice(-2), timeString = '' + dayNames[time.getDay()] + ', ' + monthNames[time.getMonth()] + ' ' + time.getDate(); $(this).attr('datetime', timestampString); $(this).html(timeString); }); } // Wildlife Programs Dropdown $('.drop-nav__open-close').click(function(e){ e.preventDefault(); // set button pos (centered using css when height if fixed) $(this).css({ 'transform': 'translateY(0)', 'top': $(this).position().top + 'px' }); var navList = $(this).parent('.drop-nav'); if (navList.hasClass('drop-nav--open')) { navList.removeClass('drop-nav--open'); } else { navList.addClass('drop-nav--open'); } }); // Add Active to Search input when search clicked $('.oco-hed__search .search-form__submit').click(function(e){ if (!$(this).prev().hasClass('active')) { e.preventDefault(); $(this).prev().addClass('active'); $(this).prev().focus(); } else if ($(this).prev().val() === '') { e.preventDefault(); $(this).prev().focus(); } }); if ($('.oco-hed__search .search-form__input').val() != ''){ $('.oco-hed__search .search-form__input').addClass('active'); } // Add Active to Seach input on focus $('.oco-hed__search .search-form__input,.oco-hed__search .search-form__submit').focus(function(){ $('.oco-hed__search .search-form__input').addClass('active'); }); // This anonymous function let's us determine the click location before blur // Search Slide Out on Focus $(function() { var clicky; $(document).mousedown(function(e) { // The latest element clicked clicky = $(e.target); }); // when 'clicky == null' on blur, we know it was not caused by a click // but maybe by pressing the tab key $(document).mouseup(function(e) { clicky = null; }); // Search Slide In on Blur $('.oco-hed__search .search-form__input').blur(function(e) { // console.log(clicky); if (typeof clicky !== 'undefined' && !$(clicky).hasClass('search-form__submit') && $('.oco-hed__search .search-form__input').val() == '') { $(this).removeClass('active'); } else if (typeof clicky === 'undefined' && $('.oco-hed__search .search-form__input').val() == '') { setTimeout(function(){ if(!$('.oco-hed__search .search-form__submit:focus').length) { $('.oco-hed__search .search-form__input').removeClass('active'); } },1); } }); // Search Button In on Blur $('.search-form__submit').blur(function(e){ // console.log(clicky); if (typeof clicky !== 'undefined' && !$(clicky).hasClass('search-form__input') && $('.search-form__input').val() == '') { $(this).removeClass('active'); } else if (typeof clicky === 'undefined' && $('.search-form__input').val() == '') { setTimeout(function(){ if(!$('.search-form__input:focus').length) { $('.search-form__input').removeClass('active'); } },1); } }); }); // Nav Menu Page Overlay $('.has-oco-menu a').click( function() { if ('none' === $('.oco-hed__menu--toggle').css('display')) { $('body').addClass('has-overlay'); } }, function() { if ('none' === $('.oco-hed__menu--toggle').css('display')) { $('body').removeClass('has-overlay'); } } ); // Fixed sidebar cta fixedCTA(yOff); function fixedCTA(yOff) { var cta = $('.channel__aside .kelp'); if (cta.length && '262px' === cta.parent().css('max-width') && $('.channel__aside').innerHeight() <= $('.channel--body').innerHeight()){ var ctaOff = cta.offset().top, ctaHeight = cta.innerHeight(), ctaWidth = cta.width(), channel = $('.channel'), channelOff = channel.offset().top, channelHeight = channel.innerHeight(); // Set store CTA offset if (cta.hasClass('bottom') || cta.hasClass('fixed')) { cta.data('og-off', cta.data('og-off')); } else { cta.data('og-off', ctaOff); } // Stick at bottom if (yOff + ctaHeight >= channelOff + channelHeight) { if (!cta.hasClass('bottom')){ cta.removeClass('fixed').addClass('bottom').width(ctaWidth); } } // Fixed else if (yOff >= cta.data('og-off') && !cta.hasClass('fixed')) { cta.removeClass('bottom').addClass('fixed').width(ctaWidth); } // Default else if (yOff < cta.data('og-off') && cta.hasClass('fixed')) { cta.removeClass('fixed'); } // Move Fixed CTA when nav is showing if (cta.hasClass('fixed')) { if ('up' === scrollDir && !cta.hasClass('fixed--up')) { cta.addClass('fixed--reveal'); setTimeout(function () { cta.addClass('fixed--up'); }, 1); } else if ('down' === scrollDir && cta.hasClass('fixed--up')) { cta.removeClass('fixed--up'); setTimeout(function () { cta.removeClass('fixed--reveal'); }, 300); } } } //remove is screen shrinks else if (cta.length && (cta.hasClass('fixed') || cta.hasClass('bottom'))) { cta.removeClass('fixed bottom fixed--up fixed--reveal').removeAttr('style'); } } $('#revmsg-CallSignupForm #phone').each(function(){ $(this).attr('required', 'required'); }); //p2p header if ($('.rot-hed').length) { var totalH = $('.rot-hed').length; timedHeader(2, totalH); // queues 2nd header on page load (repeating)... function timedHeader(i, totalH){ setTimeout(function () { var next = $('.rot-hed:nth-child(' + i + ')'); next.addClass('animate-left').css({'margin-left': '0', 'opacity': 1}); $(".p2p-foreshore .action").removeClass('shake'); if (i < totalH) { setTimeout(function () { $(".p2p-foreshore .action").addClass('shake'); setNextHeader(i, totalH); }, 1000); } else { setTimeout(function () { $('.rot-hed').each(function(i){ $(this).removeAttr('style').css('margin-left', '0'); if (i + 1 === totalH) { $(this).css('order', -1); } }); i = 0; $(".p2p-foreshore .action").addClass('shake'); setNextHeader(i, totalH); }, 1000); } }, 2000); } function setNextHeader(i, totalH){ $('.rot-hed').removeClass('animate-left next'); $('.rot-hed:nth-child(' + (i + 1) + ')').addClass('next').css({'order': (-1 * (i + 2)), 'margin-left': '-100%'}); setTimeout(function () { timedHeader(i+1, totalH); }, 1); } } // p2p marquee button if ($('.p2p-foreshore .action').length) { setTimeout(function () { $('.p2p-foreshore .action').addClass('animate-top'); setTimeout(function () { //$(".p2p-foreshore .action").addClass('shake'); }, 600); }, 300); } // p2p idea list if ($('.idea__list').length && $('.idea').length > 4) { timedIeads(1, 1); // queues idea on page load (repeating)... function timedIeads(i, trips){ setTimeout(function () { if (i > $('.idea').length) { i = 1; trips++; } $('.idea:nth-child(' + i + ')').addClass('animate-left').css({'margin-left': '-300px'}); setTimeout(function () { setNextIdea(i, trips); }, 800); }, 2000); } function setNextIdea(i, trips){ $('.idea:nth-child(' + i + ')').removeClass('animate-left').css({'order': (trips), 'margin-left': '0'}); setTimeout(function () { timedIeads(i+1, trips); }, 1); } } // p2p step button if ($('.p2p--step .action').length) { $('.p2p--step .action').each(function(i){ var etop = $(this).parents('.p2p--step').offset().top; var eBottom = etop + $(this).parents('.p2p--step').innerHeight(); if (eBottom <= $(window).scrollTop() + $(window).height() || etop <= $(window).scrollTop()) { buttonUp(i); } $(window).scroll(function() { if (eBottom <= $(window).scrollTop() + $(window).height() || etop <= $(window).scrollTop()) { buttonUp(i); } }); }); function buttonUp(i) { $('.p2p--step .action:eq(' + i + ')').addClass('animate-top'); } } // p2p stories (random) if ($('.p2p--stories .stories__li').length > 2) { var rand1 = randomIntFromInterval(1, $('.stories__li').length); $('.stories__li:nth-child(' + rand1 + ')').addClass('first'); var rand2 = randomIntFromInterval(1, $('.stories__li').length); while (rand2 === rand1) { rand2 = randomIntFromInterval(1, $('.stories__li').length); } $('.stories__li:nth-child(' + rand2 + ')').addClass('second'); } // Random Int Function function randomIntFromInterval(min,max) { return Math.floor(Math.random()*(max-min+1)+min); } // p2p step image animations if ($('.p2p__pic').length) { $('.p2p__pic').each(function(i){ var eTop = $(this).parents('.p2p--step').offset().top; var eMid = eTop + $(this).parents('.p2p--step').innerHeight()/2; if (eMid <= $(window).scrollTop() + $(window).height() || eTop <= $(window).scrollTop()) { p2pImgSlide(i); } $(window).scroll(function() { if (eMid <= $(window).scrollTop() + $(window).height() || eTop <= $(window).scrollTop()) { p2pImgSlide(i); } }); }); function p2pImgSlide(i) { // stagger if it's the second image if ($('.p2p__pic:eq(' + i + ')').prev('.p2p__pic').length) { setTimeout(function () { $('.p2p__pic:eq(' + i + ')').addClass('slide-in'); }, 500); } else { $('.p2p__pic:eq(' + i + ')').addClass('slide-in'); } } } // p2p QA animation if ($('.p2p--stories').length) { $('.stories__li').each(function(i){ var eTop = $(this).parents('.stories__list').offset().top; var eMid = eTop + $(this).parents('.stories__list').innerHeight()/4; if ('block' === $('.stories__list').css('display')) { qaSlide(i); } else if (eMid <= $(window).scrollTop() + $(window).height() || eTop <= $(window).scrollTop()) { qaSlide(i); } $(window).scroll(function() { if (eMid <= $(window).scrollTop() + $(window).height() || eTop <= $(window).scrollTop()) { qaSlide(i); } }); }); function qaSlide(i) { // stagger if it's the second image if ($('.stories__li:eq(' + i + ')').prev('.stories__li').length) { setTimeout(function () { $('.stories__li:eq(' + i + ')').addClass('slide-in'); }, 500); } else { $('.stories__li:eq(' + i + ')').addClass('slide-in'); } } } // Smooth Scrolling Links // Select all links with hashes $('a[href*="#"]') // Remove links that don't actually link to anything .not('[href="#"]') .not('[href^="#modal"]') // prevent modal from breaking .not('[href="#0"]') .click(function(event) { // On-page links if ( location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname ) { // Figure out element to scroll to var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); // Does a scroll target exist? if (target.length) { // Only prevent default if animation is actually gonna happen //event.preventDefault(); $('html, body').animate({ scrollTop: target.offset().top }, 1000, function() { // Callback after animation // Must change focus! var $target = $(target); $target.focus(); if ($target.is(":focus")) { // Checking if the target was focused return false; } else { $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable $target.focus(); // Set focus again }; }); } } }); // p2p FAQ $('.faq').on('click', function(){ $(this).toggleClass('open'); }); // Size video iframe function sizeVideoIframe(iframe) { var iframe_width = iframe.width(); var iframe_height = iframe_width * 0.5625; iframe.attr('height', iframe_height); } if( $('.post-item__video iframe').length > 0 ) { sizeVideoIframe( $('.post-item__video iframe') ); $(window).resize(function(){ sizeVideoIframe( $('.post-item__video iframe') ); }) } // post item content function sizePostItemContent() { if( $(window).width() > 767 && $('.post-item__content').length > 0 ) { var descriptionHeight = $('.post-item__description').height(); if( descriptionHeight > 310 ) { $('.post-item__content').css('height', descriptionHeight); } else { $('.post-item__content').css('height', '310px'); } } else { $('.post-item__content').removeAttr('style'); } } sizePostItemContent(); $(window).resize(function(){ sizePostItemContent(); }) //Share Your Story form toggle $('.form-inline__button').click(function(){ if($('#share').hasClass('open')) { $('#share').animate({ height: 0 }, 800, function(){ $('#share').removeClass('open') }); } else { $('#share').addClass('open') var screenWidth = $(window).width(); if(screenWidth < 768) { $('#share').animate({ height: 684 }, 800, function(){ $('#share').css('height', 'auto'); }); } else { $('#share').animate({ height: 482 }, 500, function(){ $('#share').css('height', 'auto'); }); } } }); // Deep Dive Landing Page scrolling Marquee $(window).scroll(function() { var wS = $(this).scrollTop(); if (wS > 1120 && $('.marquee-deepdive--landing').length > 0){ $('.marquee-deepdive__container').removeClass('marquee-deepdive-fixed'); $('.oco-hed').removeClass('oco-hed--deepdive'); $('.marquee-deepdive__container').addClass('marquee-deepdive-absolute'); } if (wS < 1120 && $('.marquee-deepdive--landing').length > 0){ $('.marquee-deepdive__container').addClass('marquee-deepdive-fixed'); $('.oco-hed').addClass('oco-hed--deepdive'); $('.marquee-deepdive__container').removeClass('marquee-deepdive-absolute'); } }); if ($('.g_file').length){ $('.ginput_container_fileupload, .ginput_container_post_image').each(function(){ var container = $(this), label = container.siblings('label'), input = container.find('input[type="file"]'); label.clone().insertAfter(input).text('Select File').addClass('upload-label'); input.addClass('assistive-text'); input.on('change', function(e) { var fileName = ''; if( this.files && this.files.length > 1 ) { fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length ); } else { fileName = e.target.value.split( '\\' ).pop(); } $('
    ' + fileName + '
    ').insertAfter(input); console.log(fileName); }); }); } if ($('.g_long input, .g_lat input').length) { new Cleave('.g_long input, .g_lat input', { numeral: true, numeralThousandsGroupStyle: 'none', numeralDecimalScale: 4 }); } }); // end $(document).ready // Ft Donation/About Deck Sizing function (b/c that shit's cray) function imageFit(img){ var container = $(img).parents('[class$="__image"]'); if (container.width() > $(img).width()) { $(img).css({ 'height': 'auto', 'width': '100%' }); } else if (container.height() > $(img).height()) { $(img).removeAttr('style'); } } // Image Fit v2, used in onload or within doc ready function imageFit2(img){ var container = $(img).parents('[class$="__image"]'); if (container.innerHeight() > $(img).height()) { $(img).css({ 'height': '100%', 'width': 'auto' }); } else if (container.width() > $(img).width()) { $(img).removeAttr('style'); } } (function() { var isSecure; isSecure = function() { return window.location.protocol === 'https:'; }; $(document).ready(function() { $('#revmsg-CallSignupForm').attr('action', 'javascript:void(0);'); $('#revmsg-CallSignupForm').submit(function(e) { var info, revereCalling, s; info = { phone: $('#phone').val(), campaign_line: $('#campaign_line').val() }; if ($('#name').length > 0 && $('#name').val() !== '') { info.name = $('#name').val(); } if ($('#first_name').length > 0 && $('#first_name').val() !== '') { info.first_name = $('#first_name').val(); } if ($('#last_name').length > 0 && $('#last_name').val() !== '') { info.last_name = $('#last_name').val(); } if ($('#zip').length > 0 && $('#zip').val() !== '') { info.zip = $('#zip').val(); } if ($('#email').length > 0 && $('#email').val() !== '') { info.email = $('#email').val(); } s = isSecure() ? 's' : ''; revereCalling = 'http' + s + '://' + 'phone.reverehq.com/outgoing/'; $.get(revereCalling, info, function(data) { if (data.err) { $('#revmsg-click-to-call #revmsg-CallSignupForm .err').html(data.message); $('#revmsg-click-to-call #revmsg-CallSignupForm .err').show(); } else { if($('#revmsghtml').length > 0 && $('#revmsghtml').val() !== '' && $('#revmsghtml').val() != window.location && $('#always_redirect').val() == 'true') { window.location = 'http://'+$('#revmsghtml').val(); } else { $('#revmsg-click-to-call .success').html(data.message); $('#revmsg-CallSignupForm').hide(); $('#revmsg-click-to-call .success').show(); } } }); return false; }); }); }).call(this);