1// get current date for header/footer elements based on reader's location 2jQuery(document).ready(function ($) { 3 var mydate = new Date(); 4 var year = mydate.getYear(); 5 if (year < 1000) year += 1900; 6 var day = mydate.getDay(); 7 var month = mydate.getMonth(); 8 var monthWithZero = (mydate.getMonth() + 1).toString().padStart(2, '0'); 9 var daym = mydate.getDate(); 10 var dayWithZero = (mydate.getDay() + 1).toString().padStart(2, '0'); 11 var dayFullArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); 12 var dayArray = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); 13 var monthFullArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); 14 var monthArray = new Array("Jan.", "Feb.", "March", "April", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."); 15 16 $('.sno-hac-date').each(function () { 17 let format = $(this).data('format').toString().split(""); 18 let date = ''; 19 if (format[0] == '1') date += dayArray[day]; 20 if (format[0] == '2') date += dayFullArray[day]; 21 if (date) date += ', '; 22 if (format[1] == '1') date += monthArray[month]; 23 if (format[1] == '2') date += monthFullArray[month]; 24 date += ' ' + daym 25 if (format[3] != '0') date += ', ' + year 26 $(this).find('time').text(date); 27 $(this).find('time').attr('datetime', year + '-' + monthWithZero + '-' + dayWithZero) 28 }); 29}); 30 31// for print button 32jQuery(document).ready(function ($) { 33 $('body').on('click', '.print-row-icon', function() { 34 var url = window.location.href 35 if (url.indexOf('?') == -1) { 36 url += '?print=true' 37 } else { 38 url += '&print=true' 39 } 40 window.location = url 41 42 43 }); 44}); 45 46// for staff page sorting 47jQuery(document).ready(function ($) { 48 $('body').on('click', '.nav-block-inactive', function() { 49 $(this).closest('.staff-page-nav-area').find('.nav-block-active button').attr('aria-pressed', 'false'); 50 $(this).find('button').attr('aria-pressed', 'true'); 51 $(this).closest('.staff-page-nav-area').find('.nav-block-active').toggleClass('nav-block-active nav-block-inactive'); 52 $(this).closest('.staff-position-nav-block').toggleClass('nav-block-active nav-block-inactive'); 53 const group = $(this).find('button').data('group') 54 if (group == 'All Staff') { 55 $('.toggle-staff-group').show() 56 } else { 57 $('.toggle-staff-group').hide() 58 $('.toggle-staff-group[data-group="' + group + '"]').show() 59 } 60 }) 61}); 62 63// for My Calendar plugin 64jQuery(document).ready(function ($) { 65 $('.mc-main a').each(function () { 66 $(this).attr('rel', 'nofollow') 67 }) 68}); 69 70// for mobile sharing 71jQuery(document).ready(function() { 72 73 const isMobileLike = 74 ('ontouchstart' in window || navigator.maxTouchPoints > 0) && 75 window.matchMedia('(max-width: 1024px)').matches; 76 77 if (!isMobileLike) return; 78 79 document.querySelectorAll('.mobile-share-icon').forEach(link => { 80 link.addEventListener('click', function(e) { 81 if (navigator.share) { 82 e.preventDefault(); 83 navigator.share({ 84 title: document.title, 85 url: window.location.href 86 }); 87 } 88 }); 89 }); 90 91}); 92 93// for moving Related Stories Sidebar content to be below the post on mobile devices 94jQuery(document).ready(function ($) { 95 if ($('.sno-sidebar-related').length && $(window).width() < 600) { 96 $('.sno-sidebar-related').appendTo($('.sno-story-related-content-insertion')); 97 } 98}) 99 100// for Before After Photos added 11/2025 101jQuery(document).ready(function($) { 102 const MIN_PCT = 0; 103 const MAX_PCT = 100; 104 const clamp = (n, min, max) => Math.min(max, Math.max(min, n)); 105 106 // Get percent from an event (mouse/touch) relative to a specific wrapper 107 function percentFromEvent(e, $wrap) { 108 const direction = $wrap.data('direction') 109 const o = $wrap.offset(); 110 if (direction == 'Vertical') { 111 const h = $wrap.height(); 112 const pageY = e.type.indexOf('touch') === 0 113 ? e.originalEvent.touches[0].pageY 114 : e.pageY; 115 const y = clamp((pageY - o.top) / h, 0, 1); 116 return y * 100; 117 } else { 118 const w = $wrap.width(); 119 const pageX = e.type.indexOf('touch') === 0 120 ? e.originalEvent.touches[0].pageX 121 : e.pageX; 122 const x = clamp((pageX - o.left) / w, 0, 1); 123 return x * 100; 124 } 125 } 126 127 function setPosition($wrap, pct) { 128 pct = clamp(pct, MIN_PCT, MAX_PCT); 129 dir = $wrap.data('direction') 130 if (dir == 'Horizontal') { 131 left_pct = 100 - pct; 132 $wrap.find('.snosc-ba-handle').css('left', 'calc(' + pct + '% + 4px)'); 133 $wrap.find('.snosc-ba-img-wrap-before').css('clip-path', 'inset(0 ' + left_pct + '% 0 0)').attr('aria-valuenow', Math.round(pct)); 134 $wrap.find('.snosc-ba-img-wrap-after').css('clip-path', 'inset(0 0 0 ' + pct + '%').attr('aria-valuenow', Math.round(pct)); 135 } else { 136 top_pct = 100 - pct; 137 $wrap.find('.snosc-ba-handle').css('top', pct + '%'); 138 $wrap.find('.snosc-ba-img-wrap-before').css('clip-path', 'inset(0 0 ' + top_pct + '% 0)').attr('aria-valuenow', Math.round(pct)); 139 $wrap.find('.snosc-ba-img-wrap-after').css('clip-path', 'inset(' + pct + '% 0 0 0').attr('aria-valuenow', Math.round(pct)); 140 141 } 142 } 143 144 let $active = null; // the slider currently being dragged 145 146 // Initialize each slider 147 $('.snosc-ba').each(function () { 148 const position = $(this).data('slider') 149 const $wrap = $(this); 150 const $handle = $wrap.find('.snosc-ba-handle'); 151 152 setPosition($wrap, position); 153 $handle 154 .attr({ 155 role: 'slider', 156 'aria-valuemin': 0, 157 'aria-valuemax': 100, 158 'aria-valuenow': position, 159 'aria-label': 'Drag to compare before and after', 160 tabindex: 0 161 }); 162 163 // Start dragging on handle (or anywhere on the slider, optional) 164 $wrap.on('mousedown touchstart', '.snosc-ba-handle', function (e) { 165 e.preventDefault(); 166 $active = $wrap; 167 setPosition($active, percentFromEvent(e, $active)); 168 }); 169 170 // Move the slider on click 171 $wrap.on('click', function(e) { 172 $active = $wrap; 173 setPosition($active, percentFromEvent(e, $active)); 174 $active = null; 175 }) 176 177 // Keyboard support on the handle 178 $wrap.on('keydown', '.snosc-ba-handle', function (e) { 179 direction = $wrap.data('direction') 180 let pct = 0 181 if (direction == 'Horizontal') { 182 const LEFT = ['ArrowLeft', 'Left']; 183 const RIGHT = ['ArrowRight', 'Right'];
184 if (!LEFT.includes(e.key) && !RIGHT.includes(e.key)) return; 185 e.preventDefault(); 186 const maskWidthPx = parseFloat($wrap.find('.snosc-ba-handle').css('left')); 187 const wrapWidthPx = $wrap.width(); 188 pct = (maskWidthPx / wrapWidthPx) * 100; 189 pct += RIGHT.includes(e.key) ? 5 : -5; // step size 190 } else { 191 const UP = ['ArrowUp', 'Up']; 192 const DOWN = ['ArrowDown', 'Down']; 193 if (!UP.includes(e.key) && !DOWN.includes(e.key)) return; 194 e.preventDefault(); 195 const maskHeightPx = parseFloat($wrap.find('.snosc-ba-handle').css('top')); 196 const wrapHeightPx = $wrap.height(); 197 pct = (maskHeightPx / wrapHeightPx) * 100; 198 pct += DOWN.includes(e.key) ? 5 : -5; // step size 199 } 200 setPosition($wrap, pct); 201 }); 202 203 }); 204 205 // Drag move/end on document so it keeps tracking outside the slider bounds 206 $(document).on('mousemove touchmove', function (e) { 207 if (!$active) return; 208 e.preventDefault(); 209 setPosition($active, percentFromEvent(e, $active)); 210 }); 211 212 $(document).on('mouseup touchend touchcancel', function () { 213 if (!$active) return; 214 $active = null; 215 }); 216 217}) 218 219 220// for ImageLinks added 12/2024 221 222jQuery(document).ready(function ($) { 223 $('body').on('click', '.dot-wrapper', function (e) { 224 if ($(this).hasClass('tooltip-only')) return; 225 const id = $(this).data('id'); 226 const dot = $(this); 227 const wrap = $(this).closest('.imagelink-wrap'); 228 $(wrap).find('.dot-wrapper:not(.dot-wrapper-' + id).hide(); 229 $(wrap).find('.dot-wrapper-' + id).find('.pulsing-dot, .dot-pulse').fadeOut(); 230 setTimeout(function () { 231 $(wrap).css('overflow', 'hidden'); 232 $('.dot-wrapper-' + id).find('.dot-overlay').addClass('dot-enlarge'); 233 setTimeout(function () { 234 const overlayContent = $(dot).find('.imagelink-overlay-content').clone().html() 235 $(wrap).find('.imagelink-overlay-displayed-content').html(overlayContent); 236 $(wrap).find('.imagelink-overlay').show(); 237 $(wrap).find('.il-close').data('id', id); 238 const videoWidth = $('.imagelink-overlay-displayed-content').find('.il-video-full iframe').width(); 239 $('.imagelink-overlay-displayed-content').find('.il-caption-area').width(videoWidth + 'px'); 240 $(wrap).find('.overlay-' + id).focus(); 241 }, 300) 242 }, 1) 243 }) 244 $('body').on('click', '.il-close', function () { 245 const id = $(this).data('id'); 246 const wrap = $(this).closest('.imagelink-wrap'); 247 $(wrap).find('.dot-wrapper-' + id).find('.dot-overlay').removeClass('dot-enlarge') 248 $(wrap).find('.imagelink-overlay').fadeOut(); 249 var $videoIframe = $(wrap).find('.imagelink-overlay iframe'); 250 251 if ($videoIframe.length) { 252 var src = $videoIframe.attr('src'); 253 $videoIframe.attr('src', ''); 254 $videoIframe.attr('src', src); 255 } 256 setTimeout(function () { 257 $(wrap).find('.dot-wrapper').fadeIn(); 258 $('.dot-wrapper-' + id).find('.pulsing-dot, .dot-pulse').fadeIn(); 259 $('.dot-wrapper-' + id).focus(); 260 const $tooltip = $('.dot-wrapper-' + id).find('.dot-tooltip'); 261 $tooltip.css({ 262 opacity: 0, 263 transform: 'translate(0px, 0px)' 264 }); 265 266 setTimeout(() => { 267 $tooltip.hide(); 268 }, 300); 269 270 }, 600) 271 }) 272 273 $(document).on('keydown', '.dot-wrapper', function (e) { 274 if (e.key === 'Enter' || e.key === ' ') { 275 e.preventDefault(); 276 $(this).trigger('click') 277 } 278 }); 279 280 $(document).on('keydown', '.il-close', function (e) { 281 if (e.key === 'Enter') { 282 e.preventDefault(); 283 $(this).trigger('click') 284 } 285 }); 286 287 $(document).on('keydown', function (e) { 288 if (e.key === 'Escape') {
289 $('.il-close:visible').trigger('click') 290 } 291 }); 292 293 294 function positionAndShowTooltip($Dot, $tooltip) { 295 296 $tooltip.hide().css({ 297 opacity: 0, 298 transform: 'translate(0px, 0px)' 299 }); 300 301 if ($tooltip.text().trim() === "" || $('.preview-panel').length > 0) { 302 return; 303 } 304 305 const dotPosition = $Dot.position(); 306 const containerWidth = $Dot.closest('.imagelink-wrap').width(); 307 const dotCenterX = dotPosition.left + $Dot.width() / 2; 308 const dotCenterY = $Dot.height() / 2; 309 310 const tooltipHeight = $tooltip.outerHeight(); 311 const tooltipTop = dotCenterY - (tooltipHeight / 2); 312 313 if (dotCenterX > containerWidth / 2) { 314 $tooltip.css({ 315 top: tooltipTop + "px", 316 left: 'auto', 317 right: '100%', 318 transform: 'translate(-10px, 0px)', 319 opacity: 1, 320 }); 321 } else { 322 $tooltip.css({ 323 top: tooltipTop + "px", 324 left: '100%', 325 right: 'auto', 326 transform: 'translate(10px, 0px)', 327 opacity: 1, 328 }); 329 } 330 331 $tooltip.show(); 332 } 333 334 function hideTooltip($tooltip) { 335 $tooltip.css({ 336 opacity: 0, 337 transform: 'translate(0px, 0px)', 338 }); 339 340 setTimeout(() => { 341 $tooltip.hide(); 342 }, 300); 343 } 344 345 // Hover events 346 $('.dot-wrapper').hover( 347 function () { 348 const $Dot = $(this); 349 const $tooltip = $Dot.find('.dot-tooltip'); 350 positionAndShowTooltip($Dot, $tooltip); 351 }, 352 function () { 353 const $tooltip = $(this).find('.dot-tooltip'); 354 hideTooltip($tooltip); 355 } 356 ); 357 358 // Focus and blur events for keyboard navigation 359 $(document).on('focus', '.dot-wrapper', function () { 360 const $Dot = $(this); 361 const $tooltip = $Dot.find('.dot-tooltip'); 362 positionAndShowTooltip($Dot, $tooltip); 363 }); 364 365 $(document).on('blur', '.dot-wrapper', function () { 366 const $tooltip = $(this).find('.dot-tooltip'); 367 hideTooltip($tooltip); 368 }); 369 370 371}); 372 373 374// for live updates added 06/2024 375jQuery(document).ready(function ($) { 376 $('body').on('mouseenter', '.live-update-share-wrap', function () { 377 $(this).find('.live-update-share-text').show(); 378 $(this).find('.live-update-share-link').addClass('live-update-share-link-hover'); 379 }); 380 $('body').on('mouseleave', '.live-update-share-wrap', function () { 381 $(this).find('.live-update-share-text').hide(); 382 $(this).find('.live-update-share-link').removeClass('live-update-share-link-hover'); 383 }); 384 385 $('body').on('click', '.live-update-share-link', function () { 386 $(this).closest('.live-update-share-wrap').find('.live-update-share-text').text('Link Copied'); 387 var share_link = $(this).data('share-link'); 388 var $tempInput = $('<input>'); 389 $('body').append($tempInput); 390 $tempInput.val(share_link).select(); 391 document.execCommand('copy'); 392 $tempInput.remove(); 393 $(this).closest('.live-update-share-wrap').find('.live-update-share-link').removeClass('live-update-share-link-hover'); 394 var clicked = $(this) 395 setTimeout(function () { 396 $(clicked).closest('.live-update-share-wrap').find('.live-update-share-text').hide(); 397 var label = $(clicked).closest('.live-update-share-wrap').find('.live-update-share-text') 398 $(label).text('Sharing Link'); 399 }, 1000) 400 }); 401 402 if (window.location.hash && window.location.hash.includes('live-update')) { 403 setTimeout(function () { 404 var initialTargetId = window.location.hash; 405 var topoffset = ($('#wpadminbar').length > 0) ? 60 : 25; 406 var stickyHeaderOffset = 0; 407 $('.sno-header-wrap-desktop .sno-header-row-stick').each(function () { 408 stickyHeaderOffset += $(this).height(); 409 }) 410 $('html, body').animate({ 411 scrollTop: $(initialTargetId).offset().top - topoffset - stickyHeaderOffset 412 }, 1000); 413 }, 500); 414 } 415 416 // functions for autoupdating timestamps on live updates 417 function adjustForGMTOffset(date, gmtOffset) { 418 var utc = date.getTime() + (date.getTimezoneOffset() * 60); 419 var offsetMilliseconds = gmtOffset * 3600000; 420 var adjustedDate = new Date(utc + offsetMilliseconds); 421 return adjustedDate; 422 } 423 424 function getElapsedTime(dateTimeStamp) { 425 console.log('testing date', dateTimeStamp) 426 var now = new Date(); 427 var dateTime = new Date(dateTimeStamp); 428 var difference = now - dateTime; 429 430 var elapsedMinutes = Math.floor(difference / 1000 / 60); 431 432 if (elapsedMinutes <= 0) { 433 return 'just now'; 434 } else if (elapsedMinutes < 60) { 435 return elapsedMinutes + ' minute' + (elapsedMinutes === 1 ? '' : 's') + ' ago'; 436 } else if (elapsedMinutes < 1440) { 437 var elapsedHours = Math.floor(elapsedMinutes / 60); 438 return elapsedHours + ' hour' + (elapsedHours === 1 ? '' : 's') + ' ago'; 439 } else if (elapsedMinutes < 10080) { 440 var elapsedDays = Math.floor(elapsedMinutes / 1440); 441 return elapsedDays + ' day' + (elapsedDays === 1 ? '' : 's') + ' ago'; 442 } 443 444 return false;
445 } 446 447 function updateElapsedTime(updateDiv) { 448 var id = $(updateDiv).attr('id'); 449 var dateTimeStamp = $(updateDiv).find('.live-update-timestamp').data('timestamp-gmt'); 450 var elapsedTime = getElapsedTime(dateTimeStamp); 451 if (elapsedTime && $(updateDiv).find('.timestamp-time').is(':visible')) { 452 scrollTextOnce(updateDiv, elapsedTime) 453 } else if (elapsedTime) { 454 scrollTextUpdate(updateDiv, elapsedTime); 455 } else { 456 $(updateDiv).find('.timestamp-elapsed').text($(updateDiv).find('.timestamp-time').text()); 457 var intervalID = $('#' + id).data('intervalid'); 458 clearInterval(intervalID); 459 } 460 } 461 462 function scrollTextUpdate(updateDiv, elapsedTime) { 463 var timeSize = parseInt($(updateDiv).find('.live-update-timestamp').data('time-size')); 464 $(updateDiv).find('.timestamp-elapsed-update').text(elapsedTime); 465 var text1 = $(updateDiv).find('.timestamp-elapsed').text(); 466 var text2 = $(updateDiv).find('.timestamp-elapsed-update').text(); 467 if (text1 != text2) { 468 // only animate the timestamp change if the browser tab is active 469 // this is needed because inactive browser tabs don't run animations 470 if (typeof document.hidden !== "undefined") { 471 if (document.hidden) { 472 // Tab is inactive or hidden 473 $(updateDiv).find('.timestamp-elapsed').css('top', '-' + timeSize + 'px'); 474 $(updateDiv).find('.timestamp-elapsed-update').css('top', '0px'); 475 $(updateDiv).find('.timestamp-elapsed').css('top', timeSize + 'px'); 476 $(updateDiv).find('.timestamp-toggle').toggleClass('timestamp-elapsed timestamp-elapsed-update'); 477 } else { 478 // Tab is active -- animate the change 479 $(updateDiv).find('.timestamp-elapsed').animate({top: '-' + timeSize + 'px'}, 500); 480 $(updateDiv).find('.timestamp-elapsed-update').animate({ 481 'top': '0px' 482 }, 500, function () { 483 $(updateDiv).find('.timestamp-elapsed').css('top', timeSize + 'px'); 484 $(updateDiv).find('.timestamp-toggle').toggleClass('timestamp-elapsed timestamp-elapsed-update'); 485 }); 486 } 487 } 488 } 489 } 490 491 if (typeof document.hidden !== "undefined") { 492 document.addEventListener("visibilitychange", function () { 493 }); 494 } 495 496 function scrollTextOnce(updateDiv, elapsedTime) { 497 $(updateDiv).find('.timestamp-elapsed').text(elapsedTime); 498 var timeSize = parseInt($(updateDiv).find('.live-update-timestamp').data('time-size')); 499 var text1 = $(updateDiv).find('.timestamp-time').text(); 500 var text2 = $(updateDiv).find('.timestamp-elapsed').text(); 501 if (text1 != text2) { 502 $(updateDiv).find('.timestamp-time').animate({top: '-' + timeSize + 'px'}, 500); 503 $(updateDiv).find('.timestamp-elapsed').animate({'top': '0px'}, 500); 504 setTimeout(function () { 505 $(updateDiv).find('.timestamp-time').hide(); 506 $(updateDiv).find('.timestamp-time').css('top', timeSize + 'px'); 507 }, 501); 508 } 509 } 510 511 function isElementInViewport(el) { 512 var $el = $(el); 513 var elementTop = $el.offset().top; 514 var elementBottom = elementTop + $el.outerHeight(); 515 var viewportTop = $(window).scrollTop(); 516 var viewportBottom = viewportTop + $(window).height(); 517 return elementBottom > viewportTop && elementTop < viewportBottom; 518 } 519 520 function checkUpdateDivsViewport() { 521 $('body').find('.live-update-wrap.timestamp-check').each(function (i, v) { 522 var updateDiv = $(this); 523 var id = $(this).attr('id').replace('live-update-', ''); 524 if (isElementInViewport('#live-update-' + id)) { 525 $(this).removeClass('timestamp-check') 526 var intervalID = ''; 527 setTimeout(function () { 528 updateElapsedTime(updateDiv); 529 }, 4000); 530 setTimeout(function () { 531 intervalID = setInterval(function () { 532 updateElapsedTime(updateDiv) 533 }, 30000); 534 }, 8000); 535 $('#live-update-' + id).data('intervalid', intervalID); 536 } 537 }); 538 } 539 540 checkUpdateDivsViewport() 541 $('.live-updates-wrap').data('page-title', document.title) 542 $(window).on('scroll resize', function () { 543 checkUpdateDivsViewport(); 544 }); 545 546 // Determine whether or not to start the polling mechanism -- only do so if there was an update in the last 24 hours 547 var currentTime = Math.floor(Date.now() / 1000); 548 var oneDayAgo = currentTime - (24 * 60 * 60); 549 550 $('.live-update-wrap').each(function () { 551 var publishedOn = $(this).data('published-on'); 552 if (publishedOn > oneDayAgo) { 553 // show the live coverage banner 554 $('.live-coverage-banner-wrap').insertBefore('h1.sno-story-headline').slideDown(); 555 $('.live-coverage-banner').animate({'opacity': '1'}, 500); 556 pollForUpdates(); 557 return false;
558 } 559 }); 560 561 // move sharing link if both headline and byline are absent 562 $('.live-update-wrap').each(function () { 563 if ($(this).find('h3').length < 1 && $(this).find('.sno-story-byline').length < 1) { 564 $(this).find('.live-update-share-wrap').css({'top': '15px', 'right': '15px'}); 565 } 566 if ($(this).find('.sno-story-byline').length < 1 && $(this).find('.pinned-flag').length < 1) { 567 $(this).find('.update-headline-wrap').css({'padding-right': '75px'}); 568 } 569 }) 570 571 var pollingIntervalID; 572 var stopPollingID; 573 574 function pollForUpdates() { 575 // ajax polling system to check server for updates to story every two minutes 576 pollingIntervalID = setInterval(function () { 577 checkForUpdates() 578 }, 120000); // 120000 579 // Set the timeout to stop the interval after 1 hour (3600000 milliseconds) 580 stopPollingID = setTimeout(function () { 581 clearInterval(pollingIntervalID); 582 showRefreshButton() 583 }, 3600000); 584 } 585 586 function checkForUpdates() { 587 588 var post_id = $('.live-updates-wrap').data('post-id'); 589 var last_rendered = $('.live-updates-wrap').data('last-rendered'); 590 var rendered_ids = []; 591 592 $('.live-update-wrap').each(function () { 593 rendered_ids.push($(this).data('id')); 594 }); 595 $.ajax({ 596 url: frontend_ajax_object.ajaxurl, 597 type: 'POST', 598 data: { 599 action: 'check_for_updates', 600 post_id: post_id, 601 last_rendered: last_rendered 602 }, 603 success: function (results) { 604 if (results != 'false') { 605 $('.refresh-notification').fadeOut(); 606 var update_ids = $.parseJSON(results); 607 var new_updates = []; 608 $.each(update_ids, function (i, v) { 609 if ($.inArray(v, rendered_ids) === -1) { 610 new_updates.push(v); 611 } 612 }) 613 var count = new_updates.length; 614 if (count == 0) return; 615 posts_to_retrieve = new_updates.join(','); 616 var message = (count > 1) ? count + ' New Updates' : '1 New Update';
617 $('.update-notification').data('new-updates', posts_to_retrieve) 618 $('.update-notification').attr('data-new-updates', posts_to_retrieve) 619 $('.update-notification').text(message).fadeIn(); 620 621 var currentTimestamp = Math.floor(Date.now() / 1000); 622 $('.live-updates-wrap').data('last-rendered', currentTimestamp) 623 624 document.title = '(' + count + ') ' + document.title; 625 626 // stop polling until the user clicks the button 627 if (pollingIntervalID) clearInterval(pollingIntervalID); 628 if (stopPollingID) clearTimeout(stopPollingID) 629 630 } else { 631 if ($('.refresh-notification').is(':visible')) { 632 $('.refresh-notification').text('No Updates Available'); 633 setTimeout(function () { 634 $('.refresh-notification').fadeOut(); 635 }, 4000); 636 pollForUpdates(); 637 } 638 } 639 } 640 }); 641 } 642 643 $('body').on('click', '.update-notification', function () { 644 var update_ids = $(this).data('new-updates'); 645 $.ajax({ 646 url: frontend_ajax_object.ajaxurl, 647 type: 'POST', 648 data: { 649 action: 'get_live_updates', 650 update_ids: update_ids 651 }, 652 success: function (results) { 653 $('.update-notification').fadeOut(); 654 $('.live-updates-wrap').prepend(results); 655 $('html, body').animate({scrollTop: $('.live-updates-wrap').offset().top - 50}, 'slow'); 656 $('.update-new').slideDown(); 657 $('.update-new').animate({opacity: 1}, 'slow'); 658 document.title = $('.live-updates-wrap').data('page-title') 659 660 $('.update-new').each(function () { 661 if ($(this).css('background-color') != $('.sno-story-page').css('background-color')) $(this).addClass('update-add-padding') 662 }) 663 // restart polling 664 pollingIntervalID = setInterval(function () { 665 checkForUpdates() 666 }, 120000); 667 // restart timeout check 668 stopPollingID = setTimeout(function () { 669 clearInterval(pollingIntervalID); 670 showRefreshButton() 671 }, 3600000); 672 // animation for new updates 673 setTimeout(function () { 674 $('.update-new').css({borderColor: 'rgba(255, 0, 0, 0)'}) 675 $('.update-new').css({borderColor: 'rgba(255, 0, 0, 0)'}) 676 setTimeout(function () { 677 $('.live-update-wrap.update-new').toggleClass('update-new update-rendered') 678 }, 1000); 679 }, 4000); 680 } 681 }); 682 }); 683 684 function showRefreshButton() { 685 $('.refresh-notification').fadeIn(); 686 } 687 688 $('body').on('click', '.refresh-notification', function () { 689 checkForUpdates(); 690 }) 691 692 693}); 694 695// jQuery(document).ready(function ($) { 696// $('nav').find('li.menu-item-has-children').each(function() { 697// $(this).find('li').attr('tabindex', '0') 698// }) 699// }); 700 701jQuery(document).ready(function ($) { 702 $('body').on('click', '.carousel-widget img', function () { 703 var href = $(this).closest('.carousel-widget-slide').find('a').attr('href'); 704 if (href) { 705 window.location.href = href; 706 } 707 }) 708 $('body').on('click', '.emailshare img', function () { 709 var href = $(this).closest('.emailshare').find('a').attr('href'); 710 if (href) { 711 window.location.href = href; 712 } 713 }) 714}); 715 716 717// for new story templates added 04/2023 718jQuery(document).ready(function ($) { 719 720 // checking to see if an image is both a featured image and inserted into the post 721 // if it's both, hide the featured image 722 // written to work with both legacy and new templates 723 var featuredImageID = $('.photowrap a.modal-photo').data('photo-id') 724 if (featuredImageID != undefined) { 725 $('.sno-story-body-content img:not(.sno-story-body-media img), span.storycontent img:not(.permalinkphotobox img)').each(function () { 726 var classes = $(this).attr('class') 727 if (classes != undefined) classes = classes.split(' '); 728 $.each(classes, function (i, value) { 729 if (value.indexOf("wp-image-") >= 0) { 730 value = value.replace('wp-image-', '') 731 if (value == featuredImageID) { 732 $('.sno-story-body-media, .permalinkphotobox').hide() 733 var story_id = $('.photowrap a.modal-photo').data('story-id') 734 $.ajax({ 735 url: frontend_ajax_object.ajaxurl, 736 type: 'POST', 737 data: { 738 action: 'hidefeaturedimage', 739 story: story_id, 740 photo: featuredImageID, 741 }, 742 success: function (results) { 743 } 744 }) 745 } 746 } 747 }); 748 }) 749 } 750 751 // activate print button for keyboard printing shortcuts 752 $('body').on('keydown', function (event) { 753 var key = event.keyCode || event.charCode || 0; 754 if (key == 80 && event.metaKey == true) { 755 if (!$('.sno-story-wrap').length) return; 756 if ($('body').hasClass('print-override-deactivate')) return; 757 event.preventDefault(); 758 var url = window.location.href 759 if (url.indexOf('?') == -1) { 760 url += '?print=true' 761 } else { 762 url += '&print=true' 763 } 764 window.location = url 765 } 766 $('body').on('keydown', function (e) { 767 if (e.ctrlKey && e.keyCode == 80) { 768 if (!$('.sno-story-wrap').length) return; 769 if ($('body').hasClass('print-override-deactivate')) return; 770 event.preventDefault(); 771 var url = window.location.href 772 if (url.indexOf('?') == -1) { 773 url += '?print=true' 774 } else { 775 url += '&print=true' 776 } 777 window.location = url 778 } 779 }); 780 }); 781 window.addEventListener('beforeprint', function (e) { 782 if (!$('.sno-story-wrap').length) return; 783 if ($('body').hasClass('print-override-deactivate')) return; 784 e.preventDefault 785 var url = window.location.href 786 if (url.indexOf('?') == -1) { 787 url += '?print=true' 788 } else { 789 url += '&print=true' 790 } 791 window.location = url 792 }); 793 794 795 $('.sno-story-body-content figure.wp-caption').each(function (i, el) { 796 $(el).css('max-width', $(el).css('width')) 797 $(el).css('width', 'auto') 798 }); 799 800 // full-size photos on immersive templates -- add parallax effect 801 $('.add-parallax img.size-full').each(function () { 802 if ($(this).attr('width') >= $(window).width()) $(this).addClass('image-parallax'); 803 }) 804 805 // for infobox accordions 806 $('body').on('click', '.infobox-segment-title-accordion', function () { 807 if ($(this).closest('.infobox-segment').find('.infobox-segment-body').is(':visible')) { 808 $(this).closest('.infobox-segment').find('.infobox-segment-body-wrap').slide
808Up(); 809 } else { 810 $(this).closest('.sno-infobox').find('.infobox-segment-body-wrap').slideUp(); 811 $(this).closest('.infobox-segment').find('.infobox-segment-body-wrap').slideDown(); 812 $(this).closest('.sno-infobox').find('.infobox-toggle').removeClass('fa-minus').addClass('fa-plus'); 813 } 814 $(this).closest('.infobox-segment').find('.infobox-toggle').toggleClass('fa-minus fa-plus'); 815 }); 816 817 818 // for related stories carousel on story pages 819 $('.related-carousel-list').each(function () { 820 $(this).flexslider({ 821 animation: "slide", 822 animationLoop: true, 823 controlNav: false, 824 customDirectionNav: $(".rcl-nav .custom-navigation span"), 825 slideshow: false, 826 itemMargin: 10, 827 touch: true, 828 itemWidth: 375, 829 minItems: 1, 830 move: 1, 831 maxItems: 5 832 }); 833 }); 834 var TB_CurrentScroll = 0; 835 var TB_NextScroll = 0; 836 var isChanging = false 837 $(window).scroll(function (e) { 838 TB_CurrentScroll = TB_NextScroll; 839 TB_NextScroll = $(this).scrollTop(); 840 841 if (TB_NextScroll < TB_CurrentScroll && $(document).scrollTop() > 300) { // scrolling up on the page causes it to display 842 if ($('.sno-story-related-content-carousel').is(":hidden")) { 843 $('.sno-story-related-content-carousel').show(); 844 $('.sno-story-related-content-carousel').stop().animate({bottom: '0'}, {duration: 300, queue: false}); 845 } 846 } else if ((TB_NextScroll > TB_CurrentScroll && $(document).scrollTop() > 300) || $(document).scrollTop() < 10 && isChanging == false) { // scrolling down on the page causes it to hide 847 isChanging = true; 848 $('.sno-story-related-content-carousel').stop().animate({ 849 bottom: '-120px' 850 }, 200, function () { 851 $('.sno-story-related-content-carousel').hide(); 852 isChanging = false; 853 }); 854 } 855 }); 856 857 858 if ($('.related-bottom-drawer').length) { 859 var window_position = $(window).scrollTop(); 860 var window_height = $(window).height(); 861 var footerTop = $('.footer').offset().top - window_height; 862 863 $(window).scroll(function () { 864 var scroll = $(window).scrollTop(); 865 if ($('.sno-slideshow-segment').length) { 866 const lastSegment = $('.sno-slideshow-segment').last().offset().top; 867 if (scroll > lastSegment && !$('.bottom-drawer-header').is(':visible') && footerTop > scroll) { 868 $('.bottom-drawer-header').slideDown(); 869 } 870 if ((scroll < lastSegment && $('.bottom-drawer-header').is(':visible')) || footerTop < scroll) { 871 $('.bottom-drawer-header').slideUp(); 872 $('.related-term-container').slideUp(); 873 $('.bottom-drawer-background').removeClass('bottom-drawer-background-active'); 874 $('.related-bottom-drawer').removeClass('hide-shadow'); 875 $('.bds-arrows').fadeOut(); 876 } 877 } 878 if (!$('.sno-slideshow-segment').length) { 879 if (scroll < 200) { 880 $('.bottom-drawer-header').slideUp(); 881 $('.related-term-container').slideUp(); 882 $('.bottom-drawer-background').removeClass('bottom-drawer-background-active'); 883 $('.related-bottom-drawer').removeClass('hide-shadow'); 884 $('.bds-arrows').fadeOut(); 885 } else if (scroll > (window_height / 2) && !$('.bottom-drawer-header').is(':visible') && footerTop > scroll) { 886 $('.bottom-drawer-header').slideDown(); 887 } 888 } 889 // if( !$('.sno-slideshow-segment').length && footerTop < scroll ) { 890 // $('.bottom-drawer-header').slideUp(); 891 // $('.related-term-container').slideUp(); 892 // $('.bottom-drawer-background').removeClass('bottom-drawer-background-active'); 893 // $('.related-bottom-drawer').removeClass('hide-shadow'); 894 // $('.bds-arrows').fadeOut(); 895 // } 896 window_position = scroll; 897 }); 898 } 899 900 901 // end functions for related stories in bottom drawer on story page 902 if ($('img.image-parallax').length > 0) { 903 var images = document.querySelectorAll('img.image-parallax'); 904 new simpleParallax(images); 905 } 906 907 // for fade image effect for story segment slideshows 908 var slideshow_photos = $('.sno-story-photo-fade') 909 slideshow_photos.each(function (i, el) { 910 var el = $(el) 911 if (el.is(':visible')) { 912 el.addClass('sno-story-photo-fade-in') 913 } 914 }) 915 $(window).scroll(function (event) { 916 $('.sno-story-photo-fade').each(function (i, el) { 917 const rect = el.getBoundingClientRect(); 918 var el = $(el) 919 if (rect.bottom < $(window).height() / 2) { 920 el.removeClass('sno-story-photo-fade-in'); 921 } else if ($(window).height() - rect.top > $(window).height() / 4) { 922 el.addClass('sno-story-photo-fade-in') 923 } 924 }) 925 }) 926 927 $('.segment-split-text').each(function () { 928 if ($(this).find('.segment-split-text-inner').height() + 100 < $(this).height()) $(this).css('display', 'flex'); 929 }) 930 931 $('body').on('click', '.minimize-overlay', function () { 932 $(this).closest('.segment-overlay').addClass('segment-overlay-hidden'); 933 $('body').on('mouseleave', '.segment-overlay', function () { 934 $('body').on('mouseenter', '.segment-overlay', function () { 935 $(this).removeClass('segment-overlay-hidden'); 936 }); 937 }); 938 }) 939 940 center_video() 941 942 function center_video() { 943 $('.sno-slideshow-segment .segment-video-immersive').each(function () { 944 $(this).css('margin-top', ($(window).height() - $(this).height()) / 2) 945 }); 946 } 947 948 $(window).on('resize', function () { 949 center_video() 950 }); 951 952 // up and down arrows for story segment slideshows 953 $('body').on('click', '.down-arrow', function () { 954 $('.segment-split-text, .segment-overlay').animate({scrollTop: 0}, 1000); 955 $('.segment-overlay').removeClass('segment-overlay-hidden'); 956 $('.sno-slideshow-segment').each(function (i, el) { 957 const rect = el.getBoundingClientRect(); 958 if (rect.top < 20) return 959 const scrollTop = $('html').scrollTop(); 960 $("html, body").animate({scrollTop: scrollTop + rect.top}, 666); 961 return false;
962 }) 963 }) 964 $('body').on('click', '.up-arrow', function () { 965 $('.segment-split-text, .segment-overlay').animate({scrollTop: 0}, 1000); 966 $('.segment-overlay').removeClass('segment-overlay-hidden'); 967 if (!$('.sno-header-wrap:visible').length) show_header(); 968 $($('.sno-slideshow-segment').get().reverse()).each(function (i, el) { 969 const rect = el.getBoundingClientRect(); 970 const scrollTop = $('html').scrollTop(); 971 if (rect.top < 0) { 972 $("html, body").animate({scrollTop: scrollTop + rect.top}, 666); 973 return false; 974 } 975 if (scrollTop < $(window).height() + 100) { 976 $("html, body").animate({scrollTop: 0}, 666); 977 return false; 978 } 979 }) 980 }) 981 982 983 if ($('#wrap').data('post-template') == 'fulltop' || $('#wrap').data('post-template') == 'split') { 984 var position = $(window).scrollTop(); 985 const ss_height = $("div.sno-format-slideshow").height(); 986 987 $(window).scroll(function () { 988 var scroll = $(window).scrollTop(); 989 if (scroll < position && !$('.sno-header-wrap:visible').length) { 990 show_header(); 991 } 992 if (scroll > ($(window).height() / 2) && !$('.up-arrow:visible').length) { 993 $('.up-arrow').fadeIn(); 994 } 995 if (scroll < ($(window).height() / 2) && $('.up-arrow:visible').length) { 996 $('.up-arrow').fadeOut(); 997 } 998 if (scroll > ss_height - ($(window).height() / 2) && $('.down-arrow:visible').length) { 999 $('.down-arrow').fadeOut(); 1000 } 1001 if (scroll < ss_height - ($(window).height() / 2) && !$('.down-arrow:visible').length) { 1002 $('.down-arrow').show(); 1003 } 1004 position = scroll; 1005 }); 1006 } 1007 ; 1008 1009 function show_header() { 1010 var desktop_breakpoint = $('#wrap').data('desktop-breakpoint'); 1011 var tablet_breakpoint = $('#wrap').data('tablet-breakpoint'); 1012 var mobile_breakpoint = $('#wrap').data('mobile-breakpoint'); 1013 var site_width = $(window).width(); 1014 if (site_width < mobile_breakpoint) { 1015 var header_target = '.sno-header-wrap-mobile'; 1016 } else if (site_width < tablet_breakpoint) { 1017 var header_target = '.sno-header-wrap-tablet'; 1018 } else { 1019 var header_target = '.sno-header-wrap-desktop'; 1020 } 1021 if ($(header_target).find('.sno-header-row-stick').length && !$('.sno-slideshow-segment').length ) { 1022 var fixed_element_adjustment = $('#wpadminbar').length && $('#wpadminbar').is(':visible') ? $('#wpadminbar').outerHeight() : 0 1023 var stick_height = 0 1024 $(header_target).scrollToFixed({ 1025 marginTop: fixed_element_adjustment + stick_height, 1026 spacerClass: 'topheaderspacer', 1027 zIndex: 2000, 1028 }) 1029 stick_height += $(this).height() 1030 $(header_target).fadeIn(); 1031 } else { 1032 $(header_target).show(); 1033 } 1034 1035 } 1036 1037 // fixing text in story that didn't get wrapped with p tags 1038 if ($('#sno-story-body-content').length) { 1039 var elems = document.getElementById('sno-story-body-content').childNodes; 1040 for (var i = 0; i < elems.length; i++) { 1041 var el = elems[i]; 1042 if (el.nodeType === 3 && el.nodeValue.trim().length) { 1043 const newNode = document.createElement('p'); 1044 const textNode = document.createTextNode(el.nodeValue); 1045 newNode.appendChild(textNode); 1046 $(elems[i + 1]).after(newNode) 1047 $(elems[i]).remove(); 1048 } 1049 } 1050 } 1051 1052 // detect if sno ad collides with any elements within the post story 1053 var story_p = $('.sno-story-body-content > p') 1054 var story_divs = $('.sno-story-body-content > div, .sno-story-body-content > figure'); 1055 if (story_p.length > 1) { 1056 $.each(story_p, function () { 1057 $.each(story_divs, function (index, value) { 1058 var sno_ad = $('.sno-ad'); 1059 if (sno_ad.length < 1) return; 1060 if ($(value).hasClass('sno-ad')) return; 1061 if (collision($(sno_ad), $(value)) == true) { 1062 var next_ps = sno_ad.nextAll('p'); 1063 $.each(next_ps, function (index, value) { 1064 if ($(this).text().trim().length) { 1065 sno_ad.insertAfter($(this)); 1066 return false;
1067 } 1068 }) 1069 return false; 1070 } 1071 }); 1072 }) 1073 } 1074 // detect if a slideshow or infobox inserted into the story is colliding with the featured image 1075 var story_featured = $('.sno-story-body-content .sno-story-body-media'); 1076 var story_slideshow = $('.sno-story-body-content .slideshowwrap'); 1077 if (story_slideshow.length && story_featured.length) { 1078 $.each(story_slideshow, function (index, value) { 1079 if (collision($(story_featured), $(value)) == true) { 1080 story_featured.hide(); 1081 } 1082 }) 1083 } 1084 1085 // detect if a slideshow or infobox inserted into the story is colliding with the featured image 1086 var story_featured = $('.sno-story-body-content .sno-story-body-media'); 1087 var story_infobox = $('.sno-story-body-content .sno-infobox'); 1088 if (story_infobox.length && story_featured.length) { 1089 $.each(story_infobox, function (index, value) { 1090 if (collision($(story_featured), $(value)) == true) { 1091 story_featured.hide(); 1092 } 1093 }) 1094 } 1095 1096 function collision($div1, $div2) { 1097 var x1 = $div1.offset().left; 1098 var y1 = $div1.offset().top; 1099 var h1 = $div1.outerHeight(true); 1100 var w1 = $div1.outerWidth(true); 1101 var b1 = y1 + h1; 1102 var r1 = x1 + w1; 1103 var x2 = $div2.offset().left; 1104 var y2 = $div2.offset().top; 1105 var h2 = $div2.outerHeight(true); 1106 var w2 = $div2.outerWidth(true); 1107 var b2 = y2 + h2; 1108 var r2 = x2 + w2; 1109 1110 if (b1 < y2 || y1 > b2 || r1 < x2 || x1 > r2) return false; 1111 return true; 1112 } 1113 1114 $('.sno-story-wrap').find('.slideshowwrap').each(function () { 1115 var image_ratio = $(this).data('ratio') 1116 var width = $(this).width(); 1117 var height = $(this).height(); 1118 var photo_width = $(this).find('img').data('width'); 1119 var photo_height = $(this).find('img').data('height'); 1120 if (photo_height < height && photo_width < width) return; 1121 if (height != 0 && width != 0) { 1122 var area_ratio = (width / height).toFixed(2) 1123 if (Math.abs(image_ratio - area_ratio) < 0.25) $(this).find('img').css({'object-fit': 'cover'}) 1124 } 1125 }) 1126 1127 $('body').on('click', '.byline-photo', function () { 1128 var link = $(this).data('link'); 1129 if (link) { 1130 window.location = link 1131 } 1132 }); 1133 $('body').on('click', '.related-story.preview-card, .contributor-area', function () { 1134 var link = $(this).find('a').attr('href') 1135 if (link) { 1136 window.location = link 1137 } 1138 }) 1139 $('.sno-story-related-content').find('img.scale').each(function () { 1140 var image_ratio = $(this).data('ratio') 1141 var width = $(this).closest('.related-story-photo').width(); 1142 if ($(this).closest('.column-count-1').length) { 1143 var height = $(this).closest('.related-story-photo-area').height(); 1144 } else { 1145 var height = $(this).closest('.related-story-photo-area').height() - $(this).closest('.related-story-photo-area').find('.related-story-headline').height(); 1146 } 1147 if (height != 0 && width != 0) { 1148 var area_ratio = (width / height).toFixed(2) 1149 if (Math.abs(image_ratio - area_ratio) < 0.25) $(this).css({'object-fit': 'cover'}) 1150 } 1151 }) 1152 // SNO Story Element - Story Collection 1153 $('.sno-collection').find('img.scale').each(function () { 1154 var image_ratio = $(this).data('ratio') 1155 var shape = $(this).data('shape'); 1156 var width = $(this).closest('div').width(); 1157 if (shape === undefined) { 1158 var height = $(this).closest('div').height(); 1159 } else { 1160 var height = (shape == 'Horizontal') ? width * .66 : width; 1161 } 1162 if (height != 0 && width != 0) { 1163 var area_ratio = (width / height).toFixed(2) 1164 if (Math.abs(image_ratio - area_ratio) < 0.25) $(this).css({'object-fit': 'cover'}) 1165 } 1166 }) 1167 $('body').on('mouseenter', '.collection-grid.preview-card', function () { 1168 $(this).find('.collection-grid-overlay').css('opacity', 1); 1169 }); 1170 $('body').on('mouseleave', '.collection-grid.preview-card', function () { 1171 $(this).find('.collection-grid-overlay').css('opacity', 0); 1172 }); 1173 1174 // opening up collection 1175 $('body').on('click', '.collection-tile.preview-card, .collection-grid.preview-card, a.collection-title', function () { 1176 const link_type = $(this).closest('.collection-area').data('link-type'); 1177 $('.modal-story-collection').fadeIn(); 1178 if (link_type == 'story') { 1179 var link = $(this).find('a').attr('href') 1180 if (link === undefined) link = $(this).attr('href'); 1181 if (link) { 1182 window.location = link 1183 } 1184 return false;
1185 } else { 1186 var parent_id = $(this).closest('.snopostid').data('post-id'); 1187 if (parent_id === undefined) $parent_id = 0; 1188 var postid = $(this).data('postid'); 1189 if (postid === undefined) postid = $(this).closest('.collection-grid-item-wrap').data('postid'); 1190 var collection = $(this).closest('.collection-area').data('collection-ids') 1191 var collection_title = $(this).closest('.collection-area').data('collection-title') 1192 1193 $.ajax({ 1194 url: frontend_ajax_object.ajaxurl, 1195 type: 'POST', 1196 data: { 1197 action: 'getcollection', 1198 story: postid, 1199 parent_id: parent_id, 1200 collection: collection, 1201 collection_title: collection_title, 1202 1203 }, 1204 success: function (results) { 1205 $('.remodal-collection-inner-container').replaceWith(results) 1206 var scrollDistance = $(document).scrollTop(); 1207 $('#wrap').addClass('lockposition') 1208 $('#wrap').data('scrolled', scrollDistance) 1209 1210 $('.flexslider').animate({opacity: 1}, {duration: 'slow'}) 1211 $('.flex-container').css('background', 'unset') 1212 1213 $('.modal-story-collection').find('#collection-thumbnails').flexslider({ 1214 animation: 'slide', 1215 controlNav: false, 1216 customDirectionNav: $('.modal-story-collection').find('#sfi-thumbnav span'), 1217 animationLoop: true, 1218 slideshow: false, 1219 itemWidth: 300, 1220 itemMargin: 20, 1221 touch: true, 1222 }) 1223 1224 $('.modal-story-collection').find('.infobox-carousel').each(function () { 1225 var infobox_id = $(this).closest('.sno-infobox').data('id'); 1226 $(this).flexslider({ 1227 animation: "slide", 1228 animationLoop: false, 1229 controlNav: true, 1230 customDirectionNav: $('.modal-story-collection').find('.sno-infobox-' + infobox_id + ' .custom-navigation span'), 1231 slideshow: false, 1232 itemMargin: 0, 1233 touch: true, 1234 itemWidth: 800, 1235 minItems: 1, 1236 move: 1, 1237 maxItems: 1 1238 }); 1239 }); 1240 1241 if (typeof initialize_countdown === "function") initialize_countdown(); 1242 if (typeof initialize_polls === "function") initialize_polls(); 1243 if (typeof initialize_quiz === "function") initialize_quiz(); 1244 if (typeof initialize_test === "function") initialize_test(); 1245 if (typeof initialize_sno_infographic === "function") initialize_sno_infographic(); 1246 // if( typeof Ot === "function" ) Ot(); 1247 initialize_flipbooks(); 1248 1249 var thumbAreaWidth = $('.modal-story-collection').find('#collection-thumbnails').width() 1250 var thumbRowWidth = 320 * $('.modal-story-collection').find('#collection-thumbnails li').length 1251 if (thumbRowWidth < thumbAreaWidth) { 1252 $('.modal-story-collection').find('.sfi-thumbnails').width(thumbRowWidth) 1253 } 1254 setTimeout(function () { 1255 check_thumbnail_nav(postid) 1256 }, 333) 1257 1258 }, 1259 }) 1260 return false; 1261 } 1262 }) 1263 1264 function check_thumbnail_nav(postid) { 1265 if ($('.sfi-thumb[data-postid="' + postid + '"]').offset().left < 0) { 1266 $('.sfi-thumb-navigation-area .flex-prev').trigger('click') 1267 } else if ($('.sfi-thumb[data-postid="' + postid + '"]').offset().left + $('.sfi-thumb[data-
1267postid="' + postid + '"]').width() > $(document).width()) { 1268 $('.sfi-thumb-navigation-area .flex-next').trigger('click') 1269 } 1270 } 1271 1272 // selecting a new story in an open collection 1273 $('body').on('click', '#collection-thumbnails .sfi-thumb', function () { 1274 postid = $(this).data('postid') 1275 getCollectionStory(postid) 1276 }) 1277 1278 $('body').on('click', '.modal-story-collection .slideshow_left, .modal-story-collection .slideshow_right', function () { 1279 const current = $('.collection-viewer-body').data('visible-story') 1280 var collection = $('.sfi-thumb-navigation-area li.sfi-thumb').map(function () { 1281 return $(this).data('postid'); 1282 }).get(); 1283 1284 if ($(this).hasClass('slideshow_right')) collection = collection.reverse() 1285 const first = collection[0]; 1286 const last = collection[collection.length - 1]; 1287 var prev = 0; 1288 var postid = 0; 1289 $.each(collection, function (index, value) { 1290 if (value == first && value == current) { 1291 postid = last; 1292 } else if (value == current) { 1293 postid = prev; 1294 } 1295 prev = value; 1296 }); 1297 getCollectionStory(postid) 1298 check_thumbnail_nav(postid) 1299 1300 // scroll the thumbnail navigation if newly clicked story is offscreen 1301 }); 1302 1303 function getCollectionStory(postid) { 1304 $('.collection-viewer-transition').addClass('collection-viewer-transition-active'); 1305 $('.sfi-thumb').removeClass('active-story'); 1306 $('.sfi-thumb[data-postid="' + postid + '"]').addClass('active-story'); 1307 $.ajax({ 1308 url: frontend_ajax_object.ajaxurl, 1309 type: 'POST', 1310 data: { 1311 action: 'getcollectionstory', 1312 story: postid, 1313 }, 1314 success: function (results) { 1315 $('.collection-viewer-body').replaceWith(results) 1316 $('.collection-viewer-wrap').scrollTop(0); 1317 $('.collection-viewer-transition').removeClass('collection-viewer-transition-active'); 1318 $('.modal-story-collection').find('.infobox-carousel').each(function () { 1319 var infobox_id = $(this).closest('.sno-infobox').data('id'); 1320 $(this).flexslider({ 1321 animation: "slide", 1322 animationLoop: false, 1323 controlNav: true, 1324 customDirectionNav: $('.modal-story-collection').find('.sno-infobox-' + infobox_id + ' .custom-navigation span'), 1325 slideshow: false, 1326 itemMargin: 0, 1327 touch: true, 1328 itemWidth: 800, 1329 minItems: 1, 1330 move: 1, 1331 maxItems: 1 1332 }); 1333 $(this).css('opacity', '1'); 1334 }); 1335 if (typeof initialize_countdown === "function") initialize_countdown(); 1336 if (typeof initialize_polls === "function") initialize_polls(); 1337 if (typeof initialize_quiz === "function") initialize_quiz(); 1338 if (typeof initialize_test === "function") initialize_test(); 1339 if (typeof initialize_sno_infographic === "function") initialize_sno_infographic(); 1340 // if( typeof Ot === "function" ) Ot(); 1341 initialize_flipbooks(); 1342 }, 1343 }) 1344 } 1345 1346 1347 // closing collections 1348 $('body').on('click', '.modal-story-collection .sfi-return-to-story, .modal-story-collection .sno-overlay-close', function () { 1349 $('#wrap').removeClass('lockposition') 1350 $(document).scrollTop($('#wrap').data('scrolled')); 1351 $(this).closest('.modal-story-collection').fadeOut(); 1352 setTimeout(function () { 1353 $('.collection-viewer-body').fadeOut(); 1354 $('#collection-thumbnails').fadeOut(); 1355 }, 1000) 1356 }); 1357 1358 // function to initialize any flipbooks found in collection stories 1359 function initialize_flipbooks() {
1360 canvases = jQuery("body").find(".sno-pdf-flipbook-canvas") 1361 canvases.each(function () { 1362 const flipbook = jQuery(this).find("#sno-flipbook") 1363 const width = flipbook.data("width") 1364 const aspect_ratio = flipbook.data("aspect-ratio") 1365 const arrowLeft = jQuery(this).find(".sno-flipbook-arrow-left") 1366 const arrowRight = jQuery(this).find(".sno-flipbook-arrow-right") 1367 flipbook.turn({ 1368 width: width - 62, 1369 height: (width - 62) / aspect_ratio, 1370 elevation: 50, 1371 gradients: false, 1372 autoCenter: true, 1373 }) 1374 flipbook.bind("turning", function (_event, page) { 1375 const atFirstPage = page == 1 1376 const atLastPage = page == jQuery(this).turn("pages") 1377 if (atFirstPage) { 1378 arrowLeft.addClass("disabled") 1379 } else { 1380 arrowLeft.removeClass("disabled") 1381 } 1382 if (atLastPage) { 1383 arrowRight.addClass("disabled") 1384 } else { 1385 arrowRight.removeClass("disabled") 1386 } 1387 }) 1388 flipbook.addClass("animated") 1389 arrowLeft.click(function () { 1390 flipbook.turn("previous") 1391 }) 1392 arrowRight.click(function () { 1393 flipbook.turn("next") 1394 }) 1395 window.addEventListener("keydown", (ev) => { 1396 if (ev.key == "ArrowLeft") flipbook.turn("previous") 1397 if (ev.key == "ArrowRight") flipbook.turn("next") 1398 }) 1399 }) 1400 } 1401 1402 // social icons hover effects 1403 $('.sno-row-icon').on('mouseenter', function () { 1404 const hover_style = $(this).closest('.sno-row-icons').data('hover-style'); 1405 const mono = $('.snodo-template-group:visible').find('.icons-mono-color input').val(); 1406 switch (hover_style) { 1407 case 'Full Color': 1408 $(this).addClass('hover-full-color'); 1409 break; 1410 case 'Full Color Inverse': 1411 $(this).addClass('hover-full-color-inverse'); 1412 break; 1413 case 'Monochromatic': 1414 $(this).addClass('monochromatic'); 1415 break; 1416 case 'Monochromatic Inverse': 1417 $(this).addClass('monochromatic-inverse'); 1418 break; 1419 } 1420 }); 1421 $('body').on('mouseleave', '.sno-row-icon', function () { 1422 $(this).removeClass('hover-full-color hover-full-color-inverse monochromatic monochromatic-inverse'); 1423 }); 1424 1425 if ($('#wrap').data('post-template') == 'fulltop' || $('#wrap').data('post-template') == 'split') { 1426 $('.sno-story-media-area-fade').fadeOut('slow'); 1427 1428 $('.sno-row-icons').hide(); 1429 $(window).scroll(function () { 1430 if ($(this).scrollTop() > $(window).height() / 2) { 1431 $('.sno-row-icons').fadeIn(); 1432 } else { 1433 $('.sno-row-icons').fadeOut(); 1434 } 1435 }); 1436 var wp_adminbar = ($('#wpadminbar').length > 0 && $('#wpadminbar').is(':visible')) ? $('#wpadminbar').height() : 0; 1437 1438 $('#jump-arrow').click(function () { 1439 var header_height = ($('.sno-header-wrap:visible').length) ? $('.sno-header-wrap:visible').height() : 0; 1440 if ($('.sno-story-fulltop-container').length) { 1441 $('html, body').animate({scrollTop: $('.sno-story-fulltop-container').offset().top - wp_adminbar - header_height}, 500) 1442 } 1443 if ($('.sno-story-split-header-area').length) { 1444 $('html, body').animate({scrollTop: $('.sno-story-split-header-area').offset().top - wp_adminbar - header_height}, 500) 1445 } 1446 $('#jump-arrow').fadeOut() 1447 return false 1448 }) 1449 1450 jQuery(window).scroll(function () { 1451 if (jQuery(this).scrollTop() > jQuery(window).height()) { 1452 jQuery('#jump-arrow').fadeOut() 1453 } else { 1454 jQuery('#jump-arrow').fadeIn() 1455 } 1456 }); 1457 $('.sno-story-split-image-area').on('mouseenter', function () { 1458 $(this).find('.fullphoto-overlay').fadeIn(); 1459 }); 1460 $('.sno-story-split-image-area').on('mouseleave', function () { 1461 $(this).find('.fullphoto-overlay').fadeOut(); 1462 }); 1463 1464 } else { 1465 $('.sno-row-icons').fadeIn(); 1466 } 1467 1468}); 1469 1470// carousel adjustment for mobile 1471jQuery(document).ready(function ($) { 1472 if ($(window).width() < 600) { 1473 $('.carousel-widget-slide-beside').width($(window).width() - 20) 1474 } 1475}) 1476 1477// snoAds integration 1478jQuery(document).ready(function ($) { 1479 if ($('.snods_footer').length) { 1480 var spot_id = $('.snods_footer').first().data('spot_id') 1481 var fill = $('.snods_footer').first().data('fill') 1482 var sno_client_id = $('.snods_footer').first().data('sno_client_id') 1483 var url = 'https://snoads.com/api/v1/adspot/' + spot_id + '/serve' 1484 jQuery.get(url, '', function (response) { 1485 if (response && response.link != null && response.image != null) { 1486 $('.footerboardwrap .footerimage') 1487 .filter(':visible') 1488 .html( 1489 '<a target="_blank" href="' + 1490 response.link + 1491 '" class="sno-spot" data-spot-id="' + 1492 response.id + 1493 '"><img src="' +
1494 response.image + 1495 '" alt="Related Content" /></a>' 1496 ) 1497 } else { 1498 let rand_num = Math.floor(Math.random() * 2 + 1) 1499 $('.footerboardwrap .footerimage') 1500 .filter(':visible') 1501 .html( 1502 `<img tabindex="0" aria-label="Additional Content" class="sno-fill" src="https://snoadfills.s3.us-west-2.amazonaws.com/fill-728x90-v${rand_num}.png" alt="Related Content"/>` 1503 ) 1504 } 1505 }).fail(() => { 1506 if (fill) { 1507 $('.footerboardwrap .footerimage') 1508 .filter(':visible') 1509 .html('<img tabindex="0" aria-label="Additional Content" class="sno-fill" src="' + fill + '" alt="Related Content"/>') 1510 } else { 1511 let rand_num = Math.floor(Math.random() * 2 + 1) 1512 $('.footerboardwrap .footerimage') 1513 .filter(':visible') 1514 .html( 1515 `<img tabindex="0" aria-label="Additional Content" class="sno-fill" src="https://snoadfills.s3.us-west-2.amazonaws.com/fill-728x90-v${rand_num}.png" alt="Related Content"/>` 1516 ) 1517 } 1518 }) 1519 1520 $('.footerimage').on('click', '.sno-spot', function () { 1521 let ad_id = $(this).data('spot-id') 1522 var url = 'https://snoads.com/api/v1/ad/' + ad_id + '/click' 1523 jQuery.post(url, '', function (response) { 1524 }) 1525 }) 1526 1527 $('.footerimage').on('click', '.sno-fill', function () { 1528 const url = `https://snoads.com/marketplace?site=${sno_client_id}` 1529 window.open(url, '_blank') 1530 }) 1531 } 1532}) 1533 1534jQuery(document).ready(function ($) { 1535 1536 if ($('.footer .snoads-unplaced').length) { 1537 if ($('.footer .snoads-unplaced').closest('.sno-designer-area-row').next('.sno-designer-area-row').hasClass('sno-designer-row-fullscreen')) { 1538 $('.footer .snoads-unplaced').addClass('sno-designer-row-fullscreen'); 1539 } 1540 } 1541 1542 if ($('.sno-header-wrap .snoads-unplaced').length) { 1543 if ($('.sno-header-wrap .snoads-unplaced').closest('.sno-designer-area-row').next('.sno-designer-area-row').hasClass('sno-designer-row-fullscreen')) { 1544 const bg_color = $('.sno-header-wrap .snoads-unplaced').closest('.sno-designer-area-row').next('.sno-designer-area-row').css("background-color") 1545 $('.sno-header-wrap .snoads-unplaced').closest('.sno-designer-area-row').css({'background-color': bg_color + '!important'}) 1546 } 1547 } 1548 1549}); 1550 1551 1552jQuery(document).ready(function ($) { 1553 if ($('.snods_sidebar').length) { 1554 var spot_id = $('.snods_sidebar').first().data('spot_id') 1555 var fill = $('.snods_sidebar').first().data('fill') 1556 var sno_ads_id = $('.snods_sidebar').first().data('sno_client_id') 1557 1558 var url = 'https://snoads.com/api/v1/adspot/' + spot_id + '/serve' 1559 jQuery.get(url, '', function (response) { 1560 if (response && response.link != null && response.image != null) { 1561 $('.sidebarimage') 1562 .filter(':visible') 1563 .html( 1564 '<a target="_blank" href="' + 1565 response.link + 1566 '" class="sno-spot" data-spot-id="' + 1567 response.id + 1568 '"><img src="' + 1569 response.image + 1570 '" alt="Related Content" /></a>' 1571 ) 1572 } else { 1573 let rand_num = Math.floor(Math.random() * 2 + 1) 1574 $('.sidebarimage') 1575 .filter(':visible') 1576 .html( 1577 `<img tabindex="0" aria-label="Additional Content" class="sno-fill" src="https://snoadfills.s3.us-west-2.amazonaws.com/fill-300x250-v${rand_num}.png" alt="Related Content"/>` 1578 ) 1579 } 1580 }).fail(() => { 1581 if (fill) { 1582 $('.sidebarimage') 1583 .filter(':visible') 1584 .html('<img tabindex="0" aria-label="Additional Content"
1584class="sno-fill" src="' + fill + '" alt="Related Content" />') 1585 } else { 1586 let rand_num = Math.floor(Math.random() * 2 + 1) 1587 $('.sidebarimage') 1588 .filter(':visible') 1589 .html( 1590 `<img tabindex="0" aria-label="Additional Content" class="sno-fill" src="https://snoadfills.s3.us-west-2.amazonaws.com/fill-300x250-v${rand_num}.png" alt="Related Content"/>` 1591 ) 1592 } 1593 }) 1594 $('.sidebarimage').on('click', '.sno-spot', function () { 1595 let ad_id = $(this).data('spot-id') 1596 var url = 'https://snoads.com/api/v1/ad/' + ad_id + '/click' 1597 jQuery.post(url, '', function (response) { 1598 }) 1599 }) 1600 1601 $('.sidebarimage').on('click', '.sno-fill', function () { 1602 const url = `https://snoads.com/marketplace?site=${sno_ads_id}` 1603 window.open(url, '_blank') 1604 }) 1605 } 1606}) 1607 1608jQuery(document).ready(function ($) { 1609 if ($('.snods_leaderboard').length) { 1610 var spot_id = $('.snods_leaderboard').first().data('spot_id') 1611 var fill = $('.snods_leaderboard').first().data('fill') 1612 var sno_ads_id = $('.snods_leaderboard').first().data('sno_client_id') 1613 1614 var url = 'https://snoads.com/api/v1/adspot/' + spot_id + '/serve' 1615 jQuery.get(url, '', function (response) { 1616 if (response && response.link != null && response.image != null) { 1617 $('.leaderboardimage') 1618 .filter(':visible') 1619 .html( 1620 '<a target="_blank" href="' + 1621 response.link + 1622 '" class="sno-spot" data-spot-id="' + 1623 response.id + 1624 '"><img src="' + 1625 response.image + 1626 '" alt="Related Content" /></a>' 1627 ) 1628 } else { 1629 let rand_num = Math.floor(Math.random() * 2 + 1) 1630 $('.leaderboardimage') 1631 .filter(':visible') 1632 .html( 1633 `<img tabindex="0" aria-label="Additional Content" class="sno-fill" src="https://snoadfills.s3.us-west-2.amazonaws.com/fill-728x90-v${rand_num}.png" alt="Related Content"/>` 1634 ) 1635 } 1636 }).fail(() => { 1637 if (fill) { 1638 $('.leaderboardimage') 1639 .filter(':visible') 1640 .html('<img tabindex="0" aria-label="Additional Content" class="sno-fill" src="' + fill + '" alt="Related Content" />') 1641 } else { 1642 let rand_num = Math.floor(Math.random() * 2 + 1) 1643 $('.leaderboardimage') 1644 .filter(':visible') 1645 .html( 1646 `<img tabindex="0" aria-label="Additional Content" class="sno-fill" src="https://snoadfills.s3.us-west-2.amazonaws.com/fill-728x90-v${rand_num}.png" alt="Related Content"/>` 1647 ) 1648 } 1649 }) 1650 $('.leaderboardimage').on('click', '.sno-spot', function () { 1651 let ad_id = $(this).data('spot-id') 1652 var url = 'https://snoads.com/api/v1/ad/' + ad_id + '/click' 1653 jQuery.post(url, '', function (response) { 1654 }) 1655 }) 1656 1657 $('.leaderboardimage').on('click', '.sno-fill', function () { 1658 // url = 'https://snoads.com/marketplace/' + sno_ads_id 1659 const url = `https://snoads.com/marketplace?site=${sno_ads_id}` 1660 window.open(url, '_blank') 1661 }) 1662 } 1663}) 1664 1665// scrollToFixed for header elements 1666jQuery(function ($) { 1667 var fixed_element_adjustment = $('#wpadminbar').length && $('#wpadminbar').is(':visible') ? $('#wpadminbar').outerHeight() : 0 1668 var stick_height = 0 1669 $('.sno-header-row-stick:visible').each(function () { 1670 $(this).scrollToFixed({ 1671 marginTop: fixed_element_adjustment + stick_height, 1672 spacerClass: 'topheaderspacer', 1673 zIndex: 2, 1674 position: 'relative' 1675 }) 1676 stick_height += $(this).height() 1677 }) 1678 var bottom_stick_height = 0 1679 $($('.footer .sno-footer-row-stick:visible').get().reverse()).each(function () { 1680 var row = this 1681 $(this).scrollToFixed({ 1682 bottom: bottom_stick_height, 1683 limit: $(row).offset().top, 1684 }) 1685 bottom_stick_height += $(this).height() 1686 }) 1687}) 1688 1689// If a draft is being displayed via query string, append all hyperlinks on the page with the query string to keep the user in the draft as they click through the site 1690jQuery(function ($) { 1691 $(document).ready(function () { 1692 if ($('.sno-viewing-draft-notice').length) { 1693 $('a').each(function () { 1694 if ($(this).hasClass('draft-live')) return 1695 if ($(this).closest('#wpadminbar').length) return 1696 if ($(this).attr('href').indexOf($('.sno-viewing-draft-notice').data('url')) > 0) { 1697 var joiner = ($(this).attr('href').includes('?')) ? '&' : '?'; 1698 $(this).attr('href', $(this).attr('href') + joiner + 'draft=' + $('.sno-viewing-draft-notice').data('draft-id')) 1699 } 1700 }) 1701 } else if (window.location.href.indexOf("draft=live") > -1) { 1702 $('a').each(function () { 1703 if ($(this).closest('#wpadminbar').length) return 1704 var joiner = ($(this).attr('href').includes('?')) ? '&' : '?'; 1705 $(this).attr('href', $(this).attr('href') + joiner + 'draft=live') 1706 }) 1707 } 1708 }) 1709}) 1710 1711jQuery(function ($) { 1712 1713 $('body').on('keydown', '.back-to-list', function (e) { 1714 if (!$('.return-focus-to-item').length) return; 1715 e.preventDefault(); 1716 $('.return-focus-to-item').focus(); 1717 $('.return-focus-to-item').removeClass('return-focus-to-item') 1718 $('ul.menu-with-teasers a').attr('tabindex', '0') 1719 }); 1720 1721 $('ul.menu-with-teasers').on('keyup', function (event) { 1722 if (event.key === 'Tab' || event.keyCode === 9) { 1723 if ($(event.target).hasClass('sf-with-ul')) return; 1724 1725 var visibleCards = $(event.target).closest('ul').find('.menu-ta-wrap .sno-menu-card:visible'); 1726 if (!visibleCards.length) return; 1727 var lastVisibleCard = visibleCards.last(); 1728 var lastLink = lastVisibleCard.find('a'); 1729 $(lastLink).addClass('last-menu-teaser-headline'); 1730 if ($(event.target).hasClass('last-menu-teaser-headline')) { 1731 $(event.target).addClass('back-to-list') 1732 $('.return-focus-to-item').attr('tabindex', '0') 1733 1734 } else { 1735 var allLinks = $(event.target).closest('li.menu-item-has-children').find('ul li > a'); 1736 var unfocusedLinks = allLinks.filter(function () { 1737 return this !== document.activeElement; 1738 }); 1739 var tabindex = '0'; 1740 var nextlink = false;
1741 allLinks.each(function (i, link) { 1742 $(link).attr('tabindex', tabindex) 1743 if (nextlink == true) { 1744 $(link).addClass('return-focus-to-item'); 1745 nextlink = false; 1746 } 1747 if (link == document.activeElement) { 1748 tabindex = '-1'; 1749 nextlink = true; 1750 } 1751 }) 1752 } 1753 } 1754 }); 1755 1756 // show teasers for selected menus on hover of category or via focus from tabbing 1757 $('body').on('focus', 'ul.menu-with-teasers .menu-item-object-category a, ul.menu-with-teasers .menu-item-object-page a', function () { 1758 load_menu_teasers($(this).closest('li')); 1759 }) 1760 1761 $('body').on('mouseenter', 'ul.menu-with-teasers .menu-item-object-category, ul.menu-with-teasers .menu-item-object-page', function () { 1762 load_menu_teasers($(this)); 1763 }) 1764 1765 function load_menu_teasers(triggerDiv) { 1766 var menu_object_id = '' 1767 $.each($(triggerDiv).attr('class').split(' '), function (index, value) { 1768 if (/\d/.test(value) == true) { 1769 menu_object_id = value.replace('menu-item-', '') 1770 return 1771 } 1772 }) 1773 1774 if (menu_object_id == '') return 1775 1776 $('.menu-ta-inner').empty() 1777 $('.menu-ta-inner').hide() 1778 if ($(triggerDiv).find('.menu-ta-inner').length) { 1779 $(triggerDiv) 1780 .find('.menu-ta-inner') 1781 .append( 1782 $(triggerDiv) 1783 .closest('.sno-designer-area-container') 1784 .find('.sub-menu-teaser-display-' + menu_object_id) 1785 .clone() 1786 .hide() 1787 ) 1788 } else { 1789 $(triggerDiv) 1790 .siblings('li') 1791 .last() 1792 .find('.menu-ta-inner') 1793 .append( 1794 $(triggerDiv) 1795 .closest('.sno-designer-area-container') 1796 .find('.sub-menu-teaser-display-' + menu_object_id) 1797 .clone() 1798 .hide() 1799 ) 1800 } 1801 $('.menu-ta-inner').fadeIn('slow') 1802 $('.sub-menu .sub-menu-teaser-display-' + menu_object_id).fadeIn() 1803 $(triggerDiv) 1804 .find('img.scale') 1805 .each(function () { 1806 var image_ratio = $(triggerDiv).data('ratio') 1807 var width = 220 // this is an approximation 1808 var height = $(triggerDiv).closest('.sno-story-card-photo-wrap').height() 1809 if (height != 0 && width != 0) { 1810 var area_ratio = (height / width).toFixed(2) 1811 if (Math.abs(image_ratio - area_ratio) < 0.25) $(triggerDiv).css({'object-fit': 'cover'}) 1812 } 1813 }) 1814 } 1815 1816 // adjust menu markup for menus that have teasers enabled 1817 function prepare_menus_with_teasers(menu) { 1818 // special adjustments for the More menu item 1819 $(menu) 1820 .find('ul.menu-with-teasers') 1821 .find('li.menu-more-item-top') 1822 .find('ul.sub-menu') 1823 .each(function () { 1824 $(this).closest('li').removeClass('menu-item-has-children') 1825 $(this).closest('li').find('a').removeClass('sf-with-ul') 1826 //$(this).remove() // this was removing nested dropdowns from teaser based menus under the more tab. commenting out should restore those. 1827 }) 1828 // removing the ability for the More Menu to have category teasers display -- unless I can figure out how to have one of them display by default 1829 /* 1830 $(menu).find('ul.menu-with-teasers').find('ul.sno-hac-menu-more').each(function() { 1831 $('<li class="menu-ta-wrap"><div class="menu-ta"><div class="menu-ta-inner">Insertion Point</div></div><div class="clear"></div></li>').insertAfter($(this).find('li').last()); 1832 $('.menu-teaser-insertion').replaceWith() 1833 }); 1834 */ 1835 $(menu) 1836 .find('ul.menu-with-teasers > li.menu-item-object-category') 1837 .find('ul.sub-menu') 1838 .each(function () { 1839 if ($(this).find('li.menu-item-object-category').length || $(this).closest('li.menu-item-object-category').length) {
1840 $(this).closest('li').addClass('sub-menu-teasers') 1841 $( 1842 '<li class="menu-ta-wrap"><div class="menu-ta"><div class="menu-ta-inner"></div></div><div class="clear"></div></li>' 1843 ).insertAfter($(this).find('li').last()) 1844 } 1845 }) 1846 $(menu) 1847 .find('ul.menu-with-teasers > li.menu-item-object-page') 1848 .find('ul.sub-menu') 1849 .each(function () { 1850 var menu_object_id = '' 1851 $.each($(this).closest('li').attr('class').split(' '), function (index, value) { 1852 if (/\d/.test(value) == true) { 1853 menu_object_id = value.replace('menu-item-', '') 1854 return 1855 } 1856 }) 1857 if ( 1858 $(this) 1859 .closest('.sno-designer-area-container') 1860 .find('.sub-menu-teaser-display-' + menu_object_id).length < 1 1861 ) 1862 return 1863 $(this).closest('li').addClass('sub-menu-teasers') 1864 $('<li class="menu-ta-wrap"><div class="menu-ta"><div class="menu-ta-inner"></div></div><div class="clear"></div></li>').insertAfter( 1865 $(this).find('li').last() 1866 ) 1867 }) 1868 $(menu) 1869 .find('ul.menu-with-teasers > li.menu-item-object-category, ul.menu-with-teasers > li.menu-item-object-page') 1870 .each(function () { 1871 if ($(this).find('ul').length) return 1872 if ($(this).hasClass('menu-item-object-page')) { 1873 var menu_object_id = '' 1874 $.each($(this).attr('class').split(' '), function (index, value) { 1875 if (/\d/.test(value) == true) { 1876 menu_object_id = value.replace('menu-item-', '') 1877 return 1878 } 1879 }) 1880 if ( 1881 $(this) 1882 .closest('.sno-designer-area-container') 1883 .find('.sub-menu-teaser-display-' + menu_object_id).length < 1 1884 ) 1885 return 1886 } 1887 $(this).addClass('sub-menu-teasers') 1888 $(this).append( 1889 '<ul class="sub-menu"><li class="menu-ta-wrap"><div class="menu-ta-full"><div class="menu-ta-inner"></div></div><div class="clear"></div></li></ul>' 1890 ) 1891 }) 1892 } 1893 1894 // if menus have too many items in them, collapse the extras into an extra tab under "More" 1895 function hide_extra_menu_items(menu) { 1896 var max_width = $(menu).width() 1897 var total_width = 0 1898 $(menu) 1899 .find('ul.sf-menu > li') 1900 .each(function () { 1901 total_width += $(this).outerWidth() 1902 total_width += 4 1903 if ($(this).find('ul').length) { 1904 total_width += 12 // account for drop down arrows 1905 } 1906 }) 1907 1908 if (total_width > max_width) { 1909 $(menu).find('ul.sno-menu-more').show() 1910 $(menu).find('ul.sno-hac-menu-more').show() 1911 var menu_ul_id = $(menu).find('ul').first().attr('id') 1912 var more_button_width = $(menu).find('li.menu-more-item-top').width() 1913 total_width += more_button_width 1914 1915 $($(menu).find('ul.sf-menu > li').get().reverse()).each(function () { 1916 var li_width = $(this).outerWidth() 1917 $(this).addClass('sub-menu more-menu-item') 1918 $(this).prependTo($(menu).find('ul.sno-hac-menu-more')) 1919 total_width -= li_width 1920 if (total_width + 15 < max_width) return false // the 15 is just an added buffer 1921 }) 1922 1923 $(menu).find('ul.sno-menu-more').addClass('sf-menu').superfish() 1924 $(menu) 1925 .find('.menu-more-item-top') 1926 .appendTo('#' + menu_ul_id) 1927 } else { 1928 $(menu).find('ul.sno-menu-more').remove() 1929 } 1930 1931 $(menu).css({'overflow-y': 'unset'}) 1932 1933 if ($(window).width() > 800) prepare_menus_with_teasers(menu) 1934 } 1935 1936 // hide extra menu items in the more tab on load 1937 $(document).ready(function () { 1938 $('.sno-hac-menuwrap, .sno-classic-menuwrap').each(function () { 1939 if ($('.sno-story-template-fulltop').length) return true; 1940 if ($('.sno-story-fulltop-container').length) return true; 1941 if ($('.sno-story-template-split').length) return true; 1942 hide_extra_menu_items(this) 1943 }) 1944 }) 1945 1946 // open up search bar when search icon is clicked 1947 $(document).ready(function () { 1948 $('body').on('click', '.sno-hac-search-icon', function () { 1949 $(this).find('i').toggleClass('fa-search fa-times') 1950 $('.sno-hac-hamburger-menu').hide() 1951 const hidden = ($('.sno-hac-search-icon-bar-' + $(this).data('id')).is(':hidden')) ? true : false;
1952 $('.sno-hac-search-icon-bar-' + $(this).data('id')).fadeToggle() 1953 if (hidden === true) { 1954 $('.sno-hac-search-icon-bar-' + $(this).data('id')).find('input.hac-search').focus() 1955 } 1956 }) 1957 }) 1958 1959 // open up menu when hamburger icon is clicked 1960 $(document).ready(function () { 1961 $('body').on('click', '.sno-hac-menu-icon', function () { 1962 // $(this).find('i').toggleClass('fa-bars fa-times') 1963 $('.sno-hac-search-icon-bar').hide() 1964 var menu = $('.sno-hac-hamburger-menu-' + $(this).data('menu-id')) 1965 menu.fadeToggle() 1966 if ($(this).hasClass('sno-hac-menu-side')) { 1967 restrictFocusToMenu(menu) 1968 } 1969 if ($(window).width() > 800 && !$(this).hasClass('sno-hac-menu-side')) { 1970 hide_extra_menu_items(menu) 1971 } else { 1972 $(menu).find('.sf-menu').superfish('destroy') 1973 $('.sno-side-icons').fadeOut(); 1974 if ($('#wpadminbar').length && $('#wpadminbar').is(':visible')) $(this).closest('.sno-designer-area-container').find('.sno-hac-hamburger-menu').css('top', '32px'); 1975 } 1976 $(this).attr('aria-expanded', 'true'); 1977 }) 1978 }) 1979 1980 function restrictFocusToMenu(menu) { 1981 let lastFocusableElement; 1982 const firstFocusableElement = $(menu).find('.sno-hac-menu-mobile-close'); 1983 1984 function updateFocusableElements() { 1985 // Update first and last focusable elements 1986 lastFocusableElement = $(menu).find('li:visible a:visible').last(); 1987 } 1988 1989 // Initialize focusable elements when the modal opens 1990 setTimeout(function () { 1991 updateFocusableElements(); 1992 }, 1000) 1993 1994 jQuery(menu).on('keydown', function (event) { 1995 updateFocusableElements(); 1996 const isTabPressed = (event.key === 'Tab' || event.keyCode === 9); 1997 if (!isTabPressed) { 1998 return; 1999 } 2000 if (event.shiftKey) { // Shift + Tab 2001 if (document.activeElement === firstFocusableElement[0] || document.activeElement === $(firstFocusableElement[0]).closest('li').get(0)) { 2002 lastFocusableElement.focus(); 2003 event.preventDefault(); 2004 } 2005 } else { // Tab 2006 if (document.activeElement === lastFocusableElement[0] || document.activeElement === $(lastFocusableElement[0]).closest('li').get(0)) { 2007 firstFocusableElement.focus(); 2008 event.preventDefault(); 2009 } 2010 } 2011 }); 2012 2013 } 2014 2015 $('.sno-hac-menu-wrap li > a').on('click', function (e) { 2016 if ($(this).siblings('ul').length) { 2017 if ($(this).siblings('ul').is(':visible')) { 2018 } else { 2019 $(this).siblings('ul').slideDown() 2020 $(this).addClass('sno-menu-expanded') 2021 e.preventDefault() 2022 } 2023 } 2024 }) 2025 2026 $('body').on('click', '.sno-hac-menu-mobile-close', function () { 2027 $(this).closest('.sno-hac-hamburger-menu').fadeOut() 2028 $('.sno-side-icons').fadeIn(); 2029 $('.sno-hac-menu-icon').attr('aria-expanded', 'false') 2030 // $('#wpadminbar').css('z-index', '2000') 2031 }) 2032}) 2033 2034// news tickers for header area 2035jQuery(function ($) { 2036 function marquee(a, b, speed, con_width) { 2037 var width = b.width() 2038 if (width < 0) { 2039 b.hide(); 2040 return; 2041 } 2042 var start_pos = con_width 2043 var end_pos = -width 2044 2045 function scroll() { 2046 if (b.position().left <= -width + 1) { 2047 b.css('left', start_pos) 2048 scroll() 2049 } else { 2050 var min_width = width < con_width ? con_width : width 2051 time = min_width / speed 2052 b.animate( 2053 { 2054 left: -width, 2055 }, 2056 time, 2057 'linear', 2058 function () { 2059 scroll() 2060 } 2061 ) 2062 } 2063 } 2064 2065 b.css({ 2066 width: width, 2067 left: start_pos, 2068 }) 2069 scroll(a, b) 2070 2071 // pause on hover 2072 b.mouseenter(function () { 2073 b.stop() 2074 b.clearQueue() 2075 }) 2076 b.mouseleave(function () { 2077 scroll(a, b) 2078 }) 2079 2080 // pause marquee when browser tab isn't visible to prevent excessive animations 2081 document.addEventListener('visibilitychange', function (ev) { 2082 if (document.visibilityState == 'hidden') { 2083 b.stop() 2084 b.clearQueue() 2085 } else { 2086 scroll(a, b) 2087 } 2088 }) 2089
2090 // pause marquee when focus is within the parent container 2091 let focusInMarquee = false; 2092 2093 function checkFocusInParent(parentDiv) { 2094 if (parentDiv.contains(document.activeElement)) { 2095 if (focusInMarquee == false) { 2096 const actualParentDiv = $(parentDiv).closest('.simple-marquee-container')[0]; 2097 $(actualParentDiv).find('.marquee-sibling').attr('tabindex', '0'); 2098 b.stop(); 2099 b.clearQueue(); 2100 } 2101 focusInMarquee = true; 2102 } else { 2103 if (focusInMarquee == true) { 2104 focusInMarquee = false; 2105 const currentFocus = a[0]; 2106 const currentMarquee = currentFocus.closest('.simple-marquee-container').querySelector('.marquee-sibling'); 2107 2108 $('.marquee-sibling').focus() 2109 marquee(a, b, speed, con_width) 2110 focusNextElement(currentMarquee) 2111 } 2112 } 2113 } 2114 2115 const parentDiv = a[0]; 2116 const parentMarquee = parentDiv.closest('.simple-marquee-container').querySelector('.marquee-content-items'); 2117 document.addEventListener('focusin', function () { 2118 checkFocusInParent(parentMarquee); 2119 }); 2120 2121 function focusNextElement(currentDiv) { 2122 // Get all tabbable elements on the page 2123 const tabbableElements = Array.from(document.querySelectorAll('a, button, input, textarea, select, [tabindex]:not([tabindex="-1"])')) 2124 .filter(el => !el.disabled && el.offsetParent !== null); 2125 2126 // Find the index of the currently focused element 2127 const currentIndex = tabbableElements.indexOf(currentDiv); 2128 2129 // Focus the next element if it exists 2130 if (currentIndex > -1 && currentIndex < tabbableElements.length - 1) { 2131 tabbableElements[currentIndex + 1].focus(); 2132 } 2133 } 2134 2135 } 2136 2137 2138 $(document).ready(function () { 2139 $('.simple-marquee-container:visible').each(function () { 2140 if ($(this).data('activate') == true) { 2141 if ($(this).find('.marquee-sibling').length) { 2142 var marquee_width = $(this).width() - $(this).find('.marquee-sibling').width() 2143 } else { 2144 var marquee_width = $(this).width() 2145 } 2146 marquee($(this).find('.marquee'), $(this).find('.marquee-content-items'), $(this).find('.marquee').data('speed'), marquee_width) 2147 } else { 2148 var left_padding = $(this).find('.marquee-sibling').outerWidth() + 20 2149 $(this) 2150 .find('.marquee') 2151 .css({'padding-left': left_padding + 'px'}) 2152 } 2153 $(this).find('li').css('opacity', 1) 2154 }) 2155 }) 2156}) 2157 2158// staff profile adjust vertical text centering if text is too tall for area 2159jQuery(document).ready(function ($) { 2160 if ($(window).width() > 600) { 2161 var staff_pic_height = $('.profile-panel-media img').height() 2162 if (staff_pic_height) { 2163 var staff_text_height = $('.profile-textarea-inner').height() 2164 if (staff_pic_height < staff_text_height) { 2165 $('.profile-textarea-with-media').removeClass('sno-center-v-outer') 2166 $('.profile-textarea-inner').removeClass('sno-center-v') 2167 } 2168 } 2169 } 2170 $('.sno-profile-fade').css({position: 'relative'}) 2171 $('.sno-profile-fade').animate({opacity: 1, position: 'relative'}) 2172}) 2173 2174// make photos and continue links clickable on category tile views 2175jQuery(document).ready(function () { 2176 jQuery('body').on('click', '.sno-tile-clickable', function () { 2177 var link = jQuery(this).find('a.homeheadline').attr('href') 2178 if (link) { 2179 window.location = link 2180 } 2181 }) 2182 2183 jQuery('body').on('click', '.sno-tile-clickable', function () { 2184 var photo = jQuery(this).find('a').data('photo-id') 2185 if (photo) { 2186 jQuery.ajax({ 2187 url: frontend_ajax_object.ajaxurl, 2188 type: 'POST', 2189 data: { 2190 action: 'snoloadimage', 2191 photo: photo, 2192 }, 2193 success: function (results) { 2194 jQuery('.remodal-inner-container').replaceWith(results) 2195 sno_slideshow_open = 'yes' 2196 var inst = jQuery('[data-remodal-id=modal-photo]').remodal() 2197 inst.open() 2198 scalephoto() 2199 }, 2200 }) 2201 } 2202 }) 2203}) 2204 2205// building the staggered display of tiles for the category view pages 2206function place_tiles() { 2207 if (jQuery(window).width() < 980) { 2208 jQuery('.catpage-tiles-column.column-3').remove() 2209 jQuery('.catpage-tiles-column.column-2').remove() 2210 } 2211 if (jQuery(window).width() < 600) { 2212 jQuery('.catpage-tiles-column.column-1').remove() 2213 } 2214 jQuery('.sno-tile-hidden').each(function () { 2215 var shortest = [].reduce.call(jQuery('.catpage-tiles-column'), function (sml, cur) { 2216 return jQuery(sml).height() < jQuery(cur).height() ? sml : cur 2217 }) 2218 jQuery(this).removeClass('sno-tile-hidden').hide().appendTo(shortest).fadeIn() 2219 }) 2220} 2221 2222jQuery(window).load(function () { 2223 place_tiles() 2224}) 2225 2226function remove_duplicates() { 2227 var seen = Object.create(null); 2228 jQuery('.profile-rendered').filter(function () { 2229 var id = jQuery(this).data('rendered'); 2230 if (id == null) return false;
2231 if (seen[id]) return true; // mark for removal 2232 seen[id] = true; // keep first occurrence 2233 return false; 2234 }).remove(); 2235} 2236// make sure that all story cards on the category tile view have the same height to create a nice, even display 2237 2238function resize_tiles() { 2239 if (jQuery(window).width() > 600) { 2240 var height = 0 2241 var tallest = 0 2242 var set_height = jQuery('.sno-tile-resized').last().height() != null ? jQuery('.sno-tile-resized').last().height() : null 2243 jQuery('.catlist-tile').each(function () { 2244 if (!jQuery(this).hasClass('sno-tile-resized')) { 2245 height = jQuery(this).height() 2246 tallest = height > tallest ? height : tallest 2247 if (set_height != null && tallest < set_height) tallest = set_height 2248 } 2249 }) 2250 if (jQuery('#staffpage').length) { 2251 if (tallest > 950) tallest = 950 // preventing runaway heights just in case someone adds something stupid 2252 } else { 2253 if (tallest > 750) tallest = 750 // preventing runaway heights just in case someone adds something stupid 2254 } 2255 jQuery('.catlist-tile').each(function () { 2256 if (!jQuery(this).hasClass('sno-tile-resized')) { 2257 jQuery(this).find('.catlist-tile-inner').height(tallest) 2258 if (jQuery(this).find('.catlist-tile-textarea').length) jQuery(this).find('.catlist-tile-textarea').addClass('sno-center-v-list') 2259 jQuery(this).addClass('sno-tile-resized') 2260 } 2261 }) 2262 } 2263} 2264 2265jQuery(window).load(function () { 2266 resize_tiles() 2267}) 2268 2269// force fill "contain" photo photos that are close to filling frame on category pages 2270function fill_photo() { 2271 jQuery('.catlist-panel-media img.unscaled').each(function () { 2272 jQuery(this).removeClass('unscaled') 2273 var image_ratio = jQuery(this).data('ratio') 2274 var width = jQuery(this).closest('.catlist-panel-media').width() 2275 var height = jQuery(this).closest('.catlist-panel-media').height() 2276 if (height != 0) { 2277 var area_ratio = (height / width).toFixed(2) 2278 if (Math.abs(image_ratio - area_ratio) < 0.15) jQuery(this).css({'object-fit': 'cover'}) 2279 } 2280 }) 2281 jQuery('.catlist-tile img.unscaled').each(function () { 2282 jQuery(this).removeClass('unscaled') 2283 var image_ratio = jQuery(this).data('ratio') 2284 var width = jQuery(this).closest('.catlist-tile-media-photo').width() 2285 var height = jQuery(this).closest('.catlist-tile-media-photo').height() 2286 if (height != 0) { 2287 var area_ratio = (height / width).toFixed(2) 2288 if (Math.abs(image_ratio - area_ratio) < 0.15) jQuery(this).css({'object-fit': 'cover'}) 2289 } 2290 }) 2291} 2292 2293jQuery(document).ready(function ($) { 2294 fill_photo() 2295}) 2296 2297// infinite scroll for category pages 2298jQuery(document).ready(function ($) { 2299 jQuery('body').on('click', '.sno-infinite-scroll-button-active', function () { 2300 event.preventDefault() 2301 var paged = jQuery(this).data('paged') == 0 ? 1 : jQuery(this).data('paged') 2302 var category = jQuery(this).data('category') 2303 var tag = jQuery(this).data('tag') 2304 var taxonomy = jQuery(this).data('taxonomy') 2305 var template = jQuery(this).data('template') 2306 var search = jQuery(this).data('search') 2307 var term = jQuery(this).data('term') 2308 var year = jQuery(this).data('year') 2309 var month = jQuery(this).data('month') 2310 2311 var find_rendered = [] 2312 $('.profile-rendered').each(function () { 2313 find_rendered.push($(this).data('rendered')) 2314 }) 2315 var rendered = find_rendered.join(',') 2316 2317 jQuery('.sno-infinite-scroll-button').text($('#content').data('loading')) 2318 2319 jQuery.ajax({ 2320 url: frontend_ajax_object.ajaxurl, 2321 type: 'POST', 2322 data: { 2323 action: 'snoinfinite', 2324 category: category, 2325 tag: tag, 2326 paged: paged, 2327 template: template, 2328 taxonomy: taxonomy, 2329 search: search, 2330 term: term, 2331 year: year, 2332 month: month, 2333 rendered: rendered, 2334 }, 2335 success: function (results) { 2336 jQuery('.sno-infinite-scroll-button').data('paged', paged + 1) 2337 jQuery(results).insertBefore('.sno-infinite-scroll-insertion') 2338 jQuery('.profile-keepalive').remove() 2339 jQuery('.sno-infinite-scroll-button').addClass('sno-infinite-scroll-button-active') 2340 remove_duplicates() 2341 place_tiles() 2342 fill_photo() 2343 resize_tiles() 2344 if (results == '') { 2345 jQuery('.sno-infinite-scroll-button').text($('#content').data('loaded')) 2346 jQuery('.sno-infinite-scroll-button').removeClass('sno-infinite-scroll-button-active') 2347 } else { 2348 jQuery('.sno-infinite-scroll-button').text($('#content').data('load')) 2349 } 2350 }, 2351 }) 2352 }) 2353}) 2354 2355jQuery(window).on('scroll', function () { 2356 var scrollHeight = jQuery(document).height() 2357 var scrollPosition = jQuery(window).height() + jQuery(window).scrollTop() 2358 if ((scrollHeight - 300 >= scrollPosition) / scrollHeight == 0) { 2359 if (jQuery('.sno-infinite-scroll-button').hasClass('sno-infinite-scroll-button-active')) { 2360 jQuery('.sno-infinite-scroll-button-active').click() 2361 jQuery('.sno-infinite-scroll-button').removeClass('sno-infinite-scroll-button-active') 2362 } 2363 } 2364}) 2365 2366// make photos and continue links clickable on category views 2367jQuery(document).ready(function () { 2368 jQuery('.catlist-panel .continue, .catlist-panel img, a.catlist-photooverlay').click(function () { 2369 var link = jQuery(this).closest('.catlist-panel').find('a.homeheadline').attr('href') 2370 if (link) { 2371 window.location = link 2372 } 2373 2374 var photo = jQuery(this).closest('.catlist-panel').find('a').data('photo-id') 2375 if (photo) { 2376 jQuery.ajax({ 2377 url: frontend_ajax_object.ajaxurl, 2378 type: 'POST', 2379 data: { 2380 action: 'snoloadimage', 2381 photo: photo, 2382 }, 2383 success: function (results) { 2384 jQuery('.remodal-inner-container').replaceWith(results) 2385 sno_slideshow_open = 'yes' 2386 var inst = jQuery('[data-remodal-id=modal-photo]').remodal() 2387 inst.open() 2388 scalephoto() 2389 }, 2390 }) 2391 } 2392 }) 2393}) 2394 2395// when text is vertically centered on category list view, if the text area is taller than the photo, it won't look good. Expand the height of the text area to match its actual height 2396jQuery(window).load(function () { 2397 jQuery('.catlist-textarea-with-media').each(function () { 2398 var photo_height = jQuery(this).closest('.catlist-panel').find('.catlist-panel-media').height() 2399 var text_height = jQuery(this).height() 2400 if (text_height > photo_height) { 2401 jQuery(this).css({ 2402 position: 'unset', 2403 transform: 'unset', 2404 'padding-top': 0, 2405 'margin-right': '-15px', 2406 }) 2407 } 2408 }) 2409}) 2410// do it again on ready just to be safe 2411jQuery(document).ready(function () { 2412 jQuery('.catlist-textarea-with-media').each(function () { 2413 var photo_height = jQuery(this).closest('.catlist-panel').find('.catlist-panel-media').height() 2414 var text_height = jQuery(this).height() 2415 if (text_height > photo_height) { 2416 jQuery(this).css({position: 'unset', transform: 'unset'}) 2417 } 2418 }) 2419}) 2420 2421// make menu teaser photos clickable
2422jQuery(document).ready(function () { 2423 jQuery('body').on('click', '.sno-story-card-photo-wrap', function () { 2424 if (jQuery(this).closest('.sno-menu-card').find('a').length) { 2425 window.location = jQuery(this).closest('.sno-menu-card').find('a').attr('href') 2426 } 2427 }) 2428}) 2429 2430// make full tag clickable 2431jQuery(document).ready(function () { 2432 jQuery('li.blockstag').click(function () { 2433 if (jQuery(this).find('a').length) { 2434 window.location = jQuery(this).find('a').attr('href') 2435 } 2436 }) 2437}) 2438 2439// story list widget 2440jQuery(document).ready(function () { 2441 jQuery('.sno-story-card, .dual-format-card').click(function () { 2442 if (jQuery(this).find('a.homeheadline').length) { 2443 window.location = jQuery(this).find('a.homeheadline').attr('href') 2444 } 2445 }) 2446}) 2447 2448// make sure that all story list cards in a horizontal row have the same height to create a nice, even display 2449 2450jQuery(window).load(function () { 2451 jQuery('.list-horizontal').each(function () { 2452 var height = 0 2453 var tallest = 0 2454 jQuery(this) 2455 .find('.sno-story-card') 2456 .each(function () { 2457 height = jQuery(this).height() 2458 tallest = height > tallest ? height : tallest 2459 }) 2460 if (jQuery(this).closest('.sno-story-list-widget').find('.story-widget-secondary:not(.story-widget-secondary-vertical').length) { 2461 var secondary_height = jQuery(this).closest('.sno-story-list-widget').find('.story-widget-secondary').height() 2462 tallest = secondary_height > tallest ? secondary_height : tallest 2463 } 2464 jQuery(this).find('.sno-story-card').height(tallest) 2465 }) 2466}) 2467 2468// parallax widget 2469jQuery(document).ready(function () { 2470 jQuery('.bcg').click(function () { 2471 window.location = jQuery(this).find('a').attr('href') 2472 }) 2473 2474 jQuery('.text-parallax').click(function () { 2475 window.location = jQuery(this).find('a').attr('href') 2476 }) 2477 2478 jQuery('.text-overlay-parallax-mobile').each(function () { 2479 var height = jQuery(this).height() 2480 var photoHeight = jQuery(this).closest('.parallax-mobile-widget-tile').find('img.parallax-mobile-image').height() 2481 var new_padding = Math.floor((photoHeight - height) / 2) 2482 jQuery(this).css('padding-top', new_padding) 2483 }) 2484}) 2485 2486jQuery(window).load(function () { 2487 $body = jQuery('.parallaxcontainer') 2488 if (jQuery('.parallaxcontainer').is('.instantiate-parallax')) { 2489 var s = skrollr.init({ 2490 forceHeight: false, 2491 }) 2492 jQuery('.parallaxcontainer').css('height', 'auto') 2493 jQuery('.parallaxcontainer section').fadeIn(2000) 2494 s.refresh(jQuery('.homeSlide')) 2495 } 2496}) 2497 2498// make sure that all trending stories cards in a horizontal row have the same height for photo and text to create a nice, even display 2499 2500jQuery(window).load(function () { 2501 jQuery('.sno-widget-card-wrapper.trending-horizontal').each(function () { 2502 var height = 0 2503 var tallest = 0 2504 2505 jQuery(this) 2506 .find('.sno-trending-card') 2507 .each(function () { 2508 height = jQuery(this).height() 2509 tallest = height > tallest ? height : tallest 2510 }) 2511 jQuery(this).find('.sno-trending-card').height(tallest) 2512 }) 2513}) 2514 2515// make sure that all trending stories cards are the same height 2516 2517jQuery(window).load(function () { 2518 jQuery('.sno-widget-trending-wrapper.trending-horizontal').each(function () { 2519 var card_height = 0 2520 var tallest_card = 0 2521 2522 jQuery(this) 2523 .find('.trending-row-wrap') 2524 .each(function () { 2525 card_height = jQuery(this).height() 2526 tallest_card = card_height > tallest_card ? card_height : tallest_card 2527 }) 2528 jQuery(this).find('.trending-row-wrap').height(tallest_card) 2529 }) 2530}) 2531 2532// make sure that all cards in a row have the same height for photo and text to create a nice, even display 2533 2534jQuery(window).load(function () { 2535 jQuery('.sno-widget-card-wrapper.sno-card-row').each(function () { 2536 var title_height = 0 2537 var teaser_height = 0 2538 var tallest_title = 0 2539 var tallest_teaser = 0 2540 2541 jQuery(this) 2542 .find('.sno-content-card') 2543 .each(function () { 2544 title_height = jQuery(this).find('.sno-profile-card-header-wrap').height() 2545 tallest_title = title_height > tallest_title ? title_height : tallest_title 2546 teaser_height = jQuery(this).find('.sno-profile-card-teaser').height() 2547 tallest_teaser = teaser_height > tallest_teaser ? teaser_height : tallest_teaser 2548 }) 2549 jQuery(this).find('.sno-profile-card-header-wrap').height(tallest_title) 2550 jQuery(this).find('.sno-profile-card-teaser').height(tallest_teaser) 2551 }) 2552}) 2553 2554// adjust the height of teasers so that text doesn't get cut off at the bottom of the widget 2555 2556jQuery(document).ready(function () { 2557 jQuery('.sno-widget-card-wrapper.sno-card-row, .sno-widget-card-wrapper.sno-vertical-stack').each(function () { 2558 jQuery(this) 2559 .find('.sno-content-card.sno-profile-small-photo') 2560 .each(function () { 2561 var name_height = jQuery(this).find('.sno-profile-name').height() 2562 var title_height = jQuery(this).find('.sno-profile-title').height() 2563 var teaser_height = jQuery(this).find('p').height() 2564 var photo_height = jQuery(this).find('.sno-profile-card-image').height()
2565 var line_height = parseInt(jQuery(this).find('.sno-card-teaser p').css('line-height')) 2566 var font_size = parseInt(jQuery(this).find('.sno-card-teaser p').css('font-size')) 2567 var card_bottom_padding = parseInt(jQuery(this).css('padding-bottom')) 2568 2569 var buffer = (line_height - font_size) / 2 2570 2571 if (photo_height != null) { 2572 var text_height_area_max = photo_height - name_height - title_height - 10 + card_bottom_padding 2573 while (teaser_height >= text_height_area_max) teaser_height -= line_height 2574 teaser_height += buffer 2575 } 2576 }) 2577 if (typeof teaser_height != 'undefined' && teaser_height !== null) 2578 jQuery(this) 2579 .find('.sno-profile-card-teaser') 2580 .css({height: teaser_height + 'px', overflow: 'hidden'}) 2581 }) 2582}) 2583 2584jQuery(document).ready(function () { 2585 // sports score hover effect for links 2586 jQuery('body').on('mouseenter', 'a .scorewrap.sc_horizontal', function () { 2587 jQuery(this).addClass('sc_score_link') 2588 }) 2589 jQuery('body').on('mouseleave', 'a .scorewrap.sc_horizontal', function () { 2590 jQuery(this).removeClass('sc_score_link') 2591 }) 2592 2593 jQuery('body').on('mouseenter', 'a .scorewrap.sc_vertical', function () { 2594 jQuery(this).addClass('sc_score_link_vertical') 2595 }) 2596 jQuery('body').on('mouseleave', 'a .scorewrap.sc_vertical', function () { 2597 jQuery(this).removeClass('sc_score_link_vertical') 2598 }) 2599 2600 // schedule/results widgets -- show dropdown choice for individual sports 2601 jQuery('body').on('click', '.scheduleheader', function () { 2602 jQuery(this).closest('.widgetwrap').find('.widget-sports-list').slideToggle() 2603 jQuery(this).closest('.widgetwrap').find('.sno-sports-selector-icon').toggleClass('dashicons-arrow-down dashicons-arrow-up') 2604 }) 2605 2606 // make table cells clickble on sports tables 2607 jQuery('table.schedulewidget td').click(function () { 2608 var href = jQuery(this).find('a').attr('href') 2609 if (href) { 2610 window.location = href 2611 } 2612 }) 2613}) 2614 2615jQuery(window).load(function () { 2616 2617 // sports score carousel widget 2618 2619 jQuery(function ($) { 2620 $('.weather-widget-carousel').each(function () { 2621 var transition_speed = $(this).data('transition-speed') 2622 var slide_duration = $(this).data('slide-duration') 2623 var margin_width = $(this).data('margin-width') 2624 var item_width = $(this).data('item-width') 2625 var move_number = $(this).data('move-number') 2626 var navigation_buttons = $(this).data('navigation-buttons') 2627 2628 $(this).flexslider({ 2629 animationSpeed: transition_speed, 2630 slideshowSpeed: slide_duration, 2631 slideshow: false, 2632 animation: 'slide', 2633 direction: 'horizontal', 2634 directionNav: true, 2635 animationLoop: true, 2636 controlNav: false, 2637 minItems: 1, 2638 move: 12, 2639 maxItems: 15, 2640 itemWidth: item_width, 2641 itemMargin: margin_width, 2642 }) 2643 2644 $(this).find('.flex-viewport').css({height: '200px!important'}) 2645 }) 2646 }) 2647 2648 2649 // carousel widget -- instantiate flexslider for all carousel widgets 2650 2651 jQuery(function ($) { 2652 $('.carousel-widget .carouselslider, .sportspage .carouselslider').each(function () { 2653 var transition_speed = $(this).data('transition-speed') 2654 var auto_scroll = $(this).data('auto-scroll') 2655 var transition_style = $(this).data('transition-style') 2656 var navigation_buttons = $(this).data('navigation-buttons') 2657 var width_adjustment = $(this).data('width-adjustment') 2658 var auto_scroll_speed = $(this).data('auto-scroll-speed') 2659 var play_pause = $(this).data('play-pause') 2660 var display_number = $(this).data('display-number') 2661 var move_number = $(this).data('move-number') 2662 var margin_width = $(this).data('margin-width') 2663 var item_width = $(this).data('item-width') 2664 var show_thumbnails = $(this).data('show-thumbnails') 2665 var full_screen = $(this).data('full-screen') 2666 var thumbnail_width = $(this).data('thumbnail-width') 2667 var thumbnail_margin = $(this).data('thumbnail-margin') 2668 var container = $(this); 2669 2670 if (full_screen == 'widgetfullscreen' && display_number != '1') { 2671 item_width = (jQuery(window).width() - width_adjustment) / display_number 2672 } else if (full_screen == 'widgetfullscreen') { 2673 item_width = jQuery(window).width() 2674 } else { 2675 item_width = ($(this).closest('.carouselslider').width() - width_adjustment) / display_number 2676 } 2677 $(this).find('li.carousel-widget-slide').width(item_width) 2678 2679 if (show_thumbnails == 'on') { 2680 jQuery(this) 2681 .closest('.carousel-widget') 2682 .find('.thumbnailslider') 2683 .flexslider({ 2684 animation: 'slide', 2685 customDirectionNav: jQuery(this).closest('.carousel-widget').find('.thumbnailslider .custom-navigation span'), 2686 controlNav: false, 2687 directionNav: true, 2688 animationLoop: true, 2689 slideshow: false, 2690 itemWidth: thumbnail_width, 2691 itemMargin: thumbnail_margin, 2692 touch: true, 2693 asNavFor: $(this).closest('.carousel-widget').find('.carouselslider'), 2694 }) 2695 } 2696 2697 $carousel = $(this).flexslider({ 2698 animationSpeed: transition_speed, 2699 animationLoop: true, 2700 customDirectionNav: jQuery(this).find('.custom-navigation span'), 2701 controlNav: navigation_buttons, 2702 smoothHeight: false, 2703 slideshowSpeed: auto_scroll_speed, 2704 slideshow: auto_scroll, 2705 animation: transition_style, 2706 sync: $(this).closest('.carousel-widget').find('.thumbnailslider'), 2707 itemWidth: item_width, 2708 itemMargin: margin_width, 2709 minItems: 1, 2710 pausePlay: play_pause, 2711 move: move_number, 2712 pauseOnAction: true, 2713 maxItems: 5, 2714 after: function () { 2715 restrictFocusToVisibleSlides(container); 2716 } 2717 }) 2718 setTimeout(function () { 2719 restrictFocusToVisibleSlides(container); 2720 }, 1000); 2721 var height_method = $(this).data('height-method') 2722 var height_ratio = $(this).data('height-ratio') 2723 2724 var carouselWidth = jQuery(this).width() 2725 var carouselHeight = Math.floor((jQuery(this).width() * height_ratio) / 100) 2726 2727 if (height_method == 'Ratio') jQuery(this).find('ul.slides li').css('height', carouselHeight) 2728 2729 2730 const $navigationButton = $(this).find('.custom-navigation'); 2731 $navigationButton.on('keydown', function (event) { 2732 if (event.key === 'Enter' || event.keyCode === 13) { 2733 const $slideshowRight = $(this).find('.sno_slideshow_right span'); 2734 if ($slideshowRight.length) { 2735 $slideshowRight.trigger('click'); 2736 } 2737 const $slideshowLeft = $(this).find('.sno_slideshow_left span'); 2738 if ($slideshowLeft.length) { 2739 $slideshowLeft.trigger('click'); 2740 } 2741 } 2742 }); 2743 $carousel.on('focusin', function () { 2744 $carousel.flexslider("pause"); 2745 }); 2746 2747 }); 2748 2749 $('.infobox-carousel').each(function () { 2750 var infobox_id = $(this).closest('.sno-infobox').data('id'); 2751 var container = $(this); 2752 $(this).flexslider({ 2753 animation: "slide", 2754 animationLoop: false, 2755 controlNav: true, 2756 customDirectionNav: $('.sno-infobox-' + infobox_id + ' .custom-navigation span'), 2757 slideshow: false, 2758 itemMargin: 0, 2759 touch: true, 2760 itemWidth: 375, 2761 minItems: 1, 2762 move: 1, 2763 maxItems: 1, 2764 before: function () { 2765 $('button.infobox-nav-button').removeAttr('tabindex'); 2766 }, 2767 after: function () { 2768 restrictFocusToVisibleSlides(container); 2769 $('.flex-disabled').closest('button').attr('tabindex', '-1'); 2770 } 2771 }); 2772 setTimeout(function () { 2773 restrictFocusToVisibleSlides(container) 2774 $('.flex-disabled').closest('button').attr('tabindex', '-1'); 2775 }, 1000); 2776 2777 2778 }); 2779 2780 $('body').on('keydown', '.infobox-nav-button', function (event) { 2781 event.stopPropagation(); 2782 if (event.key === 'Enter' || event.keyCode === 13) { 2783 event.preventDefault(); 2784 const $slideshowRight = $(this).find('span.flex-prev'); 2785 if ($slideshowRight.length) { 2786 $slideshowRight.trigger('click'); 2787 } 2788 const $slideshowLeft = $(this).find('span.flex-next'); 2789 if ($slideshowLeft.length) { 2790 $slideshowLeft.trigger('click'); 2791 } 2792 } 2793 }); 2794 2795 $('.infobox-carousel .flex-control-paging').attr('aria-hidden', 'true'); 2796 $('.infobox-carousel .flex-control-paging a').attr('tabindex', '-1'); 2797 2798 jQuery(function ($) { 2799 $('.sports-widget-carousel').each(function () { 2800 var direction = $(this).data('direction') 2801 var transition_speed = $(this).data('transition-speed') 2802 var slide_duration = $(this).data('slide-duration') 2803 var margin_width = $(this).data('margin-width') 2804 var item_width = $(this).data('item-width') 2805 var move_number = $(this).data('move-number') 2806 var container = $(this); 2807 2808 if (direction == 'vertical') { 2809 item_width = null 2810 margin_width = null 2811 } 2812 2813 var carousel = $(this) 2814 $(this).flexslider({ 2815 animationSpeed: transition_speed, 2816 slideshowSpeed: slide_duration, 2817 slideshow: true, 2818 animation: 'slide', 2819 direction: direction, 2820 directionNav: false, 2821 animationLoop: true, 2822 controlNav: false, 2823 pausePlay: true, 2824 minItems: 1, 2825 move: 1, 2826 maxItems: 5, 2827 itemWidth: item_width, 2828 itemMargin: margin_width, 2829 after: function () { 2830 restrictFocusToVisibleSlides(container); 2831 } 2832 }) 2833 setTimeout(function () { 2834 restrictFocusToVisibleSlides(container); 2835 }, 1000); 2836 2837 $(this).find('.flex-viewport').css({height: '200px!important'}) 2838 $(this).find('.flex-pauseplay').prependTo($(this)); 2839 }) 2840 2841 $('body').on('focus', '.sports-widget-carousel', function () {
2842 $(this).addClass('activate-tab-controls'); 2843 }) 2844 // $('body').on('focus', '.flex-pauseplay', function(e) { 2845 // e.preventDefault(); 2846 // }) 2847 2848 }) 2849 2850 2851 // functions for related stories in bottom drawer on story page 2852 $('body').on('click', '.bottom-drawer-header', function () { 2853 $(this).find('.bottom-drawer-toggle').toggleClass('fa-angle-up fa-angle-down'); 2854 if ($('.related-term-container-active:visible').length) { 2855 $(this).closest('.related-bottom-drawer').removeClass('hide-shadow'); 2856 $(this).closest('.related-bottom-drawer').find('.related-term-container').slideUp(); 2857 $('.bottom-drawer-background').removeClass('bottom-drawer-background-active'); 2858 $(this).find('.bds-arrows').fadeOut(); 2859 $(this).find('.bds-arrow').attr('tabindex', '-1'); 2860 $(this).find('.bottom-drawer-toggle').attr('aria-expanded', 'false'); 2861 } else { 2862 if ($('.related-term-container-active').length) { 2863 $(this).closest('.related-bottom-drawer').find('.related-term-container-active').slideDown(); 2864 } else { 2865 $(this).closest('.related-bottom-drawer').find('.related-term-container').first().slideDown().addClass('related-term-container-active'); 2866 } 2867 $(this).closest('.related-bottom-drawer').addClass('hide-shadow'); 2868 $('.bottom-drawer-background').addClass('bottom-drawer-background-active'); 2869 $(this).find('.bds-arrows').fadeIn(); 2870 $(this).find('.bds-arrow').attr('tabindex', '0'); 2871 restrictFocusToVisibleList($(this).closest('.related-bottom-drawer')); 2872 $(this).find('.bottom-drawer-toggle').attr('aria-expanded', 'true'); 2873 } 2874 }); 2875 2876 function restrictFocusToVisibleList(container) { 2877 $('.related-term-container a').attr('tabindex', '-1'); 2878 $('.related-term-container-active a').attr('tabindex', '0'); 2879 const modal = jQuery(container); 2880 const focusableElementsSelector = '[tabindex="0"]'; 2881 let firstFocusableElement, lastFocusableElement; 2882 2883 function updateFocusableElements() { 2884 // Update first and last focusable elements 2885 const focusableElements = jQuery(modal).find(focusableElementsSelector); 2886 firstFocusableElement = focusableElements[0]; 2887 lastFocusableElement = focusableElements[focusableElements.length - 1]; 2888 } 2889 2890 // Initialize focusable elements when the modal opens 2891 setTimeout(function () { 2892 updateFocusableElements(); 2893 }, 1000) 2894 2895 jQuery(modal).on('keydown', function (event) { 2896 const isTabPressed = (event.key === 'Tab' || event.keyCode === 9); 2897 if (!isTabPressed) { 2898 return; 2899 } 2900 2901 if (event.shiftKey) { // Shift + Tab 2902 if (document.activeElement === firstFocusableElement) { 2903 lastFocusableElement.focus(); 2904 event.preventDefault(); 2905 } 2906 } else { // Tab 2907 if (document.activeElement === lastFocusableElement) { 2908 firstFocusableElement.focus(); 2909 event.preventDefault(); 2910 } 2911 } 2912 }); 2913 } 2914 2915 $('body').on('keydown', '.bds-arrow, .bottom-drawer-toggl, .sno-hac-menu-mobile-close, .infobox-toggle, .sno-sports-selector-icon, .bottom-drawer-toggle, .live-update-share-link, .sno-fill', function (event) { 2916 if (event.key === 'Enter' || event.keyCode === 13) { 2917 $(this).trigger('click'); 2918 } 2919 }); 2920 $('body').on('keydown', '.grid-widget-tile', function (event) { 2921 if (event.key === 'Enter' || event.keyCode === 13) { 2922 $(this).find('a').trigger('click'); 2923 } 2924 }); 2925 2926 $('body').on('click', '.bds-arrow', function (e) { 2927 e.stopPropagation(); 2928 if (!$(this).hasClass('bds-arrow-active')) return false;
2929 2930 // mark the next slide 2931 if ($(this).hasClass('bds-arrow-right')) { 2932 if ($('.related-term-container-active').next('.related-term-container').length) { 2933 $('.related-term-container-active').next('.related-term-container').addClass('related-term-container-next'); 2934 } 2935 } 2936 if ($(this).hasClass('bds-arrow-left')) { 2937 if ($('.related-term-container-active').prev('.related-term-container').length) { 2938 $('.related-term-container-active').prev('.related-term-container').addClass('related-term-container-next'); 2939 } 2940 } 2941 // move the slides 2942 $('.related-term-container-active').slideUp().removeClass('related-term-container-active'); 2943 $('.related-term-container-next').slideDown().addClass('related-term-container-active').removeClass('related-term-container-next'); 2944 2945 // adjust the arrows 2946 if ($('.related-term-container-active').next('.related-term-container').length) { 2947 $('.bds-arrow-right').addClass('bds-arrow-active') 2948 } else { 2949 $('.bds-arrow-right').removeClass('bds-arrow-active') 2950 } 2951 if ($('.related-term-container-active').prev('.related-term-container').length) { 2952 $('.bds-arrow-left').addClass('bds-arrow-active') 2953 } else { 2954 $('.bds-arrow-left').removeClass('bds-arrow-active') 2955 } 2956 2957 }) 2958 2959 function restrictFocusToVisibleSlides(container) { 2960 const slides = $(container).find('.carousel-widget-slide, .infobox-list-item, .header-carousel-slide'); 2961 let viewport = $(container).find('.flex-viewport').get(0); // Convert to a native DOM element 2962 if (viewport === undefined) return 2963 2964 slides.each(function () { 2965 const slide = $(this); // Convert the current slide to a jQuery object 2966 const rect = slide[0].getBoundingClientRect(); // Get the DOM element from jQuery object 2967 const viewportRect = viewport.getBoundingClientRect(); 2968 2969 // Check if the slide is at least partially visible within the viewport 2970 const isVisible = rect.right > viewportRect.left && 2971 rect.left < viewportRect.right && 2972 rect.bottom > viewportRect.top && 2973 rect.top < viewportRect.bottom; 2974 2975 if (isVisible) { 2976 slide.addClass('visible-slide'); 2977 slide.find('a').removeAttr('tabindex'); 2978 } else { 2979 slide.removeClass('visible-slide'); 2980 slide.find('a').attr('tabindex', '-1') 2981 } 2982 }); 2983 } 2984 2985 }) 2986}) 2987 2988function scalephoto() { 2989 jQuery('.slideshow-photo-container').each(function () { 2990 photo_w = jQuery(this).find('img').attr('data-width') 2991 photo_h = jQuery(this).find('img').attr('data-height') 2992 if (photo_h > 0) { 2993 photo_ratio = photo_w / photo_h 2994 } else { 2995 photo_ratio = 2 2996 } 2997 area_w = jQuery(this).width() 2998 area_h = jQuery(this).height() 2999 if (area_h > 0) { 3000 area_ratio = area_w / area_h 3001 } else { 3002 area_ratio = 2 3003 } 3004 photo_ratio = photo_ratio.toFixed(2) 3005 area_ratio = area_ratio.toFixed(2) 3006 ratio_diff = Math.abs(area_ratio - photo_ratio).toFixed(2) 3007 if (ratio_diff < 0.3 && photo_w > area_w * 0.7 && photo_h > area_h * 0.7) { 3008 jQuery(this).find('img').addClass('forcefill') 3009 } else { 3010 jQuery(this).find('img').removeClass('forcefill') 3011 } 3012 }) 3013} 3014 3015jQuery(function () { 3016 window.onresize = function () { 3017 scalephoto() 3018 scalephotos() 3019 } 3020}) 3021 3022function scalephotos() { 3023 jQuery('#sfi-slideshow ul.slides li.storyslide').each(function () { 3024 photo_w = jQuery(this).find('img').attr('data-width') 3025 photo_h = jQuery(this).find('img').attr('data-height') 3026 if (photo_h > 0) { 3027 photo_ratio = photo_w / photo_h 3028 } else { 3029 photo_ratio = 2 3030 } 3031 area_w = jQuery(this).find('.sfi-photo-wrap').width() 3032 area_h = jQuery(this).find('.sfi-photo-wrap').height() 3033 if (area_h > 0) { 3034 area_ratio = area_w / area_h 3035 } else { 3036 area_ratio = 2 3037 } 3038 photo_ratio = photo_ratio.toFixed(2) 3039 area_ratio = area_ratio.toFixed(2) 3040 ratio_diff = Math.abs(area_ratio - photo_ratio).toFixed(2) 3041 if (ratio_diff < 0.3 && photo_w > area_w * 0.7 && photo_h > area_h * 0.7) { 3042 jQuery(this).find('img').addClass('forcefill') 3043 } else { 3044 jQuery(this).find('img').removeClass('forcefill') 3045 } 3046 }) 3047} 3048 3049jQuery(document).ready(function($) { 3050 $('body').on('click', '.photocaptionremodal', function() { 3051 const $left = $('.sno_slideshow_nav_left'); 3052 const $right = $('.sno_slideshow_nav_right'); 3053 if ($left.css('left') === '0px') { 3054 $left.css('left', '-75px'); 3055 $right.css('right', '-75px'); 3056 } else { 3057 $left.css('left', '0'); 3058 $right.css('right', '0'); 3059 } 3060 }) 3061}) 3062 3063jQuery(document).ready(function () { 3064 // functions for closing remodal windows on scroll down 3065 3066 var sno_slideshow_open = 'no'; 3067 var photo_overlay_last_focus = ''; 3068 jQuery('body').keypress(function (e) { 3069 if (e.which == 27 || e.which == 0) { 3070 sno_slideshow_open = 'no' 3071 } 3072 }) 3073 3074 jQuery('html').on('wheel', function (event) { 3075 var delta = { 3076 y: event.originalEvent.deltaY, 3077 } 3078 3079 if (delta.y > 20 && sno_slideshow_open == 'yes') { 3080 jQuery('button.remodal-close').trigger('click') 3081 sno_slideshow_open = 'no' 3082 } 3083 }) 3084 3085 // for images set as the featured image 3086 3087 jQuery('body').on('click', '.photooverlay, .photo-enlarge', function () { 3088 var photo = jQuery(this).data('photo-id') 3089 var story = jQuery(this).data('story-id') 3090 var clicked = jQuery(this); 3091 var windowWidth = jQuery(window).width(); 3092 photo_overlay_last_focus = jQuery(this); 3093 jQuery.ajax({ 3094 url: frontend_ajax_object.ajaxurl, 3095 type: 'POST', 3096 data: { 3097 action: 'snoloadimage', 3098 photo: photo, 3099 story: story, 3100 width: windowWidth 3101 }, 3102 success: function (results) { 3103 jQuery('.remodal-inner-container').replaceWith(results) 3104 sno_slideshow_open = 'yes' 3105 var inst = jQuery('[data-remodal-id=modal-photo]').remodal() 3106 jQuery('[data-remodal-id=modal-photo]').attr('aria-labelledby', 'modal-title-' + photo) 3107 inst.open() 3108 scalephoto() 3109 jQuery(clicked).closest('.photowrap').find('a').attr('aria-expanded', 'true') 3110 3111 // controlling focus and tabbing in modal 3112 const modal = jQuery('[data-remodal-id="modal-photo"]'); 3113 const focusableElements = 'button, [href], input, select, textarea, [tabindex]:not
3113([tabindex="-1"])'; 3114 let firstFocusableElement, lastFocusableElement, previouslyFocusedElement; 3115 firstFocusableElement = jQuery(modal).find(focusableElements)[0]; 3116 lastFocusableElement = jQuery(modal).find(focusableElements)[jQuery(modal).find(focusableElements).length - 1]; 3117 firstFocusableElement.focus(); 3118 3119 jQuery(modal).on('keydown', function (event) { 3120 const isTabPressed = (event.key === 'Tab' || event.keyCode === 9); 3121 if (!isTabPressed) { 3122 return; 3123 } 3124 if (event.shiftKey) { // Shift + Tab 3125 if (document.activeElement === firstFocusableElement) { 3126 lastFocusableElement.focus(); 3127 event.preventDefault(); 3128 } 3129 } else { // Tab 3130 if (document.activeElement === lastFocusableElement) { 3131 firstFocusableElement.focus(); 3132 event.preventDefault(); 3133 } 3134 } 3135 }) 3136 }, 3137 }) 3138 }) 3139 3140 function link_is_external(link_element) { 3141 return link_element.host !== window.location.host 3142 } 3143 3144 // for images inserted into the body of the story 3145 jQuery(document).ready(function ($) { 3146 $('.storycontent a, .sno-story-body a').each(function () { 3147 if ($(this).find('img').length) { 3148 if (link_is_external(this)) { 3149 return true 3150 } 3151 $(this).attr('aria-haspopup', 'dialog'); 3152 $(this).attr('aria-expanded', 'false'); 3153 $(this).attr('aria-label', 'View full size photo'); 3154 } 3155 }) 3156 }) 3157 jQuery('body').on('click', '.storycontent a, .sno-story-body a', function (e) { 3158 if (jQuery(this).find('img').length) { 3159 // test if the image is linked to something on current site vs. being linked to external site. If linked externally, return true 3160 if (link_is_external(this)) { 3161 return true 3162 } 3163 3164 3165 var clicked = jQuery(this); 3166 photo_overlay_last_focus = jQuery(this); 3167 3168 var img_link = jQuery(this).attr('href') 3169 3170 if ( 3171 img_link.indexOf('.jpg') === -1 && 3172 img_link.indexOf('.jpeg') === -1 && 3173 img_link.indexOf('.png') === -1 && 3174 img_link.indexOf('.webp') === -1 && 3175 img_link.indexOf('attachment') === -1 3176 ) 3177 return true 3178 3179 var image_id = jQuery(this) 3180 .find('img') 3181 .attr('class') 3182 .match(/[\w-]*wp-image-[\w-]*/g) 3183 .toString() 3184 .replace('wp-image-', '') 3185 3186 var post_id = jQuery(this).closest('div.snopostid').attr('id').toString().replace('snopostid-', '') 3187 var windowWidth = jQuery(window).width(); 3188 3189 jQuery.ajax({ 3190 url: frontend_ajax_object.ajaxurl, 3191 type: 'POST', 3192 data: { 3193 action: 'snoloadimage', 3194 photo: image_id, 3195 story: post_id, 3196 width: windowWidth 3197 }, 3198 success: function (results) { 3199 jQuery('.remodal-inner-container').replaceWith(results) 3200 sno_slideshow_open = 'yes' 3201 jQuery(clicked).attr('aria-expanded', 'true') 3202 3203 var inst = jQuery('[data-remodal-id=modal-photo]').remodal() 3204 inst.open() 3205 scalephoto() 3206 3207 // controlling focus and tabbing in modal 3208 const modal = jQuery('[data-remodal-id="modal-photo"]'); 3209 const focusableElementsSelector = 'button, a:not([tabindex="-1"])'; 3210 let firstFocusableElement, lastFocusableElement; 3211 3212 const focusableElements = jQuery(modal).find(focusableElementsSelector); 3213 firstFocusableElement = focusableElements[0]; 3214 lastFocusableElement = focusableElements[focusableElements.length - 1]; 3215 3216 // Initialize focusable elements when the modal opens 3217 setTimeout(function () { 3218 firstFocusableElement.focus(); 3219 }, 1000) 3220 3221 jQuery(modal).on('keydown', function (event) { 3222 const isTabPressed = (event.key === 'Tab' || event.keyCode === 9); 3223 if (!isTabPressed) { 3224 return; 3225 } 3226 3227 if (event.shiftKey) { // Shift + Tab 3228 if (document.activeElement === firstFocusableElement) { 3229 lastFocusableElement.focus(); 3230 event.preventDefault(); 3231 } 3232 } else { // Tab 3233 if (document.activeElement === lastFocusableElement) { 3234 firstFocusableElement.focus(); 3235 event.preventDefault(); 3236 } 3237 } 3238 }); 3239 3240 }, 3241 }) 3242 3243 return false 3244 } 3245 }) 3246 3247 // for SNO slideshows 3248
3249 jQuery('.sfiphotowrap .slideshow-enlarge').click(function () { 3250 jQuery(this).closest('.sfiphotowrap').trigger('click') 3251 }) 3252 jQuery(document).ready(function ($) { 3253 $('body').on('click', '.sfiphotowrap', function (event) { 3254 event.preventDefault(); 3255 photo_overlay_last_focus = jQuery(this); 3256 var image = jQuery(this).attr('data-photo-id') 3257 var storyid = jQuery(this).attr('data-story-id') 3258 var widget = jQuery(this).attr('data-widget') 3259 var photo_ids = jQuery(this).attr('data-photo-ids') 3260 var clicked_image = jQuery(this).find('li.flex-active-slide .inline-photo-wrap').data('image') 3261 var windowWidth = jQuery(window).width(); 3262 var clicked = jQuery(this); 3263 if (clicked_image == undefined) var clicked_image = image 3264 jQuery(this).find('a.modal-photo').attr('aria-expanded', 'true'); 3265 3266 sno_slideshow_open = 'yes' 3267 jQuery('.remodal-inner-container').empty() 3268 if (photo_ids == undefined) { 3269 photo_ids = ''; 3270 jQuery(this).closest('.widget-inline-gallery').find('.widget-inline-gallery-thumb').each(function () { 3271 if (photo_ids) photo_ids += ','; 3272 photo_ids += jQuery(this).data('photo-id') 3273 }); 3274 } 3275 var inst = jQuery('[data-remodal-id=modal-photo]').remodal() 3276 inst.open() 3277 //jQuery('[data-remodal-id=modal-photo]').attr('aria-labelledby', 'modal-title-' + photo) 3278 3279 jQuery.ajax({ 3280 url: frontend_ajax_object.ajaxurl, 3281 type: 'POST', 3282 data: { 3283 action: 'getslideshow', 3284 storyid: storyid, 3285 image: clicked_image, 3286 photoids: photo_ids, 3287 width: windowWidth, 3288 widget: widget, 3289 }, 3290 success: function (results) { 3291 jQuery('.remodal-inner-container').replaceWith(results) 3292 3293 3294 jQuery(clicked).closest('.photowrap').find('a').attr('aria-expanded', 'true') 3295 3296 // controlling focus and tabbing in modal 3297 const modal = jQuery('[data-remodal-id="modal-photo"]'); 3298 const focusableElementsSelector = 'button, a:not([tabindex="-1"])'; 3299 let firstFocusableElement, lastFocusableElement; 3300 3301 function updateFocusableElements() { 3302 // Reset tabindex for all links in inactive slides 3303 $('.remodal-is-opened').find('li.storyslide:not(.flex-active-slide)').find('a').attr('tabindex', '-1'); 3304 3305 // Update first and last focusable elements 3306 const focusableElements = jQuery(modal).find(focusableElementsSelector); 3307 firstFocusableElement = focusableElements[0]; 3308 lastFocusableElement = focusableElements[focusableElements.length - 1]; 3309 } 3310 3311 // Initialize focusable elements when the modal opens 3312 setTimeout(function () { 3313 updateFocusableElements(); 3314 firstFocusableElement.focus(); 3315 }, 1000) 3316 3317 jQuery(modal).on('keydown', function (event) { 3318 const isTabPressed = (event.key === 'Tab' || event.keyCode === 9); 3319 if (!isTabPressed) { 3320 return; 3321 } 3322 3323 if (event.shiftKey) { // Shift + Tab 3324 if (document.activeElement === firstFocusableElement) { 3325 lastFocusableElement.focus(); 3326 event.preventDefault(); 3327 } 3328 } else { // Tab 3329 if (document.activeElement === lastFocusableElement) { 3330 firstFocusableElement.focus(); 3331 event.preventDefault(); 3332 } 3333 } 3334 }); 3335 3336 3337 const $navigationButton = $('.remodal-inner-container .custom-navigation'); 3338 3339 // Add a keydown event listener to the button 3340 $navigationButton.on('keydown', function (event) { 3341 // Check if the Enter key is pressed 3342 if (event.key === 'Enter' || event.keyCode === 13) { 3343 // Prevent default behavior (optional) 3344 //event.preventDefault(); 3345 3346 const $slideshowRight = $(this).find('.slideshow_right'); 3347 if ($slideshowRight.length) { 3348 $slideshowRight.trigger('click'); 3349 updateFocusableElements(); 3350 } 3351 const $slideshowLeft = $(this).find('.slideshow_left'); 3352 if ($slideshowLeft.length) { 3353 $slideshowLeft.trigger('click'); 3354 updateFocusableElements(); 3355 } 3356 } 3357 }); 3358 3359 3360 var start = jQuery('.remodal-inner-container').find('.slideshowdata').data('start') 3361 3362 jQuery('.flexslider').animate({opacity: 1}, {duration: 'slow'}) 3363 jQuery('.flex-container').css('background', 'unset') 3364 3365 jQuery('.remodal-story-image').find('#sfi-thumbn
3365ails').flexslider({ 3366 animation: 'slide', 3367 controlNav: false, 3368 customDirectionNav: jQuery('.remodal-story-image').find('#sfi-thumbnav span'), 3369 animationLoop: true, 3370 slideshow: false, 3371 itemWidth: 106, 3372 itemMargin: 5, 3373 touch: true, 3374 asNavFor: '#sfi-slideshow', 3375 }) 3376 3377 jQuery('.remodal-story-image').find('#sfi-slideshow').flexslider({ 3378 animation: 'fade', 3379 smoothHeight: false, 3380 controlNav: false, 3381 customDirectionNav: jQuery('.remodal-story-image').find('#sfi-slideshow span'), 3382 animationLoop: true, 3383 slideshow: false, 3384 startAt: start, 3385 touch: true, 3386 sync: '#sfi-thumbnails', 3387 }) 3388 var thumbAreaWidth = jQuery('.remodal-story-image').find('#sfi-thumbnails').width() 3389 var thumbRowWidth = 111 * jQuery('.remodal-story-image').find('#sfi-thumbnails li').length 3390 3391 if (thumbRowWidth < thumbAreaWidth) { 3392 jQuery('.remodal-story-image').find('.sfi-thumbnails').width(thumbRowWidth) 3393 } 3394 }, 3395 }) 3396 }) 3397 }) 3398 3399 jQuery('body').on('click', '.remodal-story-image div[data-remodal-action="close"]', function () { 3400 jQuery('.remodal-story-image button.remodal-close').trigger('click') 3401 sno_slideshow_open = 'no'; 3402 if (photo_overlay_last_focus) { 3403 jQuery(photo_overlay_last_focus).focus(); 3404 } 3405 jQuery('a.modal-photo').attr('aria-expanded', 'false') 3406 }) 3407 3408 jQuery('body').on('click', '.remodal-story-image button.sno-overlay-close', function () { 3409 sno_slideshow_open = 'no'; 3410 if (photo_overlay_last_focus) { 3411 jQuery(photo_overlay_last_focus).focus(); 3412 } 3413 jQuery('a.modal-photo').attr('aria-expanded', 'false') 3414 3415 }) 3416 3417 3418 // for inline slideshows in stories and widgets 3419 3420 jQuery(function ($) { 3421 3422 $('.inline-slideshow-area').on('focus', function () { 3423 // controlling focus and tabbing in slideshow 3424 $(this).find('li.storyslide:not(.flex-active-slide)').find('a').attr('tabindex', '-1'); 3425 }) 3426 3427 3428 $('.inline-slideshow-area').each(function () { 3429 var smooth_height = $(this).find('.flex-container').data('smooth-height') 3430 var autoscroll_speed = $(this).find('.flex-container').data('autoscroll-speed') 3431 var autoscroll = $(this).find('.flex-container').data('autoscroll') 3432 3433 $(this) 3434 .find('.inline-thumbnails') 3435 .flexslider({ 3436 animation: 'slide', 3437 controlNav: false, 3438 customDirectionNav: $(this).closest('.inline-slideshow-area').find('.inline-thumbnav span'), 3439 animationLoop: true, 3440 slideshow: false, 3441 itemWidth: 107, 3442 itemMargin: 1, 3443 touch: true, 3444 asNavFor: $(this).closest('.inline-slideshow-area').find('.inline-slideshow'), 3445 }) 3446 3447 $(this) 3448 .find('.inline-slideshow') 3449 .flexslider({ 3450 animation: 'slide', 3451 smoothHeight: smooth_height, 3452 controlNav: false, 3453 slideshowSpeed: autoscroll_speed, 3454 slideshow: autoscroll, 3455 customDirectionNav: $(this).closest('.inline-slideshow-area').find('.inline-slideshow span'), 3456 animationLoop: true, 3457 touch: true, 3458 sync: $(this).closest('.inline-slideshow-area').find('.inline-thumbnails'), 3459 }) 3460 3461 $(this) 3462 .find('.custom-navigation') 3463 .on('click', function () { 3464 return false 3465 }) 3466 3467 var thumbAreaWidth = $(this).find('.inline-thumbnails').width() 3468 var thumbRowWidth = 111 * $(this).find('.inline-thumbnails li').length 3469 if (thumbRowWidth < thumbAreaWidth) { 3470 $(this).find('.inline-thumbnails').width(thumbRowWidth) 3471 } 3472 3473 const $navigationButton = $(this).find('.custom-navigation'); 3474 $navigationButton.on('keydown', function (event) { 3475 if (event.key === 'Enter' || event.keyCode === 13) { 3476 const $slideshowRight = $(this).find('.slideshow_right'); 3477 if ($slideshowRight.length) { 3478 $slideshowRight.trigger('click'); 3479 $(this).closest('.inline-slideshow-area').find('li.storyslide').find('a').removeAttr('tabindex'); 3480 $(this).closest('.inline-slideshow-area').find('li.storyslide:not(.flex-active-slide)').find('a').attr('tabindex', '-1'); 3481 } 3482 const $slideshowLeft = $(this).find('.slideshow_left'); 3483 if ($slideshowLeft.length) { 3484 $slideshowLeft.trigger('click'); 3485 $(this).closest('.inline-slideshow-area').find('li.storyslide').find('a').removeAttr('tabindex'); 3486 $(this).closest('.inline-slideshow-area').find('li.storyslide:not(.flex-active-slide)').find('a').attr('tabindex', '-1'); 3487 } 3488 } 3489 }); 3490 3491 }) 3492 }) 3493 3494 // activating modal window when sharing button clicked 3495
3496 jQuery('.modal-share').click(function () { 3497 3498 const isMobileLike = 3499 ('ontouchstart' in window || navigator.maxTouchPoints > 0) && 3500 window.matchMedia('(max-width: 1024px)').matches; 3501 3502 3503 if (jQuery(this).hasClass('share-email')) { 3504 var action = 'shareemail' 3505 } else { 3506 var action = 'sharestory' 3507 } 3508 3509 if (isMobileLike && action == 'sharestory') return; 3510 3511 jQuery(this).addClass('return-focus-to-div'); 3512 var inst = jQuery('[data-remodal-id=modal-share]').remodal() 3513 inst.open() 3514 3515 var sharestoryid = (jQuery(this).find('.email-side-icon').length) ? jQuery(this).find('.email-side-icon').data('story-id') : jQuery(this).data('story-id') 3516 jQuery.ajax({ 3517 url: frontend_ajax_object.ajaxurl, 3518 type: 'POST', 3519 data: { 3520 action: action, 3521 sharestoryid: sharestoryid, 3522 }, 3523 success: function (results) { 3524 jQuery('.remodal-share-inner-container').replaceWith(results) 3525 3526 restrictFocusToModal(jQuery('.remodal-share-inner-container').closest('.remodal-wrapper')) 3527 3528 setTimeout(function () { 3529 jQuery('input#human').after( 3530 '<div class="sno-email-captcha">Are you a robot or a human? <div class="sno-email-captcha-button sno-email-robot" role="button" aria-pressed="false" tabindex="0"><i class="fas fa-robot"></i><span class="icon-hidden-text">Robot</span></div><div class="sno-captcha-button sno-email-human" role="button" aria-pressed="false" tabindex="0"><i class="fas fa-user"></i><span class="icon-hidden-text">Human</span></button></div>' 3531 ) 3532 }, 6000) 3533 3534 jQuery('body').on('blur focus keypress paste', '.emailstoryform form input', function () { 3535 if (jQuery('.sno-email-captcha').is(':hidden') && jQuery('button#submit_email').is(':disabled')) 3536 jQuery('.sno-email-captcha').slideDown() 3537 }) 3538 }, 3539 }) 3540 }) 3541 3542 jQuery('body').on('click', '.remodal-cancel, .remodal-close', function () { 3543 jQuery('.return-focus-to-div').focus(); 3544 }) 3545 3546 function restrictFocusToModal(container) { 3547 const modal = jQuery(container); 3548 const focusableElementsSelector = 'button, input:not([type="hidden"]), textarea, a:not([tabindex="-1"])'; 3549 let firstFocusableElement, lastFocusableElement; 3550 3551 function updateFocusableElements() { 3552 // Update first and last focusable elements 3553 const focusableElements = jQuery(modal).find(focusableElementsSelector); 3554 firstFocusableElement = focusableElements[0]; 3555 lastFocusableElement = focusableElements[focusableElements.length - 1]; 3556 } 3557 3558 // Initialize focusable elements when the modal opens 3559 setTimeout(function () { 3560 updateFocusableElements(); 3561 firstFocusableElement.focus(); 3562 }, 1000) 3563 3564 jQuery(modal).on('keydown', function (event) { 3565 const isTabPressed = (event.key === 'Tab' || event.keyCode === 9); 3566 if (!isTabPressed) { 3567 return; 3568 } 3569 3570 if (event.shiftKey) { // Shift + Tab 3571 if (document.activeElement === firstFocusableElement) { 3572 lastFocusableElement.focus(); 3573 event.preventDefault(); 3574 } 3575 } else { // Tab 3576 if (document.activeElement === lastFocusableElement) { 3577 firstFocusableElement.focus(); 3578 event.preventDefault(); 3579 } 3580 } 3581 }); 3582 3583 } 3584 3585 // when readers share stories via email 3586 3587 jQuery(function ($) { 3588 $('body').on('click', '.sno-email-captcha-button', function (event, wasTriggered) { 3589 if (wasTriggered) { 3590 email_robot_click() 3591 } 3592 }) 3593 3594 $('body').on('click', '.sno-email-robot', function () { 3595 email_robot_click() 3596 }) 3597 3598 function email_robot_click() { 3599 $('.emailstoryform form button#submit_email').slideUp('slow') 3600 setTimeout(function () { 3601 $('.emailstoryform form button#submit_email').remove() 3602 $('.sno-email-captcha').html('Sorry, only humans are allowed to send email.') 3603 }, 1000) 3604 } 3605 3606 $('body').on('click', '.sno-email-human', function () { 3607 var r = $('input#wp-remember-email')
3608 $('.sno-email-captcha').slideUp() 3609 $('.emailstoryform form button#submit_email').prop('disabled', false) 3610 setTimeout(function () { 3611 $('.sno-comment-captcha').remove() 3612 r.val('1\u200B') 3613 }, 400) 3614 }) 3615 3616 $('body').on('focus', '.emailstoryform form input#human', function () { 3617 set_email_spam_verification() 3618 }) 3619 3620 function set_email_spam_verification() { 3621 var z = $('.sno-email-data').data() 3622 $.each(z, function (x, y) { 3623 $('.sno-email-data').removeAttr('data-' + x) 3624 }) 3625 3626 $('input#sno-email-verification').attr('value', '') 3627 $.each(z, function (a, b) { 3628 a += ' ' 3629 b += ' ' 3630 $.each(a.split(''), function (c, d) { 3631 $('input.sno-email-verification').attr('value', $('input.sno-email-verification').val() + d + b.split('')[c]) 3632 }) 3633 }) 3634 $('input#sno-email-verification').attr('name', 'sno-email-verifyaction') 3635 } 3636 3637 $('body').on('input', '.emailstoryform #email_from', function () { 3638 var val = $(this).val() 3639 var regexname = /^([a-zA-Z0-9 .@]{1,40})$/ 3640 if (!val.match(regexname)) { 3641 $(this).addClass('invalid-input') 3642 } else { 3643 $(this).removeClass('invalid-input') 3644 } 3645 }) 3646 3647 $('body').on('input', '.emailstoryform #email_to', function () { 3648 var val = $(this).val() 3649 var email_pattern = /^\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i 3650 if (val.match(email_pattern)) { 3651 $(this).removeClass('invalid-input') 3652 } 3653 }) 3654 3655 $('body').on('click', '#submit_email', function (e) { 3656 var email_from_valid = /^([a-zA-Z0-9 .@]{1,20})$/ 3657 3658 if (!$('.emailstoryform #email_from').val().match(email_from_valid)) { 3659 return 3660 } 3661 3662 var email_pattern = /^\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i 3663 if (!$('.emailstoryform #email_to').val().match(email_pattern)) { 3664 $('.emailstoryform #email_to').addClass('invalid-input') 3665 return 3666 } 3667 3668 var storyid = $(this).closest('.emailstoryform').data('story-id') 3669 var humanity = $(this).closest('.emailstoryform').data('humanity') 3670 var form_data = $(this).closest('form').serializeArray() 3671 3672 $.ajax({ 3673 url: frontend_ajax_object.ajaxurl, 3674 type: 'POST', 3675 data: { 3676 action: 'emailstory', 3677 storyid: storyid, 3678 humanity: humanity, 3679 form_data: form_data, 3680 }, 3681 success: function (results) { 3682 $('.remodal-share-inner-container').replaceWith(results) 3683 }, 3684 }) 3685 }) 3686 }) 3687 3688 // staff page links 3689 3690 jQuery('tr.staffstoryrow').click(function () { 3691 var href = jQuery(this).find('a').attr('href') 3692 if (href) { 3693 window.location = href 3694 } 3695 }) 3696 3697 jQuery('.clickable-row').click(function () { 3698 window.document.location = jQuery(this).data('href') 3699 }) 3700 3701 // grid widget -- hover and photo effects 3702 3703 jQuery('.overlay-hover').mouseenter(function () { 3704 jQuery(this).find('.gridwidgetoverlay').fadeIn() 3705 if (jQuery(this).hasClass('enlarge-effect')) { 3706 jQuery(this).find('img').removeClass('grow') 3707 jQuery(this).find('img').removeClass('shrink') 3708 jQuery(this).find('img').addClass('grow') 3709 } 3710 }) 3711 jQuery('.overlay-hover').mouseleave(function () { 3712 jQuery(this).find('.gridwidgetoverlay').fadeOut() 3713 if (jQuery(this).hasClass('enlarge-effect')) { 3714 jQuery(this).find('img').addClass('shrink') 3715 } 3716 }) 3717 jQuery('body').on('focus', '.grid-widget-tile', function (event) { 3718 if (event.target != this) return; 3719 if (jQuery(this).find('a')) jQuery(this).find('a').first().focus(); 3720 }) 3721 3722 jQuery(document).ready(function ($) { 3723 $('.skip-to-content').on('click', function (e) { 3724 e.preventDefault(); 3725 var firstFocusableElement = $('#sno-sites-main-content').find('a, button, input, textarea, select, [tabindex]:not
3725([tabindex="-1"])').filter(':visible').first(); 3726 if (firstFocusableElement.length) { 3727 firstFocusableElement.focus(); 3728 } 3729 }); 3730 }); 3731 3732 jQuery('.keep-link').click(function () { 3733 window.location = jQuery(this).find('a').attr('href') 3734 }) 3735 3736 // carousel widget effects 3737 3738 jQuery('.carousel-cover-hover').mouseenter(function () { 3739 jQuery(this).find('.carouseloverlay').fadeIn() 3740 jQuery(this).find('.carouseloverlaytext').fadeIn() 3741 }) 3742 jQuery('.carousel-cover-hover').mouseleave(function () { 3743 jQuery(this).find('.carouseloverlay').fadeOut() 3744 jQuery(this).find('.carouseloverlaytext').fadeOut() 3745 }) 3746 3747 jQuery('.carouseltext .continue').click(function () { 3748 window.location = jQuery(this).parent().find('a.homeheadline').attr('href') 3749 }) 3750 3751 jQuery('.carousel-cover-hover').click(function () { 3752 window.location = jQuery(this).find('.widgetheadlineoverlay a').attr('href') 3753 }) 3754 3755 // category widget 3756 jQuery('body').on('mouseenter', 'img.enlarge-effect', function () { 3757 jQuery(this).removeClass('shrink') 3758 jQuery(this).removeClass('grow') 3759 jQuery(this).addClass('grow') 3760 }) 3761 jQuery('body').on('mouseleave', 'img.enlarge-effect', function () { 3762 jQuery(this).addClass('shrink') 3763 }) 3764 3765 jQuery('.fw1-textarea .continue').click(function () { 3766 window.location = jQuery(this).closest('.fw1-panel').find('.widgetheadline a').attr('href') 3767 }) 3768 3769 jQuery('.fw2-textarea .continue').click(function () { 3770 window.location = jQuery(this).closest('.fw2-panel').find('.widgetheadline a').attr('href') 3771 }) 3772 3773 jQuery('.fw3-textarea .continue').click(function () { 3774 window.location = jQuery(this).closest('.fw3-panel').find('.widgetheadline a').attr('href') 3775 }) 3776 3777 jQuery('.wa-textarea .continue').click(function () { 3778 window.location = jQuery(this).closest('.wa-textarea').find('a.homeheadline').attr('href') 3779 }) 3780 3781 jQuery('.catwidget-col2 .continue').click(function () { 3782 window.location = jQuery(this).closest('.catwidget-col2').find('a.homeheadline').attr('href') 3783 }) 3784 3785 // go to top button on long form pages 3786 3787 jQuery('#gototop').click(function () { 3788 var bottomPosition = jQuery('.phototop').height() 3789 var bottomWindow = jQuery(window).height() 3790 bottomWindow = bottomWindow - 50 3791 if (bottomWindow < bottomPosition) { 3792 photoHeight = bottomWindow 3793 photoHeight = photoHeight - 45 3794 } else { 3795 photoHeight = bottomPosition + 35 3796 } 3797 jQuery('html, body') 3798 .animate( 3799 { 3800 scrollTop: jQuery('#mainbody').offset().top - photoHeight, 3801 }, 3802 1000 3803 ) 3804 .delay() 3805 return false 3806 }) 3807 3808 // side menus on long form pages 3809 3810 jQuery('#hover-menu').click(function () { 3811 jQuery('#altheader-searchbox').toggle('slow') 3812 }) 3813 3814 if (jQuery('.slidemenu').is(':visible')) { 3815 jQuery('.hidethis').css({visibility: 'hidden'}) 3816 jQuery('#altheader-searchbox').css({zIndex: '1001'}) 3817 } else { 3818 jQuery('.hidethis').css({visibility: 'visible'}) 3819 jQuery('#altheader-searchbox').css({zIndex: '99'}) 3820 } 3821 3822 jQuery('.sno-menu').click(function () { 3823 jQuery('#hoverbar_menu').fadeToggle() 3824 jQuery('.menu-icon').toggle() 3825 jQuery('.close-icon').toggle() 3826 jQuery('#hoverbar_menu').css({height: jQuery(window).height() - 50}) 3827 }) 3828 3829 // comments box and links on story pages 3830 3831 jQuery('#commentsbox').click(function () { 3832 jQuery('#commentsbody').slideToggle('slow') 3833 jQuery('.commenttoggle').toggleClass('fa-plus-square fa-minus-square') 3834 if (jQuery('.commenttoggle').hasClass('fa-plus-square')) { 3835 jQuery('.commenttoggle').attr('aria-expanded', 'false') 3836 } else { 3837 jQuery('.commenttoggle').attr('aria-expanded', 'true') 3838 } 3839 }) 3840 3841 /* 3842 jQuery("#commentslink, .commentscroll").click(function() { 3843 jQuery("#commentsbody").slideDown('slow'); 3844 jQuery(".commenttoggle").addClass("fa-minus-square").removeClass("fa-plus-square").attr("aria-expanded", "true"); 3845 }); 3846*/ 3847 3848 /* 3849 jQuery(function($) { 3850 $('.commentscroll').click(function() { 3851 var adjustment = 70; // set up a top margin for the scrolled-to element 3852 if ($(".navbarwrap").hasClass('sno-sticky')) { 3853 adjustment += jQuery('.navbarwrap').height(); 3854 } 3855 if ($(".subnavbarwrap").hasClass('sno-sticky')) { 3856 adjustment += jQuery('.subnavbarwrap').height(); 3857 } 3858 $('html, body').animate({ scrollTop: $("#commentswrap").offset().top - adjustment }, 500); 3859 return false;
3860 }); 3861 }); 3862*/ 3863 3864 // WordPress automatically adjusts widths on left and right floated photos with captions. It's annoying. Let's readjust their adjustment. 3865 3866 // jQuery(document).ready(function () { 3867 // jQuery.each(jQuery('.wp-caption'), function () { 3868 // jQuery(this).width(jQuery(this).find('img').attr('width')) 3869 // }) 3870 // }) 3871 3872 // activate search button on focus within the search box 3873 3874 jQuery(function () { 3875 jQuery('.s').focus(function () { 3876 jQuery('.sno-submit-search-button').prop('disabled', false) 3877 }) 3878 }) 3879 3880 // Accessibility -- Set tabIndex to -1 so that top_level_links can't receive focus until menu is open 3881 3882 // var top_level_links = jQuery('.sf-menu').find('> li > a') 3883 // jQuery(top_level_links).next('ul').find('a').attr('tabIndex', -1) 3884 3885 // Accessibility -- Adding aria-haspopup for appropriate items 3886 3887 // jQuery(top_level_links).each(function () { 3888 // if (jQuery(this).next('ul').length > 0) jQuery(this).parent('li').attr('aria-haspopup', 'true') 3889 // }) 3890 3891 // Side menu on mobile view 3892 3893 jQuery('#hover-menu-side').on('touchstart click', function (e) { 3894 e.preventDefault() 3895 jQuery('#sno_mobile_menu').fadeToggle() 3896 jQuery('body').toggleClass('noscroll') 3897 }) 3898 3899 jQuery('.side-close-icon').on('touchstart click', function (e) { 3900 e.preventDefault() 3901 jQuery('#sno_mobile_menu').fadeToggle() 3902 jQuery('body').toggleClass('noscroll') 3903 }) 3904 3905 // Slideshows and photos need to open in remodal overlays -- prevent them from going to a new URL or jumping to anchor 3906 3907 // jQuery("a[href='#slideshow']").on('click', function (event) { 3908 // return false 3909 // }) 3910 // jQuery("a[href='#photo']").on('click', function(event) { return false; }); 3911 3912 // Create photo slide up effect as the reader scrolls down the page 3913 3914 var win = jQuery(window) 3915 var allMods = jQuery('.sno-animate-active .sno-animate') 3916 var allWPcaptions = jQuery('.sno-animate-active .wp-caption') 3917 3918 allMods.each(function (i, el) { 3919 var el = jQuery(el) 3920 if (el.is(':visible')) { 3921 el.addClass('already-visible') 3922 } else { 3923 el.css('visibility', 'hidden') 3924 } 3925 }) 3926 allWPcaptions.each(function (i, el) { 3927 var el = jQuery(el) 3928 if (el.is(':visible')) { 3929 el.addClass('already-visible') 3930 } 3931 }) 3932 3933 jQuery(window).scroll(function (event) { 3934 jQuery('.sno-animate-active .sno-animate').each(function (i, el) { 3935 var el = jQuery(el) 3936 if (el.is(':visible')) { 3937 el.addClass('come-in') 3938 el.css('visibility', 'visible') 3939 } 3940 }) 3941 jQuery('.sno-animate-active .wp-caption').each(function (i, el) { 3942 var el = jQuery(el) 3943 if (el.is(':visible')) { 3944 el.addClass('come-in') 3945 el.css('visibility', 'visible') 3946 } 3947 }) 3948 }) 3949 3950 // create fade in loading effect for carousels 3951 3952 jQuery(window).load(function () { 3953 jQuery('.flexslider').each(function () { 3954 if (!jQuery(this).hasClass('sno-loading-check')) { 3955 jQuery('.flexslider').addClass('sno-loading-check') 3956 jQuery('.flexslider').animate({opacity: 1}, {duration: 'slow'}) 3957 jQuery('.flex-container').css('background', 'unset') 3958 } 3959 }) 3960 }) 3961 // Firefox wasn't consistly setting the opacity on window load, so adding these lines as a backup 3962 jQuery(document).ready(function () { 3963 setTimeout(function () { 3964 jQuery('.flexslider').each(function () { 3965 if (!jQuery(this).hasClass('sno-loading-check')) { 3966 jQuery('.flexslider').addClass('sno-loading-check') 3967 jQuery('.flexslider').animate({opacity: 1}, {duration: 'slow'}) 3968 jQuery('.flex-container').css('background', 'unset') 3969 } 3970 }) 3971 }, 1000) 3972 }) 3973 // end Firefox fix 3974 3975 // jump navigation options when Above Header widget area is activated 3976 3977 if (jQuery('#upperwrap-outer').is(':visible')) { 3978 var top_elements = jQuery('#upperwrap-outer').offset().top 3979 var wp_adminbar = 0 3980 if (jQuery('#wpadminbar').length > 0) wp_adminbar = jQuery('#wpadminbar').height() 3981 3982 var jumpbutton = top_elements + 20 3983 var headerLocation = jQuery('#wrap').offset().top 3984 if (headerLocation > jQuery(window).height()) { 3985 jQuery('#jump-to-header') 3986 .css('top', jumpbutton + 'px') 3987 .fadeIn() 3988 } 3989 jQuery(window).scroll(function () { 3990 if (jQuery(this).scrollTop() > headerLocation - jQuery(window).height()) { 3991 jQuery('#jump-to-header').fadeOut() 3992 jQuery('#jump-arrow').fadeOut() 3993 } else { 3994 jQuery('#jump-to-header').fadeIn() 3995 jQuery('#jump-arrow').fadeIn() 3996 } 3997 }) 3998 3999 jQuery('#jump-to-header').click(function () { 4000 jQuery('html, body').animate({scrollTop: jQuery('#wrap').offset().top - wp_adminbar}, 500) 4001 return false 4002 }) 4003 jQuery('#jump-arrow').click(function () { 4004 jQuery('html, body').animate({scrollTop: jQuery('#wrap').offset().top - wp_adminbar}, 500) 4005 return false 4006 }) 4007 } 4008 4009 // scroll to top functionality on long-form template 4010 4011 jQuery('#snotop').hide() 4012 jQuery(function () { 4013 jQuery(window).scroll(function () { 4014 if (jQuery(this).scrollTop() > 400) { 4015 jQuery('#snotop').fadeIn() 4016 } else { 4017 jQuery('#snotop').fadeOut() 4018 } 4019 if (jQuery(this).scrollTop() > 200) { 4020 jQuery('.header').fadeIn() 4021 } 4022 }) 4023 4024 jQuery('#back-top a').click(function () { 4025 jQuery('body,html').animate( 4026 { 4027 scrollTop: 0, 4028 }, 4029 800 4030 ) 4031 return false 4032 }) 4033 }) 4034 4035 // immersive image on long-form -- jump to main story 4036 4037 jQuery(document).ready(function () { 4038 if (jQuery('#mainbody').is(':visible')) { 4039 var wp_adminbar = 0 4040 if (jQuery('#wpadminbar').length > 0) wp_adminbar = jQuery('#wpadminbar').height() 4041 4042 jQuery('#jump-arrow').click(function () { 4043 jQuery('html, body').animate({scrollTop: jQuery('#mainbody').offset().top - wp_adminbar}, 500) 4044 jQuery('#jump-arrow').fadeOut() 4045 return false 4046 }) 4047 4048 jQuery(window).scroll(function () { 4049 if (jQuery(this).scrollTop() > jQuery(window).height()) { 4050 jQuery('#jump-arrow').fadeOut() 4051 } else { 4052 jQuery('#jump-arrow').fadeIn() 4053 } 4054 }) 4055 } 4056 }) 4057}) 4058 4059jQuery(document).ready(function () { 4060 // moving on to other ideas. Let's hide poll widgets if there are no polls 4061 jQuery("div:contains('there are no polls available at the moment')").closest('.widgetwrap').hide() 4062}) 4063 4064// jump navigation on long-form menu 4065 4066jQuery(document).ready(function () { 4067 jQuery('li.longform-menu').click(function () { 4068 var target = jQuery(this).data('part') 4069 jQuery('html, body').animate({scrollTop: jQuery('#spacer' + target).offset().top}, 500) 4070 return false 4071 }) 4072}) 4073 4074jQuery(function ($) { 4075 $('body').on('click', '.moreheadlines', function () { 4076 var videoid = $(this).data('video') 4077 $('#loadingimage').show() 4078 $('#videowrap').fadeOut() 4079 $.ajax({ 4080 url: frontend_ajax_object.ajaxurl, 4081 type: 'POST', 4082 data: { 4083 action: 'replace_video', 4084 type: 'video', 4085 id: videoid, 4086 }, 4087 success: function (results) { 4088 $('#moreposts').replaceWith(results) 4089 $('#loadingimage').hide() 4090 }, 4091 }) 4092 }) 4093}) 4094 4095jQuery(document).ready(function () { 4096 jQuery('body').on('click', '.sno-content-card', function () { 4097 var href = jQuery(this).find('a').attr('href') 4098 if (href) { 4099 window.location = href 4100 } 4101 }) 4102})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.