!function(i){"use strict";"function"==typeof define&&define.amd?define(["jquery"],i):"undefined"!=typeof exports?module.exports=i(require("jquery")):i(jQuery)}(function(i){"use strict";var e=window.Slick||{};(e=function(){var e=0;return function(t,o){var s,n=this;n.defaults={accessibility:!0,adaptiveHeight:!1,appendArrows:i(t),appendDots:i(t),arrows:!0,asNavFor:null,prevArrow:'',nextArrow:'',autoplay:!1,autoplaySpeed:3e3,centerMode:!1,centerPadding:"50px",cssEase:"ease",customPaging:function(e,t){return i('', nextArrow: '', responsive: [ { breakpoint: 992, settings: { slidesToShow: 2, slidesToScroll: 1 } }, { breakpoint: 768, settings: { slidesToShow: 1, slidesToScroll: 1 } } ] }); safeInitSlick('.responsive', { dots: true, infinite: false, speed: 300, slidesToShow: 5, slidesToScroll: 3, adaptiveHeight: false, responsive: [ { breakpoint: 1024, settings: { slidesToShow: 3, slidesToScroll: 3, infinite: true, dots: true } }, { breakpoint: 600, settings: { slidesToShow: 2, slidesToScroll: 2 } }, { breakpoint: 480, settings: { slidesToShow: 1, slidesToScroll: 1 } } ] }); }); } (function () { 'use strict'; function initWexArticleRails() { var stage = document.querySelector('.wex-article-rail-stage'); var rails = document.querySelectorAll('.wex-side-rail'); var footer = document.querySelector('footer, #footer, .site-footer'); var desktop = window.matchMedia('(min-width: 1700px)'); if (!stage || !rails.length) { return; } var railHeight = 620; var topGap = 118; var footerGap = 20; var ticking = false; function resetRail(rail) { rail.classList.remove('wex-rail-fixed'); rail.style.removeProperty('--wex-rail-current-top'); } function updateRails() { if (!desktop.matches) { rails.forEach(resetRail); return; } var stageTop = stage.getBoundingClientRect().top; var footerTop = footer ? footer.getBoundingClientRect().top : Infinity; var currentTop = topGap; if (stageTop <= topGap && footerTop > 0) { currentTop = Math.min( topGap, Math.max(-railHeight, footerTop - railHeight - footerGap) ); rails.forEach(function (rail) { rail.classList.add('wex-rail-fixed'); rail.style.setProperty('--wex-rail-current-top', currentTop + 'px'); }); } else { rails.forEach(resetRail); } } function requestUpdate() { if (ticking) { return; } ticking = true; window.requestAnimationFrame(function () { updateRails(); ticking = false; }); } window.addEventListener('scroll', requestUpdate, { passive: true }); window.addEventListener('resize', requestUpdate); window.addEventListener('load', requestUpdate); if (desktop.addEventListener) { desktop.addEventListener('change', requestUpdate); } else { desktop.addListener(requestUpdate); } requestUpdate(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initWexArticleRails); } else { initWexArticleRails(); } })(); (function () { 'use strict'; function initWexShorts() { var track = document.getElementById('shortsTrack'); var prevBtn = document.getElementById('btnPrev'); var nextBtn = document.getElementById('btnNext'); var modalEl = document.getElementById('shortsModal'); var iframe = document.getElementById('shortsFrame'); var titleEl = document.getElementById('shortTitle'); var timeEl = document.getElementById('shortTime'); var closeBtn = document.getElementById('shortsCloseBtn'); var modalPrev = document.getElementById('shortsPrevModal'); var modalNext = document.getElementById('shortsNextModal'); if (!track || !modalEl || !iframe) { return; } if (track.dataset.wexShortsReady === '1') { return; } track.dataset.wexShortsReady = '1'; var cards = Array.prototype.slice.call(track.querySelectorAll('.shorts-card')); var currentIndex = 0; function getScrollAmount() { var card = track.querySelector('.shorts-card'); if (!card) { return 280; } return card.offsetWidth + 16; } function scrollTrack(direction) { track.scrollBy({ left: direction * getScrollAmount(), behavior: 'smooth' }); } if (prevBtn) { prevBtn.addEventListener('click', function (event) { event.preventDefault(); scrollTrack(-1); }); } if (nextBtn) { nextBtn.addEventListener('click', function (event) { event.preventDefault(); scrollTrack(1); }); } function loadShort(index) { if (!cards.length) { return; } currentIndex = (index + cards.length) % cards.length; var card = cards[currentIndex]; var videoId = card.getAttribute('data-youtube-id') || ''; var title = card.getAttribute('data-title') || ''; var duration = card.getAttribute('data-duration') || ''; if (!videoId) { return; } iframe.src = 'https://www.youtube.com/embed/' + encodeURIComponent(videoId) + '?autoplay=1&mute=0&rel=0&modestbranding=1&playsinline=1'; if (titleEl) { titleEl.textContent = title; } if (timeEl) { timeEl.textContent = duration; } } function openModal(index) { loadShort(index); modalEl.classList.add('is-open'); modalEl.setAttribute('aria-hidden', 'false'); document.body.classList.add('shorts-modal-open'); } function closeModal() { modalEl.classList.remove('is-open'); modalEl.setAttribute('aria-hidden', 'true'); document.body.classList.remove('shorts-modal-open'); iframe.src = ''; } cards.forEach(function (card, index) { card.addEventListener('click', function (event) { event.preventDefault(); openModal(index); }); }); if (closeBtn) { closeBtn.addEventListener('click', function (event) { event.preventDefault(); closeModal(); }); } if (modalPrev) { modalPrev.addEventListener('click', function (event) { event.preventDefault(); loadShort(currentIndex - 1); }); } if (modalNext) { modalNext.addEventListener('click', function (event) { event.preventDefault(); loadShort(currentIndex + 1); }); } modalEl.addEventListener('click', function (event) { if (event.target === modalEl) { closeModal(); } }); document.addEventListener('keydown', function (event) { if (!modalEl.classList.contains('is-open')) { return; } if (event.key === 'Escape') { closeModal(); } if (event.key === 'ArrowUp') { loadShort(currentIndex - 1); } if (event.key === 'ArrowDown') { loadShort(currentIndex + 1); } }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initWexShorts); } else { initWexShorts(); } })(); (function () { 'use strict'; function getSessionValue(key) { try { return window.sessionStorage.getItem(key); } catch (error) { return null; } } function setSessionValue(key, value) { try { window.sessionStorage.setItem(key, value); } catch (error) { } } function initSinglePostAds() { var mobileAd = document.getElementById('wexMobAdhesion'); var closeBtn = document.querySelector('.wex-mob-adhesion-close'); var revcontentWidget = document.getElementById('wexRevcontentWidget'); if (mobileAd && mobileAd.dataset.wexReady !== '1') { mobileAd.dataset.wexReady = '1'; if (getSessionValue('wexMobAdClosed') === '1') { mobileAd.hidden = true; } else if (closeBtn) { closeBtn.addEventListener('click', function () { mobileAd.hidden = true; setSessionValue('wexMobAdClosed', '1'); }); } } if (!revcontentWidget || revcontentWidget.dataset.wexReady === '1') { return; } revcontentWidget.dataset.wexReady = '1'; var revcontentLoaded = false; var observer = null; function loadRevcontent() { if ( revcontentLoaded || document.querySelector( 'script[src*="delivery.revcontent.com/64777/282534/widget.js"]' ) ) { return; } revcontentLoaded = true; var script = document.createElement('script'); script.src = 'https://delivery.revcontent.com/64777/282534/widget.js'; script.async = true; script.defer = true; document.body.appendChild(script); } if ('IntersectionObserver' in window) { observer = new IntersectionObserver(function (entries) { if (entries[0] && entries[0].isIntersecting) { loadRevcontent(); observer.disconnect(); } }, { rootMargin: '700px 0px' }); observer.observe(revcontentWidget); } else { window.addEventListener('load', loadRevcontent, { once: true }); } } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initSinglePostAds); } else { initSinglePostAds(); } })(); // Live blog time (function () { function updateLiveTimes() { var items = document.querySelectorAll( '#wex-strip .wex-card__ago[data-timestamp]' ); var now = Math.floor(Date.now() / 1000); items.forEach(function (item) { var timestamp = parseInt( item.getAttribute('data-timestamp'), 10 ); if (!Number.isFinite(timestamp) || timestamp <= 0) { return; } var seconds = Math.max(0, now - timestamp); var minutes = Math.floor(seconds / 60); var hours = Math.floor(seconds / 3600); var days = Math.floor(seconds / 86400); var label = ''; if (minutes < 1) { label = 'JUST NOW'; } else if (minutes < 60) { label = minutes + 'M AGO'; } else if (hours < 24) { label = hours + 'H AGO'; } else { label = days + 'D AGO'; } item.textContent = label; }); } updateLiveTimes(); if (!window.wexLiveTimeInterval) { window.wexLiveTimeInterval = setInterval( updateLiveTimes, 60000 ); } })(); ; (function () { 'use strict'; function debounce(fn, delay) { var timer = null; return function () { var args = arguments; var context = this; window.clearTimeout(timer); timer = window.setTimeout(function () { fn.apply(context, args); }, delay); }; } function initUniversalRails() { var wrapper = document.querySelector('[data-wex-universal-rails]'); if (!wrapper) { return; } var leftRail = wrapper.querySelector('.wex-universal-rail--left'); var rightRail = wrapper.querySelector('.wex-universal-rail--right'); var footer = document.querySelector('.wex-footer-pro, footer'); var content = document.querySelector('.wex-special-container, .wex-generic-container, .wex-category-center .container, .wex-page-article, main .container'); var railWidth = 160; var railHeight = 625; var gap = 20; var top = 144; var minViewport = 1640; if (!leftRail || !rightRail || !content) { return; } function hide() { leftRail.classList.remove('is-visible'); rightRail.classList.remove('is-visible'); } function update() { if (window.innerWidth < minViewport) { hide(); return; } var rect = content.getBoundingClientRect(); var leftSpace = rect.left; var rightSpace = window.innerWidth - rect.right; var needed = railWidth + gap; if (leftSpace < needed || rightSpace < needed) { hide(); return; } leftRail.style.left = Math.max(8, rect.left - railWidth - gap) + 'px'; rightRail.style.left = Math.min(window.innerWidth - railWidth - 8, rect.right + gap) + 'px'; rightRail.style.right = 'auto'; var footerTop = footer ? footer.getBoundingClientRect().top : Infinity; var shift = Math.min(0, footerTop - top - railHeight - 20); var transform = 'translateY(' + shift + 'px)'; leftRail.style.transform = transform; rightRail.style.transform = transform; leftRail.classList.add('is-visible'); rightRail.classList.add('is-visible'); } var requestUpdate = debounce(function () { window.requestAnimationFrame(update); }, 20); window.addEventListener('resize', requestUpdate, { passive: true }); window.addEventListener('scroll', requestUpdate, { passive: true }); window.addEventListener('load', update); update(); } function improveDesktopMenuKeyboard() { document.querySelectorAll('.wex-nav-link.has-dropdown > a, .wex-dropdown-item.has-children > a').forEach(function (link) { link.addEventListener('keydown', function (event) { if (event.key !== 'ArrowDown' && event.key !== 'ArrowRight') { return; } var parent = link.parentElement; var submenu = parent ? parent.querySelector(':scope > .wex-dropdown') : null; var first = submenu ? submenu.querySelector('a') : null; if (first) { event.preventDefault(); first.focus(); } }); }); } function initFallbackImageHandling() { document.querySelectorAll('img').forEach(function (image) { if (image.dataset.wexErrorReady === '1') { return; } image.dataset.wexErrorReady = '1'; image.addEventListener('error', function () { var fallback = window.wexThemeData && window.wexThemeData.placeholderImage ? window.wexThemeData.placeholderImage : ''; if (fallback && image.src !== fallback) { image.src = fallback; return; } image.style.display = 'none'; /* no placeholder: hide the broken image */ }); }); } function init() { initUniversalRails(); improveDesktopMenuKeyboard(); initFallbackImageHandling(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })(); ; (function () { 'use strict'; function initFaq() { document.querySelectorAll('[data-wex-faq-question]').forEach(function (button) { button.addEventListener('click', function () { var answerId = button.getAttribute('aria-controls'); var answer = answerId ? document.getElementById(answerId) : null; if (!answer) { return; } var open = button.getAttribute('aria-expanded') === 'true'; button.setAttribute('aria-expanded', open ? 'false' : 'true'); answer.classList.toggle('is-open', !open); }); }); } function initCrosswords() { document.querySelectorAll('[data-crossword-grid]').forEach(function (grid) { var inputs = Array.prototype.slice.call(grid.querySelectorAll('input')); inputs.forEach(function (input, index) { input.addEventListener('input', function () { input.value = input.value.replace(/[^a-z]/gi, '').toUpperCase().slice(0, 1); if (input.value && inputs[index + 1]) { inputs[index + 1].focus(); } }); }); }); } function clearGame(scope) { scope.querySelectorAll('input').forEach(function (input) { input.value = ''; input.classList.remove('is-correct', 'is-wrong'); }); scope.querySelectorAll('.is-selected').forEach(function (node) { node.classList.remove('is-selected'); }); scope.querySelectorAll('.is-found').forEach(function (node) { node.classList.remove('is-found'); }); } function initGameButtons() { document.querySelectorAll('[data-game-clear]').forEach(function (button) { button.addEventListener('click', function () { var shell = button.closest('[data-game-shell]') || document; clearGame(shell); }); }); document.querySelectorAll('[data-game-check]').forEach(function (button) { button.addEventListener('click', function () { var shell = button.closest('[data-game-shell]') || document; var empty = Array.prototype.some.call(shell.querySelectorAll('input'), function (input) { return !input.value; }); button.textContent = empty ? 'Keep going' : 'Completed'; window.setTimeout(function () { button.textContent = 'Check'; }, 1400); }); }); } function initSudoku() { document.querySelectorAll('[data-sudoku-grid] input').forEach(function (input) { input.addEventListener('input', function () { input.value = input.value.replace(/[^1-9]/g, '').slice(0, 1); }); }); } function initWordsearch() { document.querySelectorAll('[data-wordsearch-grid]').forEach(function (grid) { var selected = []; grid.querySelectorAll('button').forEach(function (button) { button.addEventListener('click', function () { button.classList.toggle('is-selected'); selected = Array.prototype.slice.call(grid.querySelectorAll('.is-selected')); if (selected.length < 2) { return; } var word = selected.map(function (node) { return node.textContent.trim(); }).join(''); var list = grid.parentElement.querySelector('[data-word="' + word + '"]'); if (list) { list.classList.add('is-found'); selected.forEach(function (node) { node.classList.remove('is-selected'); }); selected = []; } }); }); }); } function init() { initFaq(); initCrosswords(); initGameButtons(); initSudoku(); initWordsearch(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } }()); ; /* WEX archive sidebar sticky */ (function () { 'use strict'; var DESKTOP_BREAKPOINT = 992; var TOP_OFFSET = 105; function initWexSidebarSticky() { var sidebar = document.querySelector('.wex-category-ads-sticky'); var column = document.querySelector('.wex-category-ads-column'); var layout = document.querySelector('.wex-category-layout'); if (!sidebar || !column || !layout) { return; } function resetSidebar() { sidebar.style.position = ''; sidebar.style.top = ''; sidebar.style.left = ''; sidebar.style.bottom = ''; sidebar.style.width = ''; sidebar.style.transform = ''; } function updateSidebar() { if (window.innerWidth < DESKTOP_BREAKPOINT) { resetSidebar(); return; } var sidebarHeight = sidebar.offsetHeight; var columnRect = column.getBoundingClientRect(); var layoutRect = layout.getBoundingClientRect(); var sidebarWidth = columnRect.width || 300; var layoutBottom = layoutRect.bottom; var fixedBottom = TOP_OFFSET + sidebarHeight; if (columnRect.top >= TOP_OFFSET) { resetSidebar(); return; } if (layoutBottom <= fixedBottom) { sidebar.style.position = 'absolute'; sidebar.style.top = 'auto'; sidebar.style.left = '0'; sidebar.style.bottom = '0'; sidebar.style.width = sidebarWidth + 'px'; sidebar.style.transform = 'none'; return; } sidebar.style.position = 'fixed'; sidebar.style.top = TOP_OFFSET + 'px'; sidebar.style.left = columnRect.left + 'px'; sidebar.style.bottom = 'auto'; sidebar.style.width = sidebarWidth + 'px'; sidebar.style.transform = 'none'; } var ticking = false; function requestUpdate() { if (ticking) { return; } ticking = true; window.requestAnimationFrame(function () { updateSidebar(); ticking = false; }); } window.addEventListener('scroll', requestUpdate, { passive: true }); window.addEventListener('resize', requestUpdate); window.addEventListener('load', requestUpdate); if ('ResizeObserver' in window) { var resizeObserver = new ResizeObserver(requestUpdate); resizeObserver.observe(layout); resizeObserver.observe(column); resizeObserver.observe(sidebar); } requestUpdate(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initWexSidebarSticky); } else { initWexSidebarSticky(); } }()); ;