function onYouTubeIframeAPIReady(){
console.log('onYouTubeIframeAPIReady');
(function ($){
if($('.youtube-wrap').length){
$('.youtube-wrap').each(function (){
let player=new YT.Player($(this).find('.div_iframe').attr('id'), {
videoId: $(this).find('.div_iframe').attr('data-youtube-id'),
playerVars: {
'playsinline': 1,
'rel': 0,
},
events: {
'onReady': function (){
},
}});
})
}}(window.jQuery||window.$));
}
(function ($){
if($('body').hasClass('page-template-tpl-home') &&
!$('.home-video-wrap[data-fade-to-grid="1"]').length &&
!$('.home-carousel').length){
var $slides=$('.home-carousel__slide');
var revealCarousel=function (){
$('.page-template-tpl-home .fullscreen:not(.home-video-wrap)').addClass('loaded');
};
if($slides.length){
var landscape=window.innerWidth > window.innerHeight;
var want=landscape ? 'landscape':'portrait';
var $firstSlide=$slides.filter(function (){
return ($(this).attr('data-orient')||'landscape')===want
&& $(this).find('img').length > 0;
}).first();
if(!$firstSlide.length){
$firstSlide=$slides.filter(function (){
return ($(this).attr('data-orient')||'landscape')==='square'
&& $(this).find('img').length > 0;
}).first();
}
if(!$firstSlide.length){
$firstSlide=$slides.filter(function (){
return $(this).find('img').length > 0;
}).first();
}
var $firstImg=$firstSlide.find('img').first();
if($firstImg.length){
if($firstImg[0].complete&&$firstImg[0].naturalWidth > 0){
revealCarousel();
}else{
$firstImg.one('load error', revealCarousel);
$(window).one('load', revealCarousel);
}}else{
$(window).one('load', revealCarousel);
}}
}
$(window).on('load', function (){
if($('.home-video-wrap[data-fade-to-grid="1"]').length){
$('.home-video-wrap').addClass('loaded');
}
if($('.home-video-wrap').length){
$('.home-video-wrap .home-logo').fadeTo("slow", 0);
$('.home-video-wrap .home-logo-small').fadeIn("slow");
}
if($('.vimeo-wrap').length){
$('.vimeo-wrap').each(function (index){
let este=$(this)
var options={
title: 0,
byline: 0,
portrait: 0
};
let player=new Vimeo.Player($(this).attr('id'), options);
player.ready().then(function (){
let video_width=$(este).find('iframe').attr('width')
let video_height=$(este).find('iframe').attr('height')
$(este).css('--aspect-ratio-crop', video_width + '/' + video_height)
})
})
}});
$(document).ready(function (){
safari100vhHack();
var _dcmAocWillShow=$('.aoc-wrap').length > 0
&& (typeof Cookies!=='undefined')
&& empty(Cookies.get('oac'));
var _dcmAocCleared = !_dcmAocWillShow;
$(document).on('aoc-cleared', function (){ _dcmAocCleared=true; });
if($('.home-carousel').length){
var $slides=$('.home-carousel__slide');
if($slides.length > 0){
var eligible=[];
var pos=0;
var nextTimer=null;
var _imgDuration=parseInt($('.home-carousel').attr('data-image-duration'), 10);
if(!_imgDuration||_imgDuration < 500) _imgDuration=4400;
var _allowFullVideo=$('.home-carousel').attr('data-allow-full-video')==='1';
var savedPermalinkOrder=null;
var currentOrient=null;
function rebuildEligible(){
var landscape=window.innerWidth > window.innerHeight;
currentOrient=landscape ? 'landscape':'portrait';
var prevPermalink=null;
if(eligible.length&&pos >=0&&pos < eligible.length){
prevPermalink=$slides.eq(eligible[pos]).attr('data-permalink');
}
eligible=[];
var byProject={};
var insertOrder=[];
$slides.each(function (i){
var key=this.getAttribute('data-permalink')||('__' + i);
var orient=this.getAttribute('data-orient')||'landscape';
if(!byProject[key]){
byProject[key]=[];
insertOrder.push(key);
}
byProject[key].push({ index: i, orient: orient });
});
var want=landscape ? 'landscape':'portrait';
function pickForProject(key){
var items=byProject[key];
if(!items) return null;
var preferred=items.filter(function (it){
return it.orient===want;
});
if(!preferred.length){
preferred=items.filter(function (it){
return it.orient==='square';
});
}
var pick=preferred.length ? preferred[0]:items[0];
return pick.index;
}
if(!savedPermalinkOrder){
insertOrder.forEach(function (key){
var idx=pickForProject(key);
if(idx!==null) eligible.push(idx);
});
for (var si=eligible.length - 1; si > 0; si--){
var sj=Math.floor(Math.random() * (si + 1));
var st=eligible[si]; eligible[si]=eligible[sj]; eligible[sj]=st;
}
var imgs=[];
var vids=[];
eligible.forEach(function (idx){
if($slides.eq(idx).attr('data-type')==='video') vids.push(idx);
else                                              imgs.push(idx);
});
if(vids.length > 0&&imgs.length >=5){
var first5=imgs.slice(0, 5);
var rest=imgs.slice(5).concat(vids);
for (var k=rest.length - 1; k > 0; k--){
var r=Math.floor(Math.random() * (k + 1));
var t=rest[k]; rest[k]=rest[r]; rest[r]=t;
}
eligible=first5.concat(rest);
}
savedPermalinkOrder=eligible.map(function (idx){
return $slides.eq(idx).attr('data-permalink');
});
}else{
eligible=savedPermalinkOrder
.map(function (key){ return pickForProject(key); })
.filter(function (idx){ return idx!==null; });
}
if(eligible.length===0){
$slides.each(function (i){ eligible.push(i); });
}
var keep=-1;
if(prevPermalink){
for (var p=0; p < eligible.length; p++){
if($slides.eq(eligible[p]).attr('data-permalink')===prevPermalink){
keep=p;
break;
}}
}
pos=keep >=0 ? keep:0;
}
var $captions=$('.home-carousel__caption-stage .home-carousel__caption');
function updateCaption($slide){
if($captions.length < 2) return;
var $incoming=$captions.filter(':not(.is-active)').first();
var $outgoing=$captions.filter('.is-active').first();
$incoming.find('.home-carousel__title')
.text($slide.attr('data-title')||'')
.attr('href', $slide.attr('data-permalink')||'#');
$incoming.find('.home-carousel__location')
.text($slide.attr('data-location')||'');
$outgoing.removeClass('is-active');
$incoming.addClass('is-active');
}
var advanceCount=0;
function advance(){
if(eligible.length===0) return;
var nextPos=(pos + 1) % eligible.length;
var nextIdx=eligible[nextPos];
var $next=$slides.eq(nextIdx);
if($next.attr('data-type')==='image'){
var nextImg=$next.find('img')[0];
if(nextImg&&!nextImg.complete){
if(nextTimer) clearTimeout(nextTimer);
nextTimer=setTimeout(advance, 200);
return;
}}
var $cur=$slides.eq(eligible[pos]);
if($cur.attr('data-type')==='image'){
var curImg=$cur.find('img')[0];
if(curImg&&curImg._dcmUpgrading){
if(nextTimer) clearTimeout(nextTimer);
nextTimer=setTimeout(advance, 200);
return;
}}
var curIdx=eligible[pos];
var $cur=$slides.eq(curIdx);
$cur.removeClass('is-active').addClass('is-leaving');
$next.addClass('is-active');
updateCaption($next);
advanceCount++;
setTimeout(function (){ $cur.removeClass('is-leaving'); }, 600);
pos=nextPos;
if(nextTimer) clearTimeout(nextTimer);
if($next.attr('data-type')==='video'){
playSlide($next);
}else{
nextTimer=setTimeout(function (){ playSlide($next); }, 600);
}}
function preloadVideoAt(p){
var $s=$slides.eq(eligible[p]);
if(!$s.length||$s.attr('data-type')!=='video') return;
var v=$s.find('video')[0];
if(v&&!v.src&&v.dataset&&v.dataset.src){
v.src=v.dataset.src;
v.load();
}}
function preloadImageAt(p){
if(p < 0||p >=eligible.length) return;
var $s=$slides.eq(eligible[p]);
if(!$s.length||$s.attr('data-type')!=='image') return;
var img=$s.find('img')[0];
if(!img||img.src) return;
if(img.dataset&&img.dataset.srcset&&!img.srcset){
img.srcset=img.dataset.srcset;
}
if(img.dataset&&img.dataset.src){
img.src=img.dataset.src;
}}
function maybeUpgradeSlideImage($slide){
var img=$slide.find('img')[0];
if(!img) return;
var srcset=img.getAttribute('srcset');
if(!srcset) return;
if(!img.naturalWidth) return;
var w=parseFloat($slide.attr('data-w'))||16;
var h=parseFloat($slide.attr('data-h'))||9;
var ar=w / h;
var dpr=window.devicePixelRatio||1;
var renderedCssWidth=Math.max(window.innerWidth,
window.innerHeight * ar
);
if(window.innerWidth > 1920){
renderedCssWidth *=1.15;
}
var requiredPxWidth=renderedCssWidth * dpr;
if(img.naturalWidth >=requiredPxWidth * 0.9) return;
if(img._dcmUpgrading) return;
img._dcmUpgrading=true;
var tmp=new Image();
tmp.sizes=img.getAttribute('sizes')||'';
var swap=function (){
tmp.removeEventListener('load', swap);
tmp.removeEventListener('error', swap);
img._dcmUpgrading=false;
if(!$slide.hasClass('is-active')) return;
img.srcset=srcset;
};
tmp.addEventListener('load', swap);
tmp.addEventListener('error', swap);
tmp.srcset=srcset;
}
function playSlide($slide){
maybeUpgradeSlideImage($slide);
preloadVideoAt((pos + 1) % eligible.length);
preloadImageAt((pos + 1) % eligible.length);
var type=$slide.attr('data-type');
if(type==='video'){
var video=$slide.find('video')[0];
if(!video){ nextTimer=setTimeout(advance, _imgDuration); return; }
if(!video.src&&video.dataset&&video.dataset.src){
video.src=video.dataset.src;
}
var ended=false;
var finish=function (){
if(ended) return;
ended=true;
video.removeEventListener('ended', finish);
if(nextTimer){ clearTimeout(nextTimer); nextTimer=null; }
advance();
};
video.addEventListener('ended', finish);
if(!_allowFullVideo){
nextTimer=setTimeout(finish, _imgDuration + 600);
}
var p=video.play();
if(p&&p.catch) p.catch(function (){
if(nextTimer) clearTimeout(nextTimer);
nextTimer=setTimeout(advance, _imgDuration);
});
}else{
nextTimer=setTimeout(advance, _imgDuration);
}}
var playCurrentSeq=0;
function playCurrent(){
if(eligible.length===0) return;
var seq=++playCurrentSeq;
var $slide=$slides.eq(eligible[pos]);
preloadImageAt(pos);
var activate=function (){
if(seq!==playCurrentSeq) return;
$slides.removeClass('is-active is-leaving');
$slide.addClass('is-active');
updateCaption($slide);
playSlide($slide);
};
if($slide.attr('data-type')==='image'){
var img=$slide.find('img')[0];
if(img&&!img.complete){
var done=false;
var fire=function (){
if(done) return;
done=true;
activate();
};
img.addEventListener('load',  fire, { once: true });
img.addEventListener('error', fire, { once: true });
setTimeout(fire, 2000);
return;
}}
activate();
}
function startCarousel(){
rebuildEligible();
preloadImageAt(pos);
if(eligible.length > 1){
preloadImageAt((pos + 1) % eligible.length);
}
if(eligible.length > 0){
var $first=$slides.eq(eligible[pos]);
$first.addClass('is-active');
var $caption=$captions.first();
if($caption.length){
$caption.find('.home-carousel__title')
.text($first.attr('data-title')||'')
.attr('href', $first.attr('data-permalink')||'#');
$caption.find('.home-carousel__location')
.text($first.attr('data-location')||'');
$caption.addClass('is-active');
}}
var begun=false;
var begin=function (){
if(begun) return;
begun=true;
$('.home-carousel').addClass('loaded');
if(_dcmAocWillShow&&!_dcmAocCleared){
$(document).one('aoc-cleared', playCurrent);
}else{
playCurrent();
}};
var $firstImg=(eligible.length > 0)
? $slides.eq(eligible[pos]).find('img').first()
: $();
if($firstImg.length){
setTimeout(begin, 3000);
if(typeof $firstImg[0].decode==='function'){
$firstImg[0].decode().then(begin).catch(begin);
}else{
$firstImg.one('load error', begin);
}}else{
begin();
}}
if($('body').hasClass('intro-pending')&&$('.home-video-wrap').length){
$(document).one('intro-fade-started', startCarousel);
}else{
startCarousel();
}
var resizeDebounce=null;
$(window).on('resize orientationchange', function (){
if(resizeDebounce) clearTimeout(resizeDebounce);
resizeDebounce=setTimeout(function (){
var landscape=window.innerWidth > window.innerHeight;
var newOrient=landscape ? 'landscape':'portrait';
if(currentOrient===newOrient) return;
rebuildEligible();
if(nextTimer) clearTimeout(nextTimer);
playCurrent();
}, 200);
});
var pausedByVisibility=false;
document.addEventListener('visibilitychange', function (){
if(document.hidden){
if(nextTimer){
clearTimeout(nextTimer);
nextTimer=null;
pausedByVisibility=true;
}
$slides.filter('.is-active').find('video').each(function (){
try { this.pause(); } catch (e){}});
}else if(pausedByVisibility){
pausedByVisibility=false;
var $active=$slides.eq(eligible[pos]);
$active.find('img').each(function (){
if(this.naturalWidth===0&&this.src){
var s=this.src;
this.src='';
this.src=s;
}});
playCurrent();
}});
$slides.find('img').each(function (){
if(this._dcmRetryBound) return;
this._dcmRetryBound=true;
this.addEventListener('error', function (){
var img=this;
if(img._dcmRetrying) return;
img._dcmRetrying=true;
setTimeout(function (){
var s=img.src;
if(s){
img.src='';
img.src=s;
}
setTimeout(function (){ img._dcmRetrying=false; }, 5000);
}, 100);
});
});
}}
if($('body').hasClass('intro-pending')){
var aocPending=$('.aoc-wrap').length > 0&&empty(Cookies.get('oac'));
var videoPending=$('.home-video-wrap').length > 0;
function maybeRevealToggle(){
if(!aocPending&&!videoPending){
$('body').removeClass('intro-pending');
}}
$('.aoc-wrap').on('click', function (){
aocPending=false;
maybeRevealToggle();
});
setTimeout(function (){ aocPending=false; maybeRevealToggle(); }, 4000);
$(document).on('intro-video-ended', function (){
videoPending=false;
maybeRevealToggle();
});
maybeRevealToggle();
}
var THEME_KEY='dcmTheme';
var THEME_CYCLE=[
{ cls: 'theme-0',   pct: 0   },
{ cls: 'theme-5',   pct: 5   },
{ cls: 'theme-10',  pct: 10  },
{ cls: 'theme-15',  pct: 15  },
{ cls: 'theme-20',  pct: 20  },
{ cls: 'theme-25',  pct: 25  },
{ cls: 'theme-75',  pct: 75  },
{ cls: 'theme-80',  pct: 80  },
{ cls: 'theme-85',  pct: 85  },
{ cls: 'theme-90',  pct: 90  },
{ cls: 'theme-95',  pct: 95  },
{ cls: 'theme-100', pct: 100 }
];
var ALL_THEME_CLASSES=THEME_CYCLE.map(function (t){ return t.cls; }).filter(Boolean).join(' ');
function findStage(cls){
for (var i=0; i < THEME_CYCLE.length; i++){
if(THEME_CYCLE[i].cls===cls) return i;
}
return -1;
}
var THEME_RGB={
'theme-0':   '0,0,0',
'theme-5':   '13,13,13',
'theme-10':  '26,26,26',
'theme-15':  '38,38,38',
'theme-20':  '51,51,51',
'theme-25':  '64,64,64',
'theme-75':  '191,191,191',
'theme-80':  '204,204,204',
'theme-85':  '217,217,217',
'theme-90':  '230,230,230',
'theme-95':  '242,242,242',
'theme-100': '255,255,255'
};
function applyTheme(cls){
$('html, body').removeClass(ALL_THEME_CLASSES);
if(cls) $('html, body').addClass(cls);
var root=document.documentElement;
if(cls&&THEME_RGB[cls]){
root.style.setProperty('--theme-bg-rgb', THEME_RGB[cls]);
root.style.backgroundColor='rgb(' + THEME_RGB[cls] + ')';
}else{
root.style.removeProperty('--theme-bg-rgb');
root.style.backgroundColor='';
}
var stage=findStage(cls||'');
if(stage >=0){
$('.theme-toggle-percent').text(String(THEME_CYCLE[stage].pct));
}}
try {
var _storedTheme=localStorage.getItem(THEME_KEY);
if(_storedTheme&&THEME_RGB[_storedTheme]){
applyTheme(_storedTheme);
}else{
var _htmlCls='';
var _classes=(document.documentElement.className||'').split(/\s+/);
for (var _i=0; _i < _classes.length; _i++){
if(/^theme-\d+$/.test(_classes[_i])){ _htmlCls=_classes[_i]; break; }}
applyTheme(_htmlCls);
}} catch (e){  }
function persistTheme(cls){
try { localStorage.setItem(THEME_KEY, cls); } catch (e){}
var maxAge=60 * 60 * 24 * 365;
if(cls){
document.cookie='dcmTheme=' + encodeURIComponent(cls) + '; max-age=' + maxAge + '; path=/; SameSite=Lax';
}else{
document.cookie='dcmTheme=; max-age=0; path=/; SameSite=Lax';
}}
$('button.theme-toggle').on('click', function (){
if($('body').hasClass('enforce-theme')) return;
var current='';
for (var i=0; i < THEME_CYCLE.length; i++){
if(THEME_CYCLE[i].cls&&$('body').hasClass(THEME_CYCLE[i].cls)){
current=THEME_CYCLE[i].cls;
break;
}}
var nextIdx=(findStage(current) + 1) % THEME_CYCLE.length;
var next=THEME_CYCLE[nextIdx].cls;
applyTheme(next);
persistTheme(next);
});
var $hamburgerBtn=$('button.hamburger');
var $navWrap=$('#navigationWrap');
var menuCloseTimer=null;
var menuOpenedAt=0;
var CLICK_GUARD_MS=1000;
function openMenu(){
if(menuCloseTimer){ clearTimeout(menuCloseTimer); menuCloseTimer=null; }
if(!$navWrap.hasClass('is-active')){
menuOpenedAt=Date.now();
}
$hamburgerBtn.addClass('is-active');
$navWrap.addClass('is-active');
$('.menu-search input[name="s"]').val('');
}
function closeMenu(){
$hamburgerBtn.removeClass('is-active');
$navWrap.removeClass('is-active');
}
function scheduleCloseMenu(){
if(menuCloseTimer) clearTimeout(menuCloseTimer);
menuCloseTimer=setTimeout(function (){
if($navWrap[0]&&$navWrap[0].contains(document.activeElement)) return;
closeMenu();
}, 120);
}
function cancelCloseMenu(){
if(menuCloseTimer){ clearTimeout(menuCloseTimer); menuCloseTimer=null; }}
$hamburgerBtn.on('click', function (){
if($navWrap.hasClass('is-active')){
if(Date.now() - menuOpenedAt < CLICK_GUARD_MS) return;
closeMenu();
}else{
openMenu();
}});
if(window.matchMedia&&window.matchMedia('(any-hover: hover)').matches){
$hamburgerBtn.on('mouseenter', openMenu);
$hamburgerBtn.on('mouseleave', scheduleCloseMenu);
$navWrap.on('mouseenter', cancelCloseMenu);
$navWrap.on('mouseleave', scheduleCloseMenu);
$navWrap.on('focusout', function (){
setTimeout(function (){
if($navWrap[0]&&!$navWrap[0].contains(document.activeElement)){
scheduleCloseMenu();
}}, 0);
});
}
if($('body').hasClass('single-experience')||$('body').hasClass('tax-experience-category')){
var $ancestorItem=$('.menu-item-has-children.current-menu-ancestor').first();
if(!$ancestorItem.length){
$ancestorItem=$('.menu-item-has-children.current-menu-parent').first();
}
if(!$ancestorItem.length){
$ancestorItem=$('.menu-item-has-children').has('.current-menu-item').first();
}
if(!$ancestorItem.length){
$ancestorItem=$('.menu-item-has-children').filter(function (){
return $(this).find('.sub-menu a[href*="/experience/"]').length > 0;
}).first();
}
if($ancestorItem.length){
$ancestorItem.addClass('children-open');
$ancestorItem.find('.sub-menu:first').show();
}}
$('.menu-item-has-children').on('click', function (e){
if(!$(e.target).parent().hasClass('sub-menu')){
if($(this).data('hoverOpenedAt')){
if(Date.now() - $(this).data('hoverOpenedAt') < 500){
return;
}}
if($(this).hasClass('children-open')){
$(this).removeClass('children-open')
$(this).find('.sub-menu:first').slideUp(125)
}else{
$(this).addClass('children-open')
$(this).find('.sub-menu:first').slideDown(125)
}}
})
if(window.matchMedia&&window.matchMedia('(any-hover: hover)').matches){
$('.menu-item-has-children').each(function (){
var $item=$(this);
var hoverTimer=null;
$item.on('mouseenter', function (){
if($item.hasClass('children-open')) return;
hoverTimer=setTimeout(function (){
$item.addClass('children-open');
$item.find('.sub-menu:first').slideDown(125);
$item.data('hoverOpenedAt', Date.now());
}, 500);
});
$item.on('mouseleave', function (){
if(hoverTimer){
clearTimeout(hoverTimer);
hoverTimer=null;
}});
});
}
if($('.aoc-wrap').length&&empty(Cookies.get('oac'))){
function dismissAoc(){
$('.aoc-wrap').fadeOut(300, function (){
$(document).trigger('aoc-cleared');
});
}
Cookies.set('oac', 'yes');
setTimeout(dismissAoc, 3000);
$('.aoc-wrap').on('click', dismissAoc);
}
$(document).on('click', '.card--person, .people__profile', function (e){
var $el=$(this).closest('.people__item');
var is_active=$el.hasClass('active');
$('.people__item').removeClass('active');
$('.people__header').removeClass('active');
if(!is_active){
$el.addClass('active');
}
$('.people').toggleClass('is-open', !is_active);
});
if($('.people').length){
toogleEdge();
$(window).on('resize', toogleEdge);
function toogleEdge(){
$('.people__profile').each(function (){
var $parent=$(this).parent();
var $next=$parent.nextAll('.people__item').first();
var isEdge=false;
var pRect=$parent[0].getBoundingClientRect();
if($next.length){
var nRect=$next[0].getBoundingClientRect();
isEdge=(nRect.top - pRect.top) > 1;
}else{
var $items=$(this).closest('.people__items');
if($items.length){
var iRect=$items[0].getBoundingClientRect();
isEdge=pRect.right >=iRect.right - 5;
}}
$parent.toggleClass('is-edge', isEdge);
});
}}
if($('#tabs-nav').length){
$('#tabs-nav li:first-child').addClass('active');
$('.tab-content').hide();
$('.tab-content:first').show();
$('#tabs-nav li').click(function (){
$('#tabs-nav li').removeClass('active');
$(this).addClass('active');
$('.tab-content').hide();
var activeTab=$(this).find('a').attr('href');
$(activeTab).fadeIn();
return false;
});
}
if($('.fade-media-element').length){
if($('.fade-media-element').attr('data-type')=='video'){
const fadeMediaVideo=async ()=> {
const fadeToGrid=$('.home-video-wrap').attr('data-fade-to-grid')==='1';
const randomise=$('.home-video-wrap').attr('data-randomise')==='1';
const playOne=$('.home-video-wrap').attr('data-play-one')==='1';
const playlist=JSON.parse($('.home-video-wrap').attr('data-videos')||'[]');
if(playlist.length===0) return;
if(randomise){
for (let i=playlist.length - 1; i > 0; i--){
const j=Math.floor(Math.random() * (i + 1));
[playlist[i], playlist[j]]=[playlist[j], playlist[i]];
}}
if(playOne&&playlist.length > 1){
playlist.length=1;
}
const $overlay=$('<div style="position:absolute;top:0;left:0;width:100%;height:100%;background:#000;opacity:0;pointer-events:none;z-index:1;transition:opacity 1s ease;"></div>');
$('.home-video-wrap').prepend($overlay);
let video=document.createElement('video');
video.preload='auto';
video.muted=true;
video.autoplay=true;
video.loop=false;
video.setAttribute('playsinline', true);
video.setAttribute('webkit-playsinline', true);
video.setAttribute('data-keepplaying', '');
video.style.opacity=0;
let source=document.createElement('source');
source.src=await loadVideoSrc(playlist[0].url);
source.type=playlist[0].type;
$(video).prepend(source);
$('.fade-media-element').prepend(video);
$(video).addClass('loaded');
let currentIndex=0;
let fadeStarted=false;
let transitionInProgress=false;
function triggerFadeToGrid(isClick){
if(fadeStarted) return;
fadeStarted=true;
var fadeOut=1;
var fadeIn=0.5;
$(document).trigger('intro-fade-started');
$('.home-video-wrap').css({'transition': 'opacity ' + fadeOut + 's ease', 'pointer-events': 'none'}).removeClass('loaded');
setTimeout(function (){
$('.page-template-tpl-home .fullscreen:not(.home-video-wrap)').css('transition', 'opacity ' + fadeIn + 's ease');
$('.page-template-tpl-home .fullscreen:not(.home-video-wrap) video.video-loop-fade').trigger('video-restart');
$('.page-template-tpl-home .fullscreen:not(.home-video-wrap)').addClass('loaded');
$(document).trigger('intro-video-ended');
}, fadeOut * 1000);
}
function transitionToNext(){
if(transitionInProgress||fadeStarted) return;
transitionInProgress=true;
$overlay.css('opacity', '1');
setTimeout(function (){
video.pause();
currentIndex++;
if(currentIndex < playlist.length){
$(video).find('source')
.attr('src', playlist[currentIndex].url)
.attr('type', playlist[currentIndex].type);
video.load();
video.play().catch(function (){});
$overlay.css('opacity', '0');
transitionInProgress=false;
}else{
if(fadeToGrid){
triggerFadeToGrid();
}else{
currentIndex=0;
$(video).find('source')
.attr('src', playlist[0].url)
.attr('type', playlist[0].type);
video.load();
video.play().catch(function (){});
$overlay.css('opacity', '0');
transitionInProgress=false;
}}
}, 1100);
}
video.addEventListener('timeupdate', function (){
if(transitionInProgress||fadeStarted||!video.duration) return;
const isLastVideo=(currentIndex===playlist.length - 1);
if(isLastVideo&&fadeToGrid&&video.currentTime >=video.duration - 1){
triggerFadeToGrid();
}else if((!isLastVideo||!fadeToGrid)&&video.currentTime >=video.duration - 1.2){
transitionToNext();
}});
video.addEventListener('ended', function (){
if(transitionInProgress||fadeStarted) return;
const isLastVideo=(currentIndex===playlist.length - 1);
if(isLastVideo&&fadeToGrid){
triggerFadeToGrid();
}else{
transitionToNext();
}});
if(fadeToGrid){
$('.home-video-wrap').on('click', function (){
triggerFadeToGrid(true);
});
}}
fadeMediaVideo()
}else if($('.fade-media-element').attr('data-type')=='image'){
const fadeMediaImage=async ()=> {
let image=document.createElement('img');
image.style.opacity=0;
image.src=await loadImageSrc($('.fade-media-element').attr('data-src'));
image.srcset=$('.fade-media-element').attr('data-srcset');
image.classList.add("fullscreen");
$('.fade-media-element').prepend(image);
$(image).addClass('loaded')
}
fadeMediaImage()
}
$(document).on('click', '.home-video-skip', function (e){
e.preventDefault();
e.stopPropagation();
$('.home-video-wrap').trigger('click');
});
}
const _isProjectPage=$('body').hasClass('single-experience');
const _hasIntroVideo=$('.home-video-wrap[data-fade-to-grid="1"]').length > 0;
const _useVideoObserver = !_hasIntroVideo;
const _initedVideos=new WeakSet();
function initVideoLoopFade(video){
if(_initedVideos.has(video)) return;
_initedVideos.add(video);
if(video.dataset.src){
video.setAttribute('src', video.dataset.src);
video.load();
}}
var videoLoopFadeObserver=_useVideoObserver ? new IntersectionObserver(function (entries){
entries.forEach(function (entry){
var vid=entry.target;
if(entry.isIntersecting){
initVideoLoopFade(vid);
if(_isProjectPage){
vid.currentTime=0;
}
vid.play().catch(function (){});
}else{
vid.pause();
}});
}, {
rootMargin: _isProjectPage ? '0px':'0px 0px 300px 0px',
threshold:  _isProjectPage ? 0.5:0
}):null;
$('video.video-loop-fade').each(function (){
if($(this).closest('.projectSwiper').length) return;
if(_useVideoObserver&&videoLoopFadeObserver){
videoLoopFadeObserver.observe(this);
}else{
initVideoLoopFade(this);
}});
function _waitForImages($scope){
return new Promise(function (resolve){
var imgs=$scope.find('img');
if(!imgs.length) return resolve();
var pending=0;
var done=false;
function finish(){ if(done) return; done=true; resolve(); }
function markOne(){ if(--pending <=0) finish(); }
imgs.each(function (){
if(this.complete) return;
pending++;
this.addEventListener('load',  markOne, { once: true });
this.addEventListener('error', markOne, { once: true });
});
if(pending===0) return finish();
setTimeout(finish, 4000);
});
}
function attachItemFadeIn($items){
$items.each(function (){
var $item=$(this);
if($item.hasClass('loaded')) return;
_waitForImages($item).then(function (){ $item.addClass('loaded'); });
});
}
function attachRowFadeIn($items){
if(!$items.length) return;
var rows=[];
var current=null;
$items.each(function (){
var top=Math.round(this.getBoundingClientRect().top);
if(current&&Math.abs(top - current.top) < 5){
current.items.push(this);
}else{
current={ top: top, items: [this] };
rows.push(current);
}});
var chain=Promise.resolve();
rows.forEach(function (row){
var $row=$(row.items);
chain=chain
.then(function (){ return _waitForImages($row); })
.then(function (){ $row.addClass('loaded'); });
});
}
if($('body').hasClass('tax-experience-category')){
attachItemFadeIn($('.project-item'));
}
if($('body').hasClass('search')){
attachItemFadeIn($('.search-item'));
}
let imageOptions={
root: null,
rootMargin: '0px 5000px 400px 5000px',
threshold: 0
}
var lazyImageObserver=observeIntersection('img.lazy-wonton', imageOptions, async imageElement=> {
if(!empty(imageElement.dataset.srcset)) imageElement.srcset=imageElement.dataset.srcset;
imageElement.src=imageElement.dataset.src;
const src=await loadImageSrc(imageElement.dataset.src);
$(imageElement).addClass('loaded');
});
function observeNthFromEnd(observer, $items, n){
observer.disconnect();
if(!$items.length) return;
var idx=Math.max(0, $items.length - n);
observer.observe($items.get(idx));
}
var $sentinel=$('#experience-scroll-sentinel');
if($sentinel.length){
var scrollLoading=false;
var scrollObserver=new IntersectionObserver(function(entries){
if(!entries[0].isIntersecting||scrollLoading) return;
var currentPage=parseInt($sentinel.data('page'));
var maxPages=parseInt($sentinel.data('max-pages'));
if(currentPage >=maxPages){
scrollObserver.disconnect();
$sentinel.remove();
return;
}
scrollLoading=true;
$sentinel.addClass('is-loading');
$.ajax({
url:  dcm_ajax.url,
type: 'POST',
data: {
action:   'dcm_load_experience',
page:     currentPage + 1,
category: $sentinel.data('category'),
nonce:    $sentinel.data('nonce')
},
success: function(response){
if(response.success){
var $newItems=$(response.data.html);
$sentinel.before($newItems);
$sentinel.data('page', currentPage + 1);
attachItemFadeIn($newItems.filter('.project-item'));
if(videoLoopFadeObserver){
$newItems.find('video.video-loop-fade').each(function (){
videoLoopFadeObserver.observe(this);
});
}
if(currentPage + 1 >=maxPages){
scrollObserver.disconnect();
$sentinel.remove();
}else{
observeNthFromEnd(scrollObserver, $('.project-item'), 3);
}}
scrollLoading=false;
$sentinel.removeClass('is-loading');
},
error: function(){
scrollLoading=false;
$sentinel.removeClass('is-loading');
}});
}, { threshold: 0 });
observeNthFromEnd(scrollObserver, $('.project-item'), 3);
}
var $newsSentinel=$('#news-scroll-sentinel');
if($newsSentinel.length){
var newsLoading=false;
var newsObserver=new IntersectionObserver(function(entries){
if(!entries[0].isIntersecting||newsLoading) return;
var currentPage=parseInt($newsSentinel.data('page'));
var maxPages=parseInt($newsSentinel.data('max-pages'));
if(currentPage >=maxPages){
newsObserver.disconnect();
$newsSentinel.remove();
return;
}
newsLoading=true;
$newsSentinel.addClass('is-loading');
$.ajax({
url:  dcm_ajax.url,
type: 'POST',
data: {
action: 'dcm_load_news',
page:   currentPage + 1,
nonce:  $newsSentinel.data('nonce')
},
success: function(response){
if(response.success){
var $newItems=$(response.data.html);
$newsSentinel.before($newItems);
$newsSentinel.data('page', currentPage + 1);
$newItems.find('img.lazy-wonton').each(function(){
lazyImageObserver.observe(this);
});
if(videoLoopFadeObserver){
$newItems.find('video.video-loop-fade').each(function (){
videoLoopFadeObserver.observe(this);
});
}
if(typeof window.initArticleSwiperOn==='function'){
$newItems.find('.articleSwiper').each(function (){
window.initArticleSwiperOn(this);
});
}
if(currentPage + 1 >=maxPages){
newsObserver.disconnect();
$newsSentinel.remove();
}else{
observeNthFromEnd(newsObserver, $('.article-wrap'), 2);
}}
newsLoading=false;
$newsSentinel.removeClass('is-loading');
},
error: function(){
newsLoading=false;
$newsSentinel.removeClass('is-loading');
}});
}, { threshold: 0 });
observeNthFromEnd(newsObserver, $('.article-wrap'), 2);
}
if($('body').hasClass('search')){
var $searchPageInput=$('.search-form')
.not('.menu-search .search-form')
.find('input[name="s"]')
.first();
if($searchPageInput.length&&!$searchPageInput.val()){
$searchPageInput.focus();
}}
var $searchSentinel=$('#search-scroll-sentinel');
if($searchSentinel.length){
var searchLoading=false;
var searchObserver=new IntersectionObserver(function (entries){
if(!entries[0].isIntersecting||searchLoading) return;
var currentPage=parseInt($searchSentinel.data('page'));
var maxPages=parseInt($searchSentinel.data('max-pages'));
if(currentPage >=maxPages){
searchObserver.disconnect();
$searchSentinel.remove();
return;
}
searchLoading=true;
$searchSentinel.addClass('is-loading');
$.ajax({
url:  dcm_ajax.url,
type: 'POST',
data: {
action:     'dcm_load_search_more',
s:          $searchSentinel.data('search'),
page:       currentPage + 1,
blank_seed: $searchSentinel.data('blank-seed')||0,
nonce:      $searchSentinel.data('nonce')
},
success: function (response){
if(response.success){
var $newItems=$(response.data.html);
$searchSentinel.before($newItems);
$searchSentinel.data('page', currentPage + 1);
attachItemFadeIn($newItems.filter('.search-item'));
if(videoLoopFadeObserver){
$newItems.find('video.video-loop-fade').each(function (){
videoLoopFadeObserver.observe(this);
});
}
if(currentPage + 1 >=maxPages){
searchObserver.disconnect();
$searchSentinel.remove();
}else{
observeNthFromEnd(searchObserver, $('.search-item'), 3);
}}
searchLoading=false;
$searchSentinel.removeClass('is-loading');
},
error: function (){
searchLoading=false;
$searchSentinel.removeClass('is-loading');
}});
}, { threshold: 0 });
observeNthFromEnd(searchObserver, $('.search-item'), 3);
}
if($('body').hasClass('page-template-tpl-people')){
try {
var navType='';
if(window.performance&&typeof performance.getEntriesByType==='function'){
var navEntries=performance.getEntriesByType('navigation');
if(navEntries&&navEntries.length){
navType=navEntries[0].type;
}}else if(window.performance&&performance.navigation){
navType=performance.navigation.type===1 ? 'reload':'navigate';
}
if(navType==='reload'){
var savedFilter=localStorage.getItem('dcmPeopleFilter')||'';
if(savedFilter){
var $savedBtn=$('.people-filter__option[data-filter="' + savedFilter + '"]');
var $savedSet=$('.people__set--' + savedFilter);
if($savedBtn.length&&$savedSet.length){
$('.people-filter__option').removeClass('is-active');
$savedBtn.addClass('is-active');
$('.people__set').removeClass('is-active');
$savedSet.addClass('is-active');
}}
}else{
localStorage.removeItem('dcmPeopleFilter');
}} catch (e){  }
attachRowFadeIn($('.people__set.is-active .people__item'));
$(document).on('click', '.people-filter__option', function (e){
e.preventDefault();
e.stopPropagation();
var $btn=$(this);
if($btn.hasClass('is-active')){
window.location.reload();
return;
}
var newFilter=$btn.attr('data-filter')||'';
var setSlug=newFilter||'all';
var $targetSet=$('.people__set--' + setSlug);
if(!$targetSet.length) return;
try { localStorage.setItem('dcmPeopleFilter', newFilter); } catch (e){}
$('.people-filter__option').removeClass('is-active');
$btn.addClass('is-active');
$targetSet.find('.people__item').removeClass('loaded');
$('.people__set').removeClass('is-active');
$targetSet.addClass('is-active');
requestAnimationFrame(function (){
requestAnimationFrame(function (){
attachRowFadeIn($targetSet.find('.people__item'));
});
});
if(typeof $(window).trigger==='function'){
$(window).trigger('resize');
}});
}
var $peopleSentinel=$('#people-scroll-sentinel');
if($peopleSentinel.length){
var peopleLoading=false;
function peopleColsForViewport(){
var w=window.innerWidth;
if(w >=1600) return 8;
if(w >=992)  return 6;
if(w >=576)  return 4;
return 2;
}
function peopleBatchSize(cols){
if(cols >=8) return 28;
if(cols >=6) return 21;
if(cols >=4) return 14;
return 10;
}
function peopleTriggerN(){
return Math.round(peopleBatchSize(peopleColsForViewport()) * 0.6);
}
function fetchPeopleBatch(){
if(peopleLoading) return;
var currentOffset=parseInt($peopleSentinel.data('offset'));
var totalPeople=parseInt($peopleSentinel.data('total'));
if(currentOffset >=totalPeople){
peopleObserver.disconnect();
$peopleSentinel.remove();
return;
}
peopleLoading=true;
$peopleSentinel.addClass('is-loading');
$.ajax({
url:  dcm_ajax.url,
type: 'POST',
data: {
action:      'dcm_load_people',
offset:      currentOffset,
cols:        peopleColsForViewport(),
people_seed: $peopleSentinel.data('people-seed'),
pos_seed:    $peopleSentinel.data('pos-seed'),
loop_index:  $peopleSentinel.data('loop-index'),
cycle_index: $peopleSentinel.data('cycle-index')||0,
filter:      'all',
nonce:       $peopleSentinel.data('nonce')
},
success: function (response){
if(response.success){
var $newItems=$(response.data.html);
$peopleSentinel.before($newItems);
$peopleSentinel.data('offset', response.data.offset);
$peopleSentinel.data('loop-index', response.data.loop_index);
if(typeof response.data.cycle_index!=='undefined'){
$peopleSentinel.data('cycle-index', response.data.cycle_index);
}
attachRowFadeIn($newItems.filter('.people__item'));
if(typeof $(window).trigger==='function'){
$(window).trigger('resize');
}
if(response.data.offset >=parseInt($peopleSentinel.data('total'))){
peopleObserver.disconnect();
$peopleSentinel.remove();
}else{
observeNthFromEnd(
peopleObserver,
$('.people__set--all .people__item'),
peopleTriggerN()
);
}}
peopleLoading=false;
$peopleSentinel.removeClass('is-loading');
},
error: function (){
peopleLoading=false;
$peopleSentinel.removeClass('is-loading');
}});
}
var peopleObserver=new IntersectionObserver(function (entries){
if(!entries[0].isIntersecting) return;
if(!$('.people__set--all').hasClass('is-active')) return;
fetchPeopleBatch();
}, { threshold: 0 });
observeNthFromEnd(
peopleObserver,
$('.people__set--all .people__item'),
peopleTriggerN()
);
}
/*$('.dragscroll').kinetic({
filterTarget: function (target, e){
if(!/down|start/.test(e.type)){
return !(/area|a|input/i.test(target.tagName));
}}
});
if($('.swiper').length > 0){
const breakpoint=window.matchMedia('(max-width:768px)');
let mySwiper;
const breakpointChecker=function (){
if(breakpoint.matches===true){
if(mySwiper!==undefined) mySwiper.destroy(true, true);
$('.dragscroll').kinetic('detach');
return;
}else if(breakpoint.matches===false){
return enableSwiper();
}};
const enableSwiper=function (){
mySwiper=new Swiper(".swiper", {
slidesPerView: "auto",
spaceBetween: 40,
freeMode: true,
loop: true,
grabCursor: true,
});
$('.dragscroll').kinetic('attach');
};
breakpoint.addListener(breakpointChecker);
breakpointChecker();
}
*/
if($('.projectSlick').length){
const settings={
dots: true,
infinite: false,
speed: 1000,
slidesToShow: 1,
centerMode: false,
variableWidth: true,
useTransform: false,
touchThreshold: 50,
responsive: [
{
breakpoint: 991,
settings: "unslick"
}
]
};
let sl=$('.projectSlick').slick(settings);
let $controls=$('.controls');
$controls.append(sl.find('.slick-prev'));
$controls.append(sl.find('.slick-dots'));
$controls.append(sl.find('.slick-next'));
$(window).on('resize', function (){
if($(window).width() > 991&&!sl.hasClass('slick-initialized')){
sl=$('.projectSlick').slick(settings);
$controls=$('.controls');
$controls.append(sl.find('.slick-prev'));
$controls.append(sl.find('.slick-dots'));
$controls.append(sl.find('.slick-next'));
}});
document.onkeydown=checkKey;
slidesCount=$('.slide-image-ratio').length;
function checkKey(e){
e=e||window.event;
if(e.keyCode=='37'){
if(sl.slick('slickCurrentSlide') > 0) sl.slick('slickPrev');
}
else if(e.keyCode=='39'){
if(sl.slick('slickCurrentSlide') < slidesCount - 1) sl.slick('slickNext');
}}
}
if($('.projectSwiper').length){
$('.projectSwiper img.lazy-wonton').each(function (){
var img=this;
if(img.dataset.srcset&&!img.srcset) img.srcset=img.dataset.srcset;
if(!img.src&&img.dataset.src) img.src=img.dataset.src;
if(img.complete&&img.naturalWidth > 0){
img.classList.add('loaded');
}else{
var markLoaded=function (){ img.classList.add('loaded'); };
img.addEventListener('load',  markLoaded, { once: true });
img.addEventListener('error', markLoaded, { once: true });
}});
if($('.projectSwiper').is(':visible')){
$('.projectSwiper video.video-loop-fade').each(function (){
if(this.dataset.src){
this.src=this.dataset.src;
this.preload='auto';
delete this.dataset.src;
this.load();
}});
}
var _projectSlideCount=$('.projectSwiper .swiper-slide').length;
var _projectUseLoop=_projectSlideCount > 1;
function dcmActivateActiveSlideVideo(swiper){
if(!swiper||!swiper.slides||!swiper.slides.length) return;
var slide=swiper.slides[swiper.activeIndex];
if(!slide) return;
var v=slide.querySelector('video.video-loop-fade');
if(!v) return;
initVideoLoopFade(v);
v.play().catch(function (){});
}
function dcmPauseAllSwiperVideosKeepTime(){
$('.projectSwiper video.video-loop-fade').each(function (){
if(!this.paused) this.pause();
});
}
function dcmResetAllSwiperVideos(){
$('.projectSwiper video.video-loop-fade').each(function (){
this.pause();
this.currentTime=0;
});
}
let projectSwiper=new Swiper(".projectSwiper", {
slidesPerView: "auto",
spaceBetween: 0,
slideToClickedSlide: true,
watchOverflow: false,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
pagination: {
el: ".swiper-pagination",
clickable: true,
renderBullet: function (index, className){
return '<span class="' + className + '">' + (index + 1) + "</span>";
},
},
keyboard: {
enabled: true,
},
loop: _projectUseLoop,
loopedSlides: _projectUseLoop ? 1:0,
allowSlideNext: false,
allowSlidePrev: false,
on: {
afterInit: function (){
var swiper=this;
var hash=window.location.hash;
var slideMatch=hash.match(/^#slide-(\d+)$/);
var startIdx=slideMatch ? parseInt(slideMatch[1]):0;
if(startIdx > 0){
swiper.slideToLoop(startIdx, 0);
}else{
$(swiper.$el).find('.swiper-button-prev').addClass('swiper-button-disabled');
swiper.allowSlidePrev=false;
swiper.allowSlideNext=true;
}
var realCount=$(swiper.$el).find('.swiper-slide:not(.swiper-slide-duplicate)').length;
if(realCount <=1){
$(swiper.$el).find('.swiper-button-next').addClass('swiper-button-disabled');
swiper.allowSlideNext=false;
setTimeout(function (){
var $pag=$(swiper.$el).find('.swiper-pagination');
$pag.removeClass('swiper-pagination-lock');
if(!$pag.find('.swiper-pagination-bullet').length){
$pag.html('<span class="swiper-pagination-bullet swiper-pagination-bullet-active">1</span>');
}}, 0);
}
dcmActivateActiveSlideVideo(swiper);
},
slideChange: function (){
$(this.$el).find('.swiper-button-disabled').removeClass('swiper-button-disabled');
if(this.realIndex > 0&&this.realIndex + 3 < this.slides.length){
this.allowSlidePrev=true
this.allowSlideNext=true
}
if(this.realIndex + 3==this.slides.length){
this.allowSlidePrev=true
this.allowSlideNext=true
}
if(this.realIndex==0){
$(this.$el).find('.swiper-button-prev').addClass('swiper-button-disabled');
this.allowSlidePrev=false
this.allowSlideNext=true
}
dcmPauseAllSwiperVideosKeepTime();
dcmActivateActiveSlideVideo(this);
},
reachEnd: function (){
this.snapGrid=[...this.slidesGrid];
},
snapGridLengthChange: function (){
if(this.snapGrid.length!=this.slidesGrid.length){
this.snapGrid=[...this.slidesGrid];
}}
}});
(function (){
var el=$('.projectSwiper')[0];
if(!el) return;
var containerObs=new IntersectionObserver(function (entries){
entries.forEach(function (entry){
if(entry.isIntersecting){
dcmActivateActiveSlideVideo(projectSwiper);
}else{
dcmResetAllSwiperVideos();
}});
}, { threshold: 0.1 });
containerObs.observe(el);
var slideObs=new IntersectionObserver(function (entries){
entries.forEach(function (entry){
if(entry.isIntersecting) return;
var v=entry.target;
v.pause();
v.currentTime=0;
});
}, { root: el, threshold: 0 });
$('.projectSwiper video.video-loop-fade').each(function (){
slideObs.observe(this);
});
})();
$('.projectSwiper .swiper-button-next').each(function (){
this.addEventListener('click', function (e){
if(!projectSwiper) return;
var lastRealIndex=projectSwiper.slides.length - 3;
if(projectSwiper.realIndex >=lastRealIndex){
e.stopImmediatePropagation();
e.preventDefault();
projectSwiper.slideToLoop(0);
}}, true);
});
function refreshProjectWideSlides(){
var $wrap=$('.projectSwiper');
if(!$wrap.length) return;
var slotW=$wrap[0].getBoundingClientRect().width;
if(slotW <=0) return;
$wrap.find('.swiper-slide').each(function (){
var slideW=this.getBoundingClientRect().width;
if(slideW > slotW + 5){
$(this).addClass('is-wide');
}else{
$(this).removeClass('is-wide');
}});
}
refreshProjectWideSlides();
$(window).on('load resize', refreshProjectWideSlides);
$('.projectSwiper').on('click', '.image-expand-toggle', function (e){
e.preventDefault();
e.stopPropagation();
var $gallery=$(this).closest('.gallery-wrap');
$gallery.toggleClass('is-expanded');
setTimeout(function (){
if(projectSwiper&&projectSwiper.update) projectSwiper.update();
refreshProjectWideSlides();
}, 320);
});
}
window.initArticleSwiperOn=function (el){
var $c=$(el);
$c.find('img.lazy-wonton').each(function (){
var img=this;
if(img.dataset.srcset&&!img.srcset) img.srcset=img.dataset.srcset;
if(!img.src&&img.dataset.src) img.src=img.dataset.src;
if(img.complete&&img.naturalWidth > 0){
img.classList.add('loaded');
}else{
var markLoaded=function (){ img.classList.add('loaded'); };
img.addEventListener('load',  markLoaded, { once: true });
img.addEventListener('error', markLoaded, { once: true });
}});
var nextEl=$c.find('.swiper-button-next')[0]||null;
var prevEl=$c.find('.swiper-button-prev')[0]||null;
var pagEl=$c.find('.swiper-pagination')[0]||null;
var _articleSlideCount=$c.find('.swiper-slide').length;
var _articleUseLoop=_articleSlideCount > 1;
var swiper=new Swiper(el, {
slidesPerView: "auto",
spaceBetween: 0,
slideToClickedSlide: true,
watchOverflow: false,
navigation: {
nextEl: nextEl,
prevEl: prevEl,
},
pagination: {
el: pagEl,
clickable: true,
renderBullet: function (index, className){
return '<span class="' + className + '">' + (index + 1) + "</span>";
},
},
loop: _articleUseLoop,
loopedSlides: _articleUseLoop ? 1:0,
allowSlideNext: false,
allowSlidePrev: false,
on: {
afterInit: function (){
var swiper=this;
$(swiper.$el).find('.swiper-button-prev').addClass('swiper-button-disabled');
swiper.allowSlidePrev=false
swiper.allowSlideNext=true
var realSlideCount=$(swiper.$el).find('.swiper-slide:not(.swiper-slide-duplicate)').length;
if(realSlideCount <=1){
$(swiper.$el).find('.swiper-button-next').addClass('swiper-button-disabled');
swiper.allowSlideNext=false
setTimeout(function (){
var $pag=$(swiper.$el).find('.swiper-pagination');
$pag.removeClass('swiper-pagination-lock');
if(!$pag.find('.swiper-pagination-bullet').length){
$pag.html('<span class="swiper-pagination-bullet swiper-pagination-bullet-active">1</span>');
}}, 0);
}},
slideChange: function (){
$(this.$el).find('.swiper-button-disabled').removeClass('swiper-button-disabled');
if(this.realIndex > 0&&this.realIndex + 3 < this.slides.length){
this.allowSlidePrev=true
this.allowSlideNext=true
}
if(this.realIndex + 3==this.slides.length){
this.allowSlidePrev=true
this.allowSlideNext=true
}
if(this.realIndex==0){
$(this.$el).find('.swiper-button-prev').addClass('swiper-button-disabled');
this.allowSlidePrev=false
this.allowSlideNext=true
}},
reachEnd: function (){
this.snapGrid=[...this.slidesGrid];
},
snapGridLengthChange: function (){
if(this.snapGrid.length!=this.slidesGrid.length){
this.snapGrid=[...this.slidesGrid];
}}
}});
$c.find('img').each(function (){
if(!this.complete){
$(this).one('load', function (){
if(swiper&&swiper.update) swiper.update();
});
}});
if(nextEl){
nextEl.addEventListener('click', function (e){
if(!swiper) return;
var lastRealIndex=swiper.slides.length - 3;
if(swiper.realIndex >=lastRealIndex){
e.stopImmediatePropagation();
e.preventDefault();
swiper.slideToLoop(0);
}}, true);
}
return swiper;
};
if($('.articleSwiper').length){
$('.articleSwiper').each(function (){
window.initArticleSwiperOn(this);
});
}
/*
var resizeId;
$(window).resize(function(){
clearTimeout(resizeId);
resizeId=setTimeout(doneResizing, 500);
});
function doneResizing(){
}
*/
/*
$(document).mouseup(function(e){
if($('.menu-wrapper').is(":visible")){
var container=$(".menu-wrapper #nav");
if(!container.is(e.target)&&container.has(e.target).length===0){
$('.menu-wrapper').fadeToggle();
}}
});
*/
});
}(window.jQuery||window.$));
function loadImageSrc(src){
return new Promise(resolve=> {
const image=new Image();
image.src=src;
image.onload=function (){
resolve(src);
};});
}
function loadVideoSrc(src){
return new Promise(resolve=> {
const video=document.createElement('video');
video.onloadedmetadata=function (){
resolve(src);
};
video.src=src;
});
}
function observeIntersection(selector, options, callback){
const observer=new IntersectionObserver(components=> {
components.forEach(component=> {
if(component.isIntersecting&&typeof callback==='function'){
callback(component.target);
observer.unobserve(component.target);
}});
}, options);
observer.POLL_INTERVAL=100;
Array.from(document.querySelectorAll(selector)).forEach(observer.observe.bind(observer)
);
return observer;
}
function safari100vhHack(){
let vh=window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
window.addEventListener('resize', ()=> {
let vh=window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
});
}
function $_GET(param){
var vars={};
window.location.href.replace(location.hash, '').replace(/[?&]+([^=&]+)=?([^&]*)?/gi,
function (m, key, value){
vars[key]=value!==undefined ? value:'';
}
);
if(param){
return vars[param] ? vars[param]:null;
}
return vars;
}
function empty(val){
if(val===undefined)
return true;
if(typeof (val)=='function'||typeof (val)=='number'||typeof (val)=='boolean'||Object.prototype.toString.call(val)==='[object Date]')
return false;
if(val==null||val.length===0)
return true;
if(typeof (val)=="object"){
var r=true;
for (var f in val)
r=false;
return r;
}
return false;
}
function convertSvg(){
jQuery('img.svg').each(function (){
var $img=jQuery(this);
var imgID=$img.attr('id');
var imgClass=$img.attr('class');
var imgURL=$img.attr('src');
jQuery.get(imgURL, function (data){
var $svg=jQuery(data).find('svg');
if(typeof imgID!=='undefined'){
$svg=$svg.attr('id', imgID);
}
if(typeof imgClass!=='undefined'){
$svg=$svg.attr('class', imgClass + ' replaced-svg');
}
$svg=$svg.removeAttr('xmlns:a');
if(!$svg.attr('viewBox')&&$svg.attr('height')&&$svg.attr('width')){
$svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width'))
}
$img.replaceWith($svg);
}, 'xml');
});
};