jQuery(document).ready(function($) {
doStoryOverlay();
var autoplay = true;
// homepage video -- pause button
$('.video-header').prepend(
'
'
)
$('.video-controls').append(
''
);
$('#video-play-pause-1').on('click', function () {
var $button = $(this);
if ( $button.hasClass('playing') ) {
$button.closest('.video-header').find('video').each(function (index, element) {
element.pause();
});
}
else {
$button.closest('.video-header').find('video').each(function (index, element) {
element.play();
});
}
});
$('a[href^="http://"]').filter(function() {
return this.hostname && this.hostname !== location.hostname;
}).attr('target', '_blank');
$('.eventlinkholder').each(function() {
if ($(this).hasClass('partnertrue')) {
$a = $(this).attr('rel');
if ($a == "") {} else {
$(this).find('.a-post-content a').attr('href', $a).attr('target', '_blank');
}
}
});
$('input[type=radio]').click(function() {
$(this).closest("form").submit();
});
});
$ = jQuery.noConflict();
var doStoryOverlay = function () {
var $featureImg;
$featureImg = $('body.single').find('.fImage.fImage-single');
if ($('body.single-stories').length && $featureImg.length) {
$(".overlay-general").filter(function() {
$(this).appendTo($featureImg);
$(this).show();
})
}
if ($('body.single-publications').length && $featureImg.length) {
$(".overlay-general").filter(function() {
$(this).appendTo($featureImg);
$(this).show();
})
}
}
// Set up our hotspots.
var hotspots = [
{ startTime: 13.5, endTime: 17.5, top: "68%", right: "6.6%", height: "8%", width: "17%", href: "https://2019.arcusfoundation.org", type: 1 , label:"Read the Arcus Foundation 2019 Annual Report", label2:"Destruction of nature exposes us to a panoply of diseases, and creates and exacerbates social injustice and political repression around the world"},
{ startTime: 29.5, endTime: 34, top: "64.5%", right: "8%", height: "7.6%", width: "13.8%", href: "/our-support/social-justice-lgbt", type: 1, label:"Learn about our support of LGBTQ communities", label2:"LGBTQ communities served by our Social Justice Program live at the intersection of this long chain of degradation—environmental and social" },
{ startTime: 50.5, endTime: 52,top: "71%", right: "44.5%", height: "7.6%", width: "14%", href: "/stories-of-impact/none/lgbtq-migrants-to-the-u-s-fight-to-stay-safe/", type: 1, label:"Stories of Impact: LGBTQ immigrants to the U.S. fight to stay safe", label2:"
There's incredible power in the trans queer migrant community. To be dehumanized so much and not lose your hope, your sense of joy—it's just astonishing.
—Umi Vera, Familia: Trans Queer Liberation Movement, United States" },
{ startTime: 64.5, endTime: 67, label2:"", top: "72.5%", right: "52%", height: "7.6%", width: "13.8%", href: "/stories-of-impact/lgbt/i-know-who-i-am-but-my-country-doesnt-recognize-me/", label:"Stories of Impact: I know who I am, but my country doesn't recognize me", type: 1 },
{ startTime: 83.5, endTime: 87, top: "47%", right: "48.6%", height: "7.6%", width: "13.8%", href: "/stories-of-impact/lgbt/supporting-cape-towns-homeless-transgender-women-during-covid-19/", label:"Stories of Impact: Supporting Cape Town's homeless transgender women during COVID-19", type: 1 },
{ startTime: 104, endTime: 108, top: "65%", right: "3%", height: "7.6%", width: "14%", href: "https://www.stateoftheapes.com", type: 1, label:"The State of the Apes" },
{ startTime: 128, endTime: 132, top: "56%", right: "54%", height: "7.6%", width: "13.8%", href: "/our-support/great-apes/", type: 1, label:"Our Support: Great Apes & Gibbons Program"},
{ startTime: 193, endTime: 197, top: "68%", right: "54.6%", height: "7.6%", width: "13.8%", href: "/annual-reporting", type: 1, label:"Annual Reporting" },
{ startTime: 208, endTime: 211, top: "54.5%", right: "35.5%", height: "10%", width: "25.8%", href: "https://www.arcusfoundation.org/social/", label:"Connect with us on social media", type: 1 },
{ startTime: 211.1, endTime: 214, top: "72.5%", right: "6%", height: "7.6%", width: "13.8%", href: "/credits/", label:"Credits", type: 2 }
];
function init() {
var video = document.getElementById('sampleVideo');
if ( video ) {
var $holder = $(video).closest('.video-header').find('#holder');
var hotspotData;
// create ACCESSIBLE hotspots for the video that can be navigated via keyboard
$holder.empty();
for (var i = 0; i < hotspots.length; i++) {
var hotspotData = hotspots[i];
hotspotData.href = hotspotData.href || '';
hotspotData.label = hotspotData.label || '';
var $hotspot = $('');
// var $labelHolder = $('#rotator2').find('a[href^="'+hotspotData.href+'"]').find('.sr-only');
// if ($labelHolder.length) {
// hotspotData.label = $labelHolder.html();
// }
var $link = $('');
$hotspot.css({
// top: hotspotData.top,
top:0,
// right: hotspotData.right,
left: 0,
// height: hotspotData.height,
height:'100%',
// width: hotspotData.width
width:'100%'
});
// fast forward to hotspot range
// $link.on('focus', function () {
// var time = Number($(this).data('starttime'));
// video.currentTime = time+1.3;
// video.pause();
// })
$hotspot.append($link);
$holder.append($hotspot);
}
video.addEventListener( 'pause', function () {
video.classList.add('paused');
$(video).closest('.video-header').find('.play-pause-btn').removeClass('playing');
});
video.addEventListener( 'play', function () {
video.classList.remove('paused');
$(video).closest('.video-header').find('.play-pause-btn').addClass('playing');
})
// Disable clicking on hotspots when the video is not within their start/end time (still allow tabbing to focus)
video.addEventListener( 'timeupdate', function () {
// Grab the current video pointer time mark.
var currentTime = video.currentTime;
for ( var i = 0; i < hotspots.length; i++ ) {
var hotspot = hotspots[i];
var $hotspot = $holder.find('.hotspot').eq(i);
if ( currentTime >= hotspots[i].startTime && currentTime < hotspots[i].endTime ) {
$hotspot.css('pointer-events','all');
} else { // clear:
$hotspot.css('pointer-events', 'none');
}
}
}, false );
// mute the video so it'll autoplay:
video.muted = true;
if ( video.readyState >= video.HAVE_FUTURE_DATA ) {
video.play();
} else {
video.addEventListener( 'canplay', function () {
this.play();
}, false );
}
}
twoItemSlider();
}
function twoItemSlider () {
var autoplay = false;
var $slider = $('.two-item-slider');
var timer;
var $indicators = $slider.append(
''
).find('.carousel-indicators');
$slider.each(function () {
var $slider = $(this);
$slider.find('.slider-inner').find('a,button,input').on('focus', function () {
var index = $(this).closest('.slide').index();
clearInterval(timer);
goToSlide(index);
})
});
$slider.find('.slide').each(function () {
var $slide = $(this);
var active = $slide.hasClass('active');
var index = $slide.index();
var $indicator = $(
''
)
$indicator.on('click', function (event) {
event.stopPropagation();
event.stopImmediatePropagation();
var index = $(this).index();
goToSlide(index);
})
$indicators.append($indicator);
})
if (autoplay) {
timer = setInterval(sliderMoveRight, 7000);
}
function goToSlide(index) {
var $slide = $slider.find('.slide').eq(index);
$slider.find('.slide').removeClass('active');
$slide.addClass('active');
$indicators.find('.active').removeClass('active');
$indicators.find('.indicator').eq(index).addClass('active');
}
function sliderMoveRight() {
var $currentSlide = $slider.find('.slide.active');
var nextIndex = $currentSlide.index()+1;
var $nextSlide = $slider.find('.slide').eq(nextIndex);
if ($nextSlide.length === 0) {
$nextSlide = $slider.find('.slide').first();
}
$currentSlide.removeClass('active');
$nextSlide.addClass('active');
$indicators.find('.active').removeClass('active');
$indicators.find('.indicator').eq(nextIndex).addClass('active');
}
}
window.addEventListener('load', init);