1/* VARIABLES 2-------------------------------------------------------------------------- */ 3var t74_debug = 0, 4 t74_window = { 5 'width' :window.innerWidth, 6 'height' :window.innerHeight, 7 'font_ratio' :0, 8 'mobile' :(window.innerWidth <= 768)?true:false, 9 }, 10 t74_scroll = { 11 'last_position' :window.pageYOffset || document.documentElement.scrollTop, 12 'direction' :false 13 }, 14 t74_nav = { 15 'top_banner' : document.querySelector('#top_banner'), 16 'main_nav' : document.querySelector('#main_nav'), 17 'sub_nav' : document.querySelector('#sub_nav'), 18 'search' : document.querySelector('#search-trigger'), 19 'breaking_banners' : document.querySelectorAll('.breaking_news.dark'), 20 'breaking_buttons' : document.querySelectorAll('.hide_breaking'), 21 }, 22 t74_ticker = { 23 'ticker' : document.querySelector('#news_ticker'), 24 'container' : document.querySelector('#tick_container'), 25 }, 26 t74_layout = { 27 'menu' : document.querySelector('#layout_selector'), 28 'buttons' : document.querySelectorAll('a.select_button'), 29 }, 30 t74_about = { 31 'vimeo_wrapper' : document.querySelectorAll('wp-block-embed-vimeo'), 32 'video_overlay' : document.querySelectorAll('div.wp-block-embed__wrapper'), 33 'vimeo_player' : '', 34 'mission_video' : document.querySelectorAll('iframe'), 35 }, 36 t74_single = { 37 'expand' : document.querySelectorAll('.expand_trigger'), 38 'expandable' : document.querySelectorAll('.expandable'), 39 'activate' : document.querySelectorAll('.activate'), 40 'fp_repeat' : document.querySelector('#frontpage-repeat'), 41 'inline_form' : document.querySelector('#inline_signup'), 42 'content' : document.querySelectorAll('.article_content'), 43 }, 44 t74_feature_story = { 45 'chapter_nav' : document.querySelectorAll('#feature_chapters li'), 46 'sticky_nav' : document.querySelectorAll('#sticky_chapters li'), 47 'sticky_title' : document.querySelectorAll('#sticky_title span'), 48 'chapter_breaks': document.querySelectorAll('.chapter-break'), 49 'sticky_blocks' : document.querySelectorAll('.sticky-block'), 50 'stickers' : document.querySelectorAll('.sticker > div'), 51 'sticker_heights' :[], 52 'reveals' : document.querySelectorAll('.reveal'), 53 'map_triggers' : document.querySelectorAll('.map_trigger'), 54 'body_triggers' : document.querySelectorAll('.body_trigger'), 55 'vimeo_reveals' : document.querySelectorAll('.vimeo_reveal'), 56 }, 57 t74_accordion = { 58 'blocks' : document.querySelectorAll( '.is-style-accordion-content'), 59 'triggers' : document.querySelectorAll( '.is-style-accordion-content h4'), 60 }, 61 t74_fixed_header = { 62 'header' : document.querySelector('#feature_header'), 63 'hero' : document.querySelector('#featured_story_image'), 64 'images' : document.querySelectorAll('.fixed_header_image' ), 65 'text' : document.querySelectorAll('.stand_alone' ), 66 'current' : 0, 67 }, 68 t74_player, 69 t74_player_short, 70 t74_videos = { 71 'featured' : document.querySelectorAll('.fv'), 72 'active' : document.querySelectorAll('.active_video'), 73 'short' : document.querySelectorAll('.video_short a'), 74 }, 75 t74_simpleBar = { 76 'container' : document.querySelector('#simplebar_container'), 77 }, 78 t74_latest_news = { 79 'module' : document.querySelector('#latest_news'), 80 'load_more' : document.querySelectorAll('#latest_news .load_more'), 81 }, 82 t74_newsletters = { 83 'selectors' : document.querySelectorAll('.nl_selector'), 84 'radio_btns': document.querySelectorAll("#signup_banner input[type=radio]") 85 }, 86 t74_slideshow = { 87 'slides' : document.querySelectorAll('#slides .wp-block-group'), 88 'arrows' : document.querySelectorAll( '#slide_controls .slide_arrow'), 89 'counter' : document.querySelector('#slide_count'), 90 'container' : document.querySelector('#slideshow_container'), 91 'begin' : document.querySelector('#begin_slideshow'), 92 'close' : document.querySelector('#close_slideshow'), 93 'vertical' : document.querySelector('#vertical_slideshow_container'), 94 'vertical_scrollPos' : '', 95 }, 96 t74_swiper = { 97 'swiper' : document.querySelectorAll('.swiper'), 98 }, 99 t74_toaster_banner = { 100 'banner': document.querySelector('#toaster_banner'), 101 'close' : document.querySelector('#hide_toaster'), 102 'link' : document.querySelector('#toaster_link'), 103 'form' : document.querySelectorAll('.toaster-email-form'), 104 }, 105 t74_promotional_banner = { 106 'banner': document.querySelector('#promotional_banner'), 107 'close' : document.querySelector('#hide_promo'), 108 }, 109 t74_sponsored_ad = { 110 'content': document.querySelector('meta[name="sponsored_ad"]'), 111 }, 112 T74_canvas = { 113 'header_canvas' : document.querySelector('#header_canvas'),
114 'media_path' : '', 115 'starts' : '', 116 'ends' : '', 117 'fps' : '', 118 }, 119 zero2eight = { 120 'about_triggers' : document.querySelectorAll('.z2e_about_trigger'), 121 } 122; 123 124 125/* FUNCTIONS 126-------------------------------------------------------------------------- */ 127 128 129function t74_initSlideShow(){ 130 131 let slides = Array.from(t74_slideshow.slides), 132 total_slides = t74_slideshow.slides.length, 133 current_slide = 0, 134 touchstartX = 0, 135 touchendX = 0; 136 137 138 //count the slides and add to counter 139 function updateCounter() { 140 t74_slideshow.counter.innerHTML = (current_slide + 1) + '/' + total_slides; 141 } 142 143 //determine if slide has paragraph within 144 function detectSlideText(){ 145 slides.forEach(function (element){ 146 //check for p tags 147 const p_matches = element.querySelectorAll("p"); 148 if(p_matches.length !== 0){ 149 element.classList.add('has_text'); 150 } 151 }); 152 } 153 154 //set first slide to active 155 function setActiveSlide(){ 156 //remove current active 157 slides.forEach(function (element){ 158 if(element.classList.contains('active')){ 159 element.classList.remove('active') 160 } 161 }); 162 //add new active 163 slides[current_slide].classList.add('active'); 164 console.log(current_slide); 165 } 166 167 168 //listen for swipes 169 document.addEventListener('touchstart', e => { 170 touchstartX = e.changedTouches[0].screenX; 171 }) 172 173 document.addEventListener('touchend', e => { 174 touchendX = e.changedTouches[0].screenX; 175 registerSwipe(); 176 }) 177 178 function slideForward(){
179 if(current_slide < (total_slides - 1)) { 180 //on mobile we don't show slide text and image at the same time 181 if( (t74_window.mobile) && (slides[current_slide].classList.contains('has_text')) && !(slides[current_slide].classList.contains('show_slide_image')) ) { 182 slides[current_slide].classList.add('show_slide_image'); 183 }else{ 184 current_slide++; 185 updateCounter(); 186 setActiveSlide(); 187 slides[current_slide - 1].classList.remove('show_slide_image'); 188 } 189 } 190 } 191 192 function slideBackward(){ 193 if(current_slide !== 0){ 194 //on mobile we don't show slide text and image at the same time 195 if( (t74_window.mobile) && (slides[current_slide].classList.contains('has_text')) && !(slides[current_slide].classList.contains('show_slide_image')) ) { 196 slides[current_slide].classList.add('show_slide_image'); 197 }else { 198 current_slide = current_slide - 1; 199 updateCounter(); 200 setActiveSlide(); 201 slides[current_slide + 1].classList.remove('show_slide_image'); 202 } 203 } 204 } 205 206 //make arrows functional 207 t74_slideshow.arrows.forEach(function (element){ 208 element.addEventListener("click", function(event){ 209 if(event.target.classList.contains('next')){ 210 slideForward(); 211 }else if(event.target.classList.contains('previous')){ 212 slideBackward(); 213 } 214 }); 215 }); 216 217 //register swipe gestures 218 function registerSwipe() { 219 if (touchendX < touchstartX){ 220 slideForward(); 221 } 222 if (touchendX > touchstartX){ 223 slideBackward(); 224 } 225 } 226 227 //begin slideshow 228 t74_slideshow.begin.addEventListener("click", function(event){ 229 t74_slideshow.container.classList.add('active'); 230 document.body.classList.add('slideshow_active'); 231 setActiveSlide(); 232 }); 233 234 //close slideshow 235 t74_slideshow.close.addEventListener("click", function(event){ 236 t74_slideshow.container.classList.remove('active'); 237 document.body.classList.remove('slideshow_active'); 238 current_slide = 0; 239 updateCounter(); 240 setActiveSlide(); 241 }); 242 243 //on init 244 updateCounter(); 245 setActiveSlide(); 246 detectSlideText(); 247} 248 249 250//track the scroll 251function t74_trackScroll(){ 252 253 //set the variables 254 var scroll_position = window.pageYOffset || document.documentElement.scrollTop; 255 256 //set the direction 257 t74_scroll.direction = ( t74_scroll.last_position > scroll_position )?'up':'down'; 258 259 //set the last position 260 t74_scroll.last_position = scroll_position; 261 262 //manage fixed header images 263 if(t74_fixed_header.text.length != 0){ 264 t74_switch_feature_fixed_header_images(); 265 } 266} 267 268//show/hide the navigation 269function t74_showNav(){ 270 271 let nav_padding = 0; 272 273 /*let nav_padding = (t74_window.width >= 960)?20:-2;*/ 274 275 if(t74_nav.main_nav.classList.contains('down')){ 276 nav_padding = (t74_window.width >= 960)?-2:0; 277 }else{ 278 nav_padding = (t74_window.width >= 960)?20:0; 279 } 280 281 //dynamically set the top of the nav to the bottom position of the main nav 282 t74_nav.sub_nav.style.top = (t74_nav.main_nav.getBoundingClientRect().bottom + nav_padding) + 'px'; 283 284 //set body class 285 if( this.classList.contains('open') ) { 286 this.classList.remove("open"); 287 document.body.classList.remove("nav_open"); 288 }else{ 289 this.classList.add("open"); 290 document.body.classList.add("nav_open"); 291 } 292} 293 294//show/hide the search bar 295function t74_showSearch(){ 296 //set body class 297 if( document.body.classList.contains('search_open') ) { 298 document.body.classList.remove("search_open"); 299 }else{ 300 document.body.classList.add("search_open"); 301 document.getElementById("s").focus(); 302 } 303} 304 305//show/hide accordion content 306function t74_expand_accordion_content(event){ 307 308 let parent_container = event.target.parentElement; 309 310 if( parent_container.classList.contains("expanded") ) { 311 parent_container.classList.remove("expanded"); 312 }else{ 313 parent_container.classList.add("expanded"); 314 } 315 console.log(parent_container); 316} 317 318//open expandable content -> video-single content for example 319function t74_showExpandables(){ 320 //set body class 321 if( document.body.classList.contains('expandables_open') ) { 322 document.body.classList.remove('expandables_open'); 323 }else{ 324 document.body.classList.add('expandables_open'); 325 } 326} 327 328//track scroll position of navigation bar 329function t74_trackNav(){ 330 let y_pos = t74_nav.top_banner.getBoundingClientRect().bottom, 331 y_int = -1; 332 333 /* Feature Story: delay deployment of fixed header until all full-screen images have scrolled past */ 334 if(t74_fixed_header.images.length >= 1){ 335 y_int = t74_fixed_header.images.length * -1; 336 } 337 338 //detect when nav is off screen 339 if(y_pos <= (t74_window.height * y_int)){ 340 if( !(document.body.classList.contains('nav_scrolled')) ) { 341 document.body.classList.add('nav_scrolled'); 342 t74_nav.main_nav.classList.add('down'); 343 } 344 }else{ 345 if( document.body.classList.contains('nav_scrolled') ) { 346 document.body.classList.remove('nav_scrolled'); 347 t74_nav.main_nav.classList.remove('down'); 348 } 349 } 350 351 //console.log(y_pos); 352} 353 354 355//set the total characters for Feature Story sticky title 356function t74_truncate_sticky_title(){ 357 358 let title = t74_feature_story.sticky_title[0].innerHTML, 359 title_split = title.split(' '), 360 word_index = 0, 361 character_width = 12, 362 max_width = t74_window.width - 20, 363 character_count = 0; 364 365 //keep track of character link for each word 366 title_split.forEach(function (word){ 367 character_count = (word.length * character_width) + character_count; 368 if(character_count > max_width){ 369 return; 370 }else{ 371 word_index++; 372 } 373 }); 374 375 if(title_split.length !== word_index){ 376 377 //shortening array length to max 378 title_split.length = word_index; 379 380 //replace with shortened title plus ellipses 381 t74_feature_story.sticky_title[0].innerHTML = title_split.join(' ') + '...'; 382 383 } 384} 385 386//show/hide the navigation 387function t74_showLayoutSelector(){ 388 389 if( t74_layout.menu.classList.contains('active') ){ 390 t74_layout.menu.classList.remove('active'); 391 } 392 else{ 393 t74_layout.menu.classList.add('active'); 394 } 395} 396 397//generate multiple scrolling tick messages 398function t74_generateTick(){ 399 400 let tick = document.createElement("div"), 401 speed = 18;
402 403 //create an element and add attributes 404 tick.className = "message"; 405 tick.innerHTML = '<p>'+t74_ticker.ticker.dataset.title+'</p>'; //copy data attribute 406 407 //add created element to the DOM if the screen is active 408 if( !(document.hidden) ) { 409 t74_ticker.container.appendChild(tick); 410 } 411 412 //'Read More' after element width needs to be added to tick width 413 let after_element_x = 150; 414 415 //set the distance to travel 416 let tick_x = tick.clientWidth + after_element_x, 417 ticker_x = t74_ticker.container.clientWidth, 418 tick_end = (tick_x + ticker_x), 419 spawn_p = (tick_x > ticker_x)?0.75:0.5, 420 spawn_time = (speed * spawn_p) * 1000; 421 422 //set the transform attributes 423 tick.style.transitionDuration = speed+'s'; 424 tick.style.transform = 'translateX(-'+tick_end+'px)'; 425 426 //animate and recycle it 427 setTimeout(function(){ 428 t74_generateTick(); 429 }, spawn_time); 430 431 //delete any old ticks 432 let old_messages = document.querySelectorAll('#news_ticker .message'); 433 434 if( old_messages.length >= 5 ){ 435 old_messages[1].remove(); 436 } 437} 438 439//determine font size based on screen width 440function t74_set_fontRatio(){ 441 //set variables 442 let min_vw = 480, 443 max_vw = 960, 444 min_fs = 16, 445 max_fs = 20, 446 font_size; 447 448 //update current window sizes 449 t74_window.width = window.innerWidth; 450 t74_window.height = window.innerHeight; 451 452 if( (t74_window.width < max_vw) && (t74_window.width > min_vw) ){ 453 454 let fs_spread = max_fs - min_fs, 455 vw_spread = max_vw - min_vw, 456 fs_ratio = fs_spread/vw_spread; 457 458 font_size = ((t74_window.width - min_vw) * fs_ratio) + min_fs; 459 460 }else if(t74_window.width > max_vw){ 461 font_size = max_fs; 462 }else{ 463 font_size = min_fs; 464 } 465 document.documentElement.style.fontSize = font_size + 'px'; 466 console.log('t74_set_fontRatio: '+ font_size + 'px'); 467} 468 469//always open external links in new window 470function t74_targetExternalLinks(){ 471 for(var c = document.getElementsByTagName("a"), a = 0;a < c.length;a++) { 472 var b = c[a]; 473 b.getAttribute("href") && b.hostname !== location.hostname && (b.target = "_blank") 474 } 475} 476 477//scroll to feature story chapter 478function t74_scrollToChapter(event, index) { 479 event.preventDefault(); 480 481 //get element data 482 var scroll_target = t74_feature_story.chapter_breaks[index], 483 scroll_destination = window.innerHeight * 0.5, 484 duration = 500; 485 486 var animateObject = function() { 487 if (duration > 0) { 488 var difference = scroll_target.getBoundingClientRect().top - scroll_destination, 489 increment = difference / duration * 10; 490 491 //scroll the target 492 window.scrollBy(0,increment); 493 494 // recurse if not finished 495 if (scroll_target.getBoundingClientRect().top !== scroll_destination) { 496 497 duration = duration - 10; 498 setTimeout(function () { 499 animateObject(); 500 }, 10); 501 } 502 } 503 }; 504 505 animateObject(); 506} 507 508// Set fixed header images from article body as background images 509function t74_insert_feature_fixed_header_images(){ 510 511 let standAlone_images = [].slice.call(document.querySelectorAll('.stand_alone > div > figure > img' ), 0).reverse(); 512 513 //inject divs with background image into feature header 514 for (i = 0; i < standAlone_images.length; ++i) { 515 var headerImg = document.createElement('div'); 516 517 headerImg.style.cssText = "background-image:url('" + standAlone_images[i].src + "')"; 518 headerImg.className = "fixed_header_image"; 519 document.querySelector('#featured_story_image').insertAdjacentElement('afterend', headerImg); 520 } 521 522 //set body class if multiple standAlone images 523 if(standAlone_images.length != 0){ 524 document.body.className += ' fixed_header_multi_image'; 525 } 526 527 t74_fixed_header.images = document.querySelectorAll('.fixed_header_image' ); 528 529 console.log(standAlone_images); 530} 531 532//show hide fixed header images 533function t74_switch_feature_fixed_header_images() { 534 535 var window_y = Math.floor(t74_scroll.last_position / window.innerHeight); 536 537 //set the current 538 if ((window_y != t74_fixed_header.current) && (window_y <= t74_fixed_header.text.length)) { 539 t74_fixed_header.current = window_y; 540 541 //animating in new images 542 if( (T74_canvas.header_canvas) && (T74_canvas.header_canvas.length !== 0) ){ 543 544 //animating in 545 let start = T74_canvas.starts[t74_fixed_header.current - 1]; 546 let end = T74_canvas.ends[t74_fixed_header.current - 1]; 547 548 if(t74_fixed_header.current <= T74_canvas.starts.length){ 549 t74_animate_canvas2(start, end); 550 }else{ 551 alert('done'); 552 } 553 } 554 555 console.log('compare'); 556 console.log('current: ' + t74_fixed_header.current); 557 console.log('starts length: ' + T74_canvas.starts.length); 558 559 //hiding canvas 560 if( (t74_fixed_header.current > T74_canvas.starts.length) ){ 561 if(T74_canvas.header_canvas){ 562 T74_canvas.header_canvas.classList.remove("active"); 563 } 564 } 565 //&& (T74_canvas.header_canvas.classList.contains('active')) 566 567 //showing canvas 568 if( (t74_fixed_header.current <= T74_canvas.starts.length) ){ 569 if(T74_canvas.header_canvas){ 570 T74_canvas.header_canvas.className = 'active'; 571 } 572 } 573 //&& (T74_canvas.header_canvas.classList.contains('active')) 574 575 576 } 577 578 if(window_y <= t74_fixed_header.text.length){ 579 580 //remove all previous active 581 let active = document.querySelector("#feature_header .active"); 582 if(active !== null){ 583 active.classList.remove("active"); 584 } 585 586 //set the current active if not already set 587 if( (t74_fixed_header.images[window_y]) && !(t74_fixed_header.images[window_y].classList.contains('active')) ){ 588 t74_fixed_header.images[window_y].className += ' active'; 589 } 590 591 //show the header if not visible 592 if(t74_fixed_header.header.classList.contains('off')) { 593 t74_fixed_header.header.classList.remove("off"); 594 } 595 596 //show the canvas if it exists and is not active 597 if( (T74_canvas.header_canvas) && (T74_canvas.header_canvas.length !== 0) ) { 598 if( !(T74_canvas.header_canvas.classList.contains('active')) ) { 599 T74_canvas.header_canvas.className = "active"; 600 } 601 } 602 603 604 }else{ 605 606 //hide the header 607 if( !(t74_fixed_header.header.classList.contains('off')) ) { 608 t74_fixed_header.header.className += ' off'; 609 } 610 611 //hide the canvas if it exists 612 if( (T74_canvas.header_canvas) && (T74_canvas.header_canvas.length !== 0) ) { 613 if (T74_canvas.header_canvas.classList.contains('active')) { 614 T74_canvas.header_canvas.classList.remove("active"); 615 } 616 } 617 618 619 } 620 621 622 //console.log(DEVONA_scroll.last_position); 623 //console.log(t74_fixed_header.window_y); 624} 625 626//hide breaking news module 627function T74_set_hide_banner_cookie(){ 628 document.cookie = "hide_breaking = 1"; 629 console.log('T74_set_hide_banner_cookie');
630 t74_nav.breaking_banners.forEach(banner => 631 banner.classList.add('hide') 632 ); 633} 634 635//hide promotional banner module 636function T74_set_hide_promotional_banner_cookie(){ 637 638 let expiration_amount = 1*24*60*60*1000, // 1 Day in milliseconds 639 expires = (new Date(Date.now()+ expiration_amount)).toUTCString(); 640 641 document.cookie = "hide_promo = 1; expires=" + expires + ";path=/;" 642 t74_promotional_banner.banner.classList.add("hide"); 643} 644 645//hide toaster banner module 646function T74_set_hide_toaster_cookie(){ 647 // 1 Day = 24 Hrs = 24*60*60 = 86400. 648 let expires = (new Date(Date.now()+ 86400*1000)).toUTCString(); 649 document.cookie = "hide_toaster = 1; expires=" + expires + ";path=/;" 650 console.log('T74_set_hide_toaster_cookie'); 651 t74_toaster_banner.banner.classList.add("hide"); 652} 653 654 655// show the toaster-banner at bottom of page 656function t74_launch_toaster() { 657 658 if ( !(t74_toaster_banner.banner.classList.contains('hide')) || !(t74_toaster_banner.banner.classList.contains('launched'))) { 659 if (t74_scroll.last_position > (t74_window.height * 2) ) { 660 t74_toaster_banner.banner.classList.add('launched'); 661 console.log('banner has been launched'); 662 } 663 } 664 665} 666 667//show zero2eight archive page about pop-up 668function z2e_show_about(event) { 669 if( !(document.body.classList.contains('showz2eAbout')) ){ 670 document.body.classList.add('showz2eAbout'); 671 }else{ 672 document.body.classList.remove('showz2eAbout'); 673 } 674} 675 676 677function loadVimeoPlayer(){ 678 679 const iframe = document.querySelector('iframe'); 680 const player = new Vimeo.Player(iframe); 681 682 683 t74_about.video_overlay[0].addEventListener("click", function(){ 684 player.play().then(function(){ 685 document.body.classList.add('video_playing'); 686 }).catch(function(error) { 687 console.log(error); 688 689 }) 690 }); 691 692 693 //todo: click to play does not work when we use this... 694 /*player.getDuration().then(function(duration) { 695 let duration_minutes = Math.floor(duration / 60), 696 duration_seconds = duration % 60, 697 time = duration_minutes+':'+duration_seconds; 698 699 t74_about.video_overlay[0].innerHTML += '<span class="duration">'+time+'</span>'; 700 701 }).catch(function(error) { 702 console.log('could not get video duration'); 703 });*/ 704 705 706 707} 708 709// Register iframe is ready 710function onYouTubeIframeAPIReady() { 711 712 //youtube horizontal videos 713 t74_player = new YT.Player('player', { 714 height: '485', 715 width: '860', 716 videoId: ( (t74_videos.featured.length > 0) && typeof t74_videos.featured != 'undefined')? t74_videos.featured[0].getAttribute('data-video_id'):false, 717 playerVars: { 718 rel: 0, 719 showinfo: 0 , 720 modestbranding: 1 721 }, 722 events: { 723 'onReady': onPlayerReady, 724 'onStateChange': onPlayerStateChange 725 } 726 }); 727 728 //youtube shorts pop-up player 729 t74_player_short = new YT.Player('video_shorts_player', { 730 height: (t74_window.mobile)?'560':'686', 731 width: (t74_window.mobile)?'315':'386', 732 videoId: ( (t74_videos.short.length > 0) && typeof t74_videos.short != 'undefined')? t74_videos.short[0].getAttribute('data-shortvid_id'):false, 733 playerVars: { 734 rel: 0, 735 showinfo: 0, 736 modestbranding: 1 737 }, 738 events: { 739 'onReady': onPlayerReady 740 } 741 742 }); 743} 744 745// Register player is ready 746function onPlayerReady(){ 747 console.log('player is ready'); 748} 749 750// Register player is ready 751function onPlayerStateChange( event ){ 752 //video has started buffering 753 if (event.data == 3) { 754 document.body.classList.add("video_playing"); 755 } 756 757 //video has ended 758 if (event.data == 0 && DEVONA_videos.active && (DEVONA_videos.featured.length > 1) ) { 759 var active_video = DEVONA_videos.active[0].getAttribute('data-video_index'), 760 next_video = parseInt(active_video) + 1, 761 next_video_id = DEVONA_videos.featured[next_video].getAttribute('data-video_id') 762 ; 763 DEVONA_reset_active_video(next_video); 764 DEVONA_player.loadVideoById(next_video_id); 765 } 766} 767 768//load new video into player 769function t74_load_video(){ 770 if( window.innerWidth > 900 ){ 771 event.preventDefault(); 772 773 var video_id = this.getAttribute('data-video_id'), 774 video_index = this.getAttribute('data-video_index'); 775 776 console.log(video_index); 777 778 //DEVONA_reset_active_video(video_index); 779 t74_player.loadVideoById(video_id); 780 } 781} 782 783//load new video into player 784function t74_load_video_short(event){ 785 event.preventDefault(); 786
787 //add body class to bring up video player 788 document.body.classList.add('video_short_active'); 789 790 var video_id = this.getAttribute('data-shortvid_id'); 791 792 console.log('running a video short'); 793 console.log(t74_player_short); 794 795 t74_player_short.loadVideoById(video_id); 796} 797 798 799// load more stories 800function t74_latest_loadMore(){ 801 t74_latest_news.module.classList.add("loaded"); 802} 803 804function t74_register_subscription(event){ 805 let selector = event.target, 806 mc_tag = selector.getAttribute('data-mc_tag'), 807 radio_btn = document.getElementById(mc_tag); 808 809 console.log(mc_tag ); 810 811 // check/uncheck the sign-up form hidden radio buttons and selector icons 812 if(radio_btn.checked){ 813 radio_btn.checked = false; 814 selector.classList.remove("checked"); 815 }else{ 816 radio_btn.checked = true; 817 selector.classList.add("checked"); 818 } 819 820 //show the sign-up form 821 document.body.classList.add('show_nl_form'); 822 823} 824 825// Form submit 826function t74_formSubmit(e) { 827 if(t74_debug) console.log("FORM SUBMIT"); 828 e.preventDefault(); 829 830 // set the variables 831 var xhttp = new XMLHttpRequest(), 832 action = e.target.action, 833 data = new FormData( e.target ); 834 835 // post the form 836 xhttp.open( "POST", action, true ); 837 xhttp.onreadystatechange = function() { 838 if ( xhttp.readyState == 4 && xhttp.status == 200 ) { 839 if ( typeof xhttp.responseText != 'undefined' ) { 840 841 // set the variables 842 var parser = new DOMParser(), 843 response_dom = parser.parseFromString( xhttp.responseText, "text/html"), 844 response_value = [].slice.call( response_dom.getElementsByClassName('response_content') )[0].innerHTML; 845 846 [].slice.call( e.target.parentElement.getElementsByClassName('response') )[0].innerHTML = response_value; 847 e.target.reset(); 848 } 849 } 850 }; 851 xhttp.send( data ); 852} 853 854// show the frontpage-repeat content at bottom of single pages 855function t74_show_frontpageRepeat() { 856 857 if(t74_single.fp_repeat){ 858 859 let fp_pos = t74_single.fp_repeat.getBoundingClientRect(); 860 861 if (!(t74_single.fp_repeat.classList.contains('active'))) { 862 if (fp_pos.top < t74_window.height) { 863 //load the ajax 864 t74v2_loadFP(); 865 t74_single.fp_repeat.classList.add('active'); 866 } 867 } 868 869 } 870} 871 872// Load frontpage content 873function t74v2_loadFP() { 874 875 // set the variables 876 var xhttp = new XMLHttpRequest(); 877 878 // ajax the data from the homepage 879 xhttp.open( "GET", "/", true ); 880 xhttp.onreadystatechange = function() { 881 if ( xhttp.readyState == 4 && xhttp.status == 200 ) { 882 if ( typeof xhttp.responseText != 'undefined' ) { 883 884 // set the variables 885 var parser = new DOMParser(), 886 response_dom = parser.parseFromString( xhttp.responseText, "text/html"), 887 hp_content = response_dom.querySelector("#homepage_content"); 888 889 // add the homepage content 890 document.getElementById('frontpage-repeat-container').appendChild(hp_content); 891 892 // reset simplebar 893 t74_simpleBar.container = document.querySelector('#simplebar_container'); 894 new SimpleBar(t74_simpleBar.container); 895 896 } 897 } 898 }; 899 xhttp.send(); 900} 901 902 903// Load more 904function t74v2_loadMore(e) { 905 e.preventDefault(); 906 907 // set the variables 908 var xhttp = new XMLHttpRequest(), 909 old_button = document.getElementById("next-page"); 910 911 // remove old button 912 old_button.remove(); 913 914 // ajax the data 915 xhttp.open( "GET", old_button.href, true ); 916 xhttp.onreadystatechange = function() { 917 if ( xhttp.readyState == 4 && xhttp.status == 200 ) { 918 if ( typeof xhttp.responseText != 'undefined' ) { 919 920 // set the variables 921 var parser = new DOMParser(), 922 response_dom = parser.parseFromString( xhttp.responseText, "text/html"), 923 more_posts = document.querySelectorAll(".more_posts"), 924 container = more_posts[more_posts.length -1], //getting last instance 925 button = response_dom.getElementById("next-page"); 926 927 928 // add the list items 929 [].slice.call( response_dom.getElementById('article_listing').getElementsByClassName("post") ).forEach( function(element){ 930 container.appendChild( element ); 931 }); 932 933 // set the link 934 if ( button ) { 935 container.appendChild( button ); 936 button.onclick = function(){ t74v2_loadMore(event); }; 937 } 938 } 939 } 940 }; 941 xhttp.send(); 942} 943 944//copy text in data attribute to clipboard, set inline 945function t74_copy_to_clipboard(event) { 946 event.preventDefault(); 947 948 let clip = event.target.getAttribute("data-clip"); 949 950 navigator.clipboard.writeText(clip).then(function(x) { 951 alert("Copied: " + clip); 952 }); 953 954} 955 956//reveal the list elements sequentially 957function t74_animate_list(list_elements){ 958 959 let delay = 200; // how much time should the delay between two iterations be (in milliseconds)? 960 let promise = Promise.resolve(); 961 962 // reveal elements
963 list_elements.forEach(function (el) { 964 promise = promise.then(function () { 965 el.classList.add('active'); 966 return new Promise(function (resolve) { 967 setTimeout(resolve, delay); 968 }); 969 }); 970 }); 971 972 promise.then(function () { 973 console.log('list elements revealed'); 974 }); 975 976} 977 978//animate the latest news clock to current time or just a nice looking angle 979function t74_animate_clock(position){ 980 //set time 981 var current_time = document.getElementById('current_time'); 982 var hourHand = document.getElementById('ct_hours'); 983 var minuteHand = document.getElementById('ct_minutes'); 984 985 if(position == 'current'){ 986 //real time 987 var date = new Date; 988 var hours = date.getHours(); 989 var hours = (hours > 12)?(hours-12):hours; 990 var minutes = date.getMinutes(); 991 992 hourHand.style.transform = 'rotate('+(hours * 30)+'deg)'; 993 minuteHand.style.transform = 'rotate('+(minutes * 6)+'deg)'; 994 995 }else{ 996 //aesthetic time 997 hourHand.style.transform = 'rotate('+(90)+'deg)'; 998 minuteHand.style.transform = 'rotate('+(360)+'deg)'; 999 } 1000 1001} 1002 1003//get the heights of all the sticky blocks 1004function t74_measureStickyBlocks(){ 1005 t74_feature_story.stickers.forEach(function (sticker, i) { 1006 t74_feature_story.sticker_heights.push(sticker.offsetHeight); 1007 }) 1008 //console.log(t74_feature_story.sticker_heights); 1009} 1010 1011 1012function t74_trackStickyBlocks(){ 1013 1014 t74_feature_story.sticky_blocks.forEach(function (block, i) { 1015 1016 //set variables 1017 var block_y_pos = block.getBoundingClientRect().top, 1018 block_width = block.offsetWidth, 1019 sticker = t74_feature_story.stickers[i], 1020 sticker_height = t74_feature_story.sticker_heights[i], 1021 block_height = block.offsetHeight, 1022 in_trigger = ( (t74_window.height/2) - (sticker_height/2) ), 1023 out_trigger = ( (block_height - t74_window.height/2) - (sticker_height/2) ) * -1; 1024 1025 1026 if( (block_y_pos < in_trigger) && (block_y_pos > out_trigger)){ 1027 if(!(block.classList.contains('stuck-in'))){ 1028 block.classList.add('stuck-in'); 1029 sticker.style.top = (in_trigger) + 'px'; 1030 sticker.style.maxWidth = 'calc('+ (block_width/2) + 'px - 1em )'; 1031 } 1032 }else if(block_y_pos < out_trigger){ 1033 if( block.classList.contains('stuck-in') ){ 1034 1035 block.classList.replace('stuck-in', 'stuck-out'); 1036 } 1037 }else{ 1038 /*block.classList.remove('stuck-in','stuck-out');*/ 1039 if( (block.classList.contains('stuck-in')) ){ 1040 block.classList.remove('stuck-in'); 1041 } 1042 if( (block.classList.contains('stuck-out')) ){ 1043 block.classList.remove('stuck-out'); 1044 } 1045 } 1046 1047 }); 1048 1049} 1050 1051 1052//check if the frontpage top story has a vimeo header 1053function t74_add_video_head(){ 1054 var hero = document.querySelectorAll(".a_grid .hero .feature-image"), 1055 video_bg = ''; 1056 1057 if(hero.length){ 1058 let vimeo_thumb_id = hero[0].dataset.vimeoThumb; 1059 if(vimeo_thumb_id && vimeo_thumb_id.length){ 1060 video_bg += '<div class="fp_vimeo_wrapper">'; 1061 video_bg += '<iframe class="vimeo-head" src="https://player.vimeo.com/video/'+vimeo_thumb_id+'?autoplay=1&loop=1&autopause=0&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; 1062 video_bg += '<div>'; 1063 1064 hero[0].innerHTML = video_bg; 1065 } 1066 } 1067 1068} 1069 1070function t74_copyContents(field_id) { 1071 // Get the text field 1072 var copyText = document.getElementById(field_id); 1073 1074 // Select the text field 1075 copyText.select(); 1076 copyText.setSelectionRange(0, 99999); // For mobile devices 1077 1078 // Copy the text inside the text field 1079 navigator.clipboard 1080 .writeText(copyText.value) 1081 .then(() => { 1082 alert("Successfully copied the text."); 1083 }) 1084 .catch(() => { 1085 alert("Something went wrong, please select complete text and copy manually."); 1086 }); 1087} 1088 1089//republish box with tracking pixel 1090function t74_show_republish_box(){ 1091 event.preventDefault(); 1092 var republishBox = document.getElementById("republish-box"), 1093 repub_content = document.getElementById("repub_content"); 1094 1095 //set body class 1096 if( document.body.classList.contains('repub_open') ) { 1097 document.body.classList.remove("repub_open"); 1098 }else{ 1099 document.body.classList.add("repub_open"); 1100 1101 //add tracking pixel to share content if has not been already 1102 if( !(document.body.classList.contains('tracking_added')) ) { 1103 repub_content.innerHTML += '<img id="republication-tracker-tool-source" src="https://www.the74million.org/?republication-pixel=true&post='+republishBox.dataset.postid+'&ga3='+republishBox.dataset.gaid+'&ga4='+republishBox.dataset.ga4id+'" style="width:1px;height:1px;">'; 1104 document.body.classList.add("tracking_added"); 1105 } 1106 } 1107} 1108 1109//get the value of a set cookie 1110const getCookieValue = (name) => ( 1111 document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)')?.pop() || '' 1112) 1113 1114/* add sponsored ad data to content asynchronously */ 1115function t74_insert_advert(){ 1116 1117 if(t74_single.content.length){ 1118 1119 //let advertCookie = getCookieValue('sat74_mobileImg').content; 1120 //console.log('doosh'); 1121 //console.log(document.cookie); 1122 //console.log(advertCookie); 1123 1124 var sponsored_ad_img = (t74_window.mobile)?t74_sponsored_ad.content.dataset.sa_mobile_img:t74_sponsored_ad.content.dataset.sa_desktop_img; 1125 1126 //determine if alternate position has been set for ad 1127 var sa_position = (t74_sponsored_ad.content.dataset.sa_position)?Number(t74_sponsored_ad.content.dataset.sa_position):5; 1128 1129 //build the ad 1130 var t74_ad = '<div class="set_banner sans full sponsored_ad"><a href="'+t74_sponsored_ad.content.dataset.sa_url+'" target="_blank"><img src="'+sponsored_ad_img+'"></a></div>'; 1131 1132 //find paragraphs 1133 var ps = t74_single.content[0].getElementsByTagName("p"); 1134 // Create a new, plain <div> element 1135 var newdiv1 = document.createElement("div"); 1136 // put content etc in the div here... 1137 newdiv1.innerHTML = t74_ad; 1138 // Get a reference to the paragraph we want to insert the new div after 1139 var para_pos = ps[sa_position]; 1140 // Get a reference to the parent element 1141 var parent = para_pos.parentNode; 1142 // insert after 1143 parent.insertBefore(newdiv1, para_pos.nextSibling); 1144 } 1145} 1146 1147function t74_setup_canvas() { 1148 1149 T74_canvas.media_path = T74_canvas.header_canvas.dataset.mediapath; 1150 T74_canvas.starts = T74_canvas.header_canvas.dataset.starts.split(',').map( Number ); //converting to array 1151 T74_canvas.ends = T74_canvas.header_canvas.dataset.ends.split(',').map( Number ); //converting to array 1152 T74_canvas.fps = T74_canvas.header_canvas.dataset.fps; 1153 console.log(T74_canvas.starts[2]); 1154 1155 // Set canvas dimensions 1156 T74_canvas.header_canvas.width = t74_window.width; 1157 T74_canvas.header_canvas.height = t74_window.height; 1158 1159} 1160 1161function t74_animate_canvas2(start, end){ 1162 const canvas = T74_canvas.header_canvas; 1163 const currentFrame = index => ( T74_canvas.media_path + index +'.png'); 1164 var start_index = start; 1165 1166 // Create, load and draw the image 1167 const img = new Image(); 1168 img.src = currentFrame(start_index); // we'll make this dynamic in the next step, for now we'll just load image 1 of our sequence 1169 1170 //center content 1171 img.onload = function(){ 1172 var canvasContext = canvas.getContext('2d'); 1173 var wrh = img.width / img.height; 1174 var newWidth = canvas.width ; 1175 var newHeight = newWidth / wrh; 1176 if (newHeight > canvas.height) { 1177 newHeight = canvas.height; 1178 newWidth = newHeight * wrh; 1179 } 1180 var xOffset = newWidth < canvas.width ? ((canvas.width - newWidth) / 2) : 0; 1181 var yOffset = newHeight < canvas.height ? ((canvas.height - newHeight) / 2) : 0; 1182 1183 canvasContext.drawImage(img, xOffset, yOffset, newWidth, newHeight); 1184 1185 console.log("new_width = " + newWidth) 1186 } 1187 1188 1189 const interval = setInterval(function () { 1190 img.src = currentFrame(start_index); 1191 start_index = start_index + 1; 1192 if (start_index >= end) { 1193 clearInterval(interval); 1194 } 1195 1196 }, 100); 1197 1198} 1199 1200if( (T74_canvas.header_canvas) && (T74_canvas.header_canvas.length !== 0) ) { 1201 t74_animate_canvas2(1,13); 1202 t74_setup_canvas(); 1203} 1204 1205 1206function t74_trackVimeoReveals(){ 1207
1208 t74_feature_story.vimeo_reveals.forEach(function (block, i) { 1209 1210 //set variables 1211 var block_y_top = block.getBoundingClientRect().top, 1212 block_y_bottom = block.getBoundingClientRect().bottom, 1213 block_id = block.id; // will use this name as a body class 1214 1215 1216 //show the iframe 1217 if((block_y_top < t74_window.height/4) && !(document.body.classList.contains(block_id)) ){ 1218 document.body.classList.add(block_id); 1219 } 1220 1221 //gone above -> hide the reveal content 1222 else if( (block_y_top > t74_window.height/4) && (document.body.classList.contains(block_id)) ){ 1223 document.body.classList.remove(block_id); 1224 pauseAllVimeoIframes(); 1225 } 1226 1227 //gone below -> hide it 1228 if( (block_y_bottom < t74_window.height) && (document.body.classList.contains(block_id)) ){ 1229 document.body.classList.remove(block_id); 1230 pauseAllVimeoIframes(); 1231 } 1232 1233 }); 1234} 1235function pauseAllVimeoIframes() { 1236 // Get all iframe elements on the page 1237 var iframes = document.querySelectorAll('iframe'); 1238 1239 iframes.forEach(function(iframe) { 1240 // Check if the iframe source is from Vimeo and 1241 if ( (iframe.src.includes('player.vimeo.com')) && !(iframe.classList.contains('vimeo-head')) ) { 1242 // Create a new Vimeo Player instance for the iframe 1243 var player = new Vimeo.Player(iframe); 1244 1245 // Pause the video 1246 player.pause().then(function() { 1247 //console.log('Vimeo video paused:', iframe.src); 1248 }).catch(function(error) { 1249 //console.error('Error pausing Vimeo video:', error); 1250 }); 1251 } 1252 }); 1253} 1254 1255 1256//show or hide fixed position vimeo embeds on scroll 1257function t74_trackReveals(){ 1258 1259 t74_feature_story.reveals.forEach(function (block, i) { 1260 1261 //set variables 1262 var block_y_top = block.getBoundingClientRect().top, 1263 block_y_bottom = block.getBoundingClientRect().bottom, 1264 window_y_pos = window.pageYOffset; 1265 1266 //console.log('by:' + block_y_top); 1267 1268 //show the reveal content 1269 if((block_y_top < t74_window.height/4) && !(document.body.classList.contains('reveal')) ){ 1270 document.body.classList.add('reveal'); 1271 // is the variable is defined 1272 if (typeof map !== 'undefined') { 1273 map.resize(); 1274 //map.fitBounds(bounds, {padding: 5}); 1275 } 1276 } 1277 1278 //gone above -> hide the reveal content 1279 else if( (block_y_top > t74_window.height/4) && (document.body.classList.contains('reveal')) ){ 1280 document.body.classList.remove('reveal'); 1281 // is the variable is defined 1282 if (typeof map !== 'undefined') { 1283 //map.fitBounds(bounds, {padding: 5}); 1284 map.resize(); 1285 } 1286 1287 } 1288 1289 //gone below -> hide it 1290 if( (block_y_bottom < t74_window.height) && (document.body.classList.contains('reveal')) ){ 1291 document.body.classList.remove('reveal'); 1292 } 1293 1294 }); 1295 //console.log(t74_feature_story.reveals); 1296 //console.log('wy:' + window.pageYOffset); 1297 1298} 1299 //check if element is visible on screen 1300 function t74_checkOnScreen(elm) { 1301 var rect = elm.getBoundingClientRect(); 1302 var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight); 1303 1304 //return true or false 1305 return !(rect.bottom < 0 || rect.top - viewHeight >= 0); 1306 } 1307 1308 1309//change location of map on scroll -> specific to 'Unwelcome to America' story 1310function t74_trackMapTriggers(){ 1311 1312 let location_array = [ 1313 [0.051989304770728495, 1.3871106888221618,4.200363047136733, 5.360172942480631], //IOWA 1314 [-10.6483903001876, 3.0011346818918696,0.26811710013373613, 7.635706564326867], //WY,NEB,SD 1315 [0.8551443622113482, -2.1365873598924594,4.351608705471278, 2.3770870792998267], //MISSOURI 1316 [-23.126553620704698, -13.107438323555286,21.192541038109653, 9.820852305507586],//CA,TX,NY,FL 1317 [-21.09625438382639, -5.414518209156967,-13.95264626542064, 5.10616931565626],//CA 1318 [-21.09625438382639, -5.414518209156967,-13.95264626542064, 5.10616931565626],//CA 1319 [11.878483666526108, 2.8825300875861615,18.377709289393863, 9.30006701568982],//NY 1320 [5.724030986168174, 2.9726749170307443,6.844263802307324, 4.180506603102074],//ILL 1321 [-21.643456821879965, -7.618637175419508, -6.997286839826813, 6.277941569474933], //NV,AZ 1322 [-21.643456821879965, -7.618637175419508, -6.997286839826813, 6.277941569474933], //NV,AZ 1323 [-18.674292438037668, -1.9612915334014644, -11.914336329571682, 5.496753657644987], //AZ, TIGHT 1324 ]; 1325
1326 t74_feature_story.map_triggers.forEach(function (trigger, i) { 1327 1328 1329 //set variables 1330 var trigger_top = trigger.getBoundingClientRect().top, 1331 trigger_bottom = trigger.getBoundingClientRect().bottom; 1332 1333 //document.getElementById('screen-nums').innerHTML = 'trigger_top:' + trigger_top + ' | ' + 'trigger_bottom:' + trigger_bottom + ' | window-height/2:' + t74_window.height/2; 1334 1335 //trigger the change if within range and has not fired/active 1336 if( (trigger_top < (t74_window.height/2)) && (trigger_bottom > (t74_window.height/2)) ) { 1337 if( !(trigger.classList.contains('active')) ){ 1338 trigger.classList.add('active'); 1339 1340 /*map.flyTo({ 1341 center: [location_array[i][0], location_array[i][1]], 1342 essential: true, 1343 zoom: location_array[i][2] 1344 });*/ 1345 const popup = document.getElementsByClassName('mapboxgl-popup'); 1346 if ( popup.length ) { 1347 popup[0].remove(); 1348 } 1349 1350 map.fitBounds([ 1351 [location_array[i][0], location_array[i][1]], // [lng, lat] - southwestern corner of the bounds 1352 [location_array[i][2], location_array[i][3]], // [lng, lat] - northeastern corner of the bounds 1353 ]); 1354 1355 1356 1357 } 1358 }else{ 1359 if(trigger.classList.contains('active')){ 1360 trigger.classList.remove('active'); 1361 //alert('trigger remove number:' + i); 1362 } 1363 } 1364 1365 1366 }); 1367} 1368 1369//add or remove a body class when element is onscreen 1370function t74_trackBodyTriggers(){ 1371 1372 1373 t74_feature_story.body_triggers.forEach(function (trigger, i) { 1374 1375 1376 //set variables 1377 var trigger_top = trigger.getBoundingClientRect().top, 1378 trigger_bottom = trigger.getBoundingClientRect().bottom, 1379 trigger_id = trigger.id; //using the name of the id as a body class 1380 1381 1382 //trigger the change if within range and has not fired/active 1383 if( (trigger_top < (t74_window.height/2)) ) { 1384 if( !(trigger.classList.contains('active')) ){ 1385 trigger.classList.add('active'); 1386 1387 //adding name of trigger_id as class to the body 1388 if( !(document.body.classList.contains(trigger_id)) ){ 1389 console.log('hurrah'); 1390 document.body.classList.add(trigger_id); 1391 } 1392 1393 } 1394 }else{ 1395 if(trigger.classList.contains('active')){ 1396 trigger.classList.remove('active'); 1397 1398 //removing the class 1399 if( document.body.classList.contains(trigger_id) ){ 1400 console.log('goodbye'); 1401 document.body.classList.remove(trigger_id); 1402 } 1403 1404 } 1405 } 1406 1407 1408 }); 1409} 1410 1411//generic function to add active class on click 1412function t74_activate(element) { 1413 console.log(element); 1414 if(element.classList.contains('is_active')){ 1415 element.classList.remove('is_active'); 1416 }else{ 1417 element.classList.add('is_active'); 1418 } 1419 console.log('activating element'); 1420} 1421 1422//set slideshow to locked when at top of screen 1423function t74_lock_slideshow(){ 1424 1425 let slideShow_WindowPosition = t74_slideshow.vertical.getBoundingClientRect().top; 1426 1427 console.log('scrolling direction: ' + t74_scroll.direction); 1428 console.log('slideshow window is' + slideShow_WindowPosition + ' from the top'); 1429 1430 //scrolling down 1431 if(t74_scroll.direction === 'down'){ 1432 if( (slideShow_WindowPosition < 0) && !(document.body.classList.contains('lock_slideshow')) && (t74_slideshow.vertical_scrollPos !== 'bottomed_out') ) { 1433 document.body.classList.add('lock_slideshow'); 1434 }else if( (document.body.classList.contains('lock_slideshow')) && (t74_slideshow.vertical_scrollPos === 'bottomed_out') ) { 1435 document.body.classList.remove('lock_slideshow'); 1436 } 1437 } 1438 1439 //scrolling up 1440 else if(t74_scroll.direction === 'up'){ 1441 if( (slideShow_WindowPosition >= 0) && !(document.body.classList.contains('lock_slideshow')) && (t74_slideshow.vertical_scrollPos === 'bottomed_out') ) { 1442 document.body.classList.add('lock_slideshow'); 1443 } 1444 else if( (document.body.classList.contains('lock_slideshow')) && (t74_slideshow.vertical_scrollPos === 'topped_out') ) { 1445 document.body.classList.remove('lock_slideshow'); 1446 } 1447 } 1448} 1449 1450//track the inner scroll position of the vertical slideshow 1451function t74_getVerticalSlideshowContainerScrollPosition(){ 1452 if( (t74_slideshow.vertical.scrollTop + t74_slideshow.vertical.offsetHeight) >= (t74_slideshow.vertical.scrollHeight) ){ 1453 t74_slideshow.vertical_scrollPos = 'bottomed_out'; 1454 }else if(t74_slideshow.vertical.scrollTop === 0){ 1455 t74_slideshow.vertical_scrollPos = 'topped_out'; 1456 }else{ 1457 t74_slideshow.vertical_scrollPos = 'scrolling';
1458 } 1459 1460 //t74_slideshow.vertical_scrollTop = t74_slideshow.vertical.scrollTop; 1461 console.log('scrollTop: ' + t74_slideshow.vertical.scrollTop); 1462 console.log('scrollTop + offsetHeight: ' + (t74_slideshow.vertical.scrollTop + t74_slideshow.vertical.offsetHeight)); 1463 console.log('scrollHeight is: ' + t74_slideshow.vertical.scrollHeight); 1464 console.log('vertical_scrollPos:' + t74_slideshow.vertical_scrollPos); 1465 //5904 1466 //console.log('scroll position is' + t74_slideshow.vertical_scrollPos); 1467} 1468/* FIRE 1469-------------------------------------------------------------------------- */ 1470//load page at top 1471window.scrollTo(0, 0); 1472 1473// open all external links in new window 1474t74_targetExternalLinks(); 1475 1476// get font size 1477t74_set_fontRatio(); 1478 1479// Ticker 1480if(t74_ticker.ticker){ 1481 t74_generateTick(); 1482} 1483 1484// Slideshow 1485if(t74_slideshow.container) { 1486 t74_initSlideShow(); 1487 console.log(t74_slideshow.slides); 1488} 1489 1490// Feature Story 1491if(t74_feature_story.sticky_title.length !== 0){ 1492 t74_truncate_sticky_title(); 1493} 1494 1495// Feature Story: Sticky Blocks 1496if( (t74_window.width > 959) && t74_feature_story.sticky_blocks ) { 1497 t74_measureStickyBlocks(); 1498 window.onscroll = function(){ 1499 t74_trackStickyBlocks 1500 } 1501} 1502 1503// Feature Story: Reveals 1504if( (t74_window.width > 959) && t74_feature_story.reveals ) { 1505 window.onscroll = function(){ 1506 t74_trackReveals(); 1507 } 1508} 1509 1510 1511// Vimeo Header 1512if(document.querySelectorAll(".a_grid .hero .feature-image").length){ 1513 t74_add_video_head(); 1514} 1515 1516//Simplebar scroller: apply simplebar script to 'simplebar_container' element when window is wide enough 1517if( (t74_window.width > 959) && (t74_simpleBar.container) ){ 1518 new SimpleBar(t74_simpleBar.container); 1519}else{ 1520 console.log('window width = '+t74_window.width+': simplebar disabled'); 1521} 1522 1523 1524//Swiper: initialize script for horizontal scrolling content 1525let swiper = new Swiper('.swiper', { 1526 resistanceRatio: 0.5, 1527 slidesPerView: 'auto', 1528}); 1529 1530let swiper_paginate = new Swiper('.swiper_paginate', { 1531 resistanceRatio: 0.5, 1532 slidesPerView: 'auto', 1533 pagination: { 1534 el: ".swiper-pagination", 1535 }, 1536}); 1537 1538let swiper_support_page = new Swiper('.swiper_support_page', { 1539 resistanceRatio: 0.5, 1540 slidesPerView: 'auto', 1541 wrapperClass: 'wp-block-group__inner-container', 1542}); 1543 1544//sponsored ads 1545if(t74_sponsored_ad.content){ 1546 t74_insert_advert(); 1547} 1548let reveal_element = document.querySelectorAll('.reveal'); 1549 1550 1551 1552 1553/* BIND 1554-------------------------------------------------------------------------- */ 1555 1556//listen for scroll to expand nav 1557window.onscroll = function() { 1558 t74_trackNav(); 1559 t74_trackScroll(); 1560 t74_trackStickyBlocks(); 1561 t74_show_frontpageRepeat(); 1562 if (t74_toaster_banner.banner) { 1563 t74_launch_toaster(); 1564 } 1565 t74_trackReveals(); 1566 t74_trackVimeoReveals(); 1567 t74_trackMapTriggers(); 1568 t74_trackBodyTriggers(); 1569 if(t74_slideshow.vertical){ 1570 t74_lock_slideshow(); 1571 } 1572}; 1573 1574// Set fixed header images 1575if( (t74_fixed_header.hero) && (t74_fixed_header.hero.classList.contains('fixed_header_image')) ){ 1576 t74_insert_feature_fixed_header_images(); 1577} 1578 1579//show menu 1580document.getElementById('menu_button').addEventListener('click', t74_showNav, false); 1581 1582//show search bar 1583t74_nav.search.addEventListener('click', t74_showSearch, false); 1584 1585if(t74_latest_news.module){ 1586 let list_elements = t74_simpleBar.container.getElementsByTagName("li"); 1587 t74_animate_list(list_elements); 1588 t74_animate_clock(); 1589 1590 //load more Latest News stories 1591 t74_latest_news.load_more.forEach(element => 1592 element.addEventListener("click", t74_latest_loadMore) 1593 ); 1594 1595} 1596 1597//show layout selector 1598t74_layout.buttons.forEach(button => 1599 button.addEventListener("click", t74_showLayoutSelector) 1600); 1601 1602//set-up Vimeo player 1603if(t74_about.vimeo_wrapper) { 1604 //loadVimeoPlayer(); 1605} 1606 1607t74_about.mission_video.forEach(function (element, index){ 1608 element.addEventListener("click", function(event){ 1609 document.body.classList.add('vimeo_playing'); 1610 }); 1611}); 1612 1613// Chapter Nav: scroll to selected feature story chapter 1614t74_feature_story.chapter_nav.forEach(function (element, index){ 1615 element.addEventListener("click", function(event){ 1616 t74_scrollToChapter(event, index); 1617 }); 1618}); 1619 1620// Sticky Chapter Nav: scroll to selected feature story chapter 1621t74_feature_story.sticky_nav.forEach(function (element, index){ 1622 element.addEventListener("click", function(event){ 1623 t74_scrollToChapter(event, index); 1624 }); 1625}); 1626 1627// expand accordion content
1628t74_accordion.triggers.forEach(function (element){ 1629 element.addEventListener("click", function(event){ 1630 t74_expand_accordion_content(event); 1631 }); 1632}); 1633 1634// expandable content 1635t74_single.expand.forEach(function (element){ 1636 element.addEventListener("click", function(event){ 1637 t74_showExpandables(event); 1638 }); 1639}); 1640 1641// add an active class to generic elements 1642t74_single.activate.forEach(function (element){ 1643 element.addEventListener("click", function(event){ 1644 t74_activate(element); 1645 }); 1646}); 1647 1648// breaking news banner 1649if(t74_nav.breaking_banners) { 1650 t74_nav.breaking_buttons.forEach(button => 1651 button.addEventListener("click", T74_set_hide_banner_cookie, false) 1652 ); 1653} 1654 1655// promotional banner 1656if(t74_promotional_banner.banner) { 1657 t74_promotional_banner.close.addEventListener("click", T74_set_hide_promotional_banner_cookie, false); 1658} 1659 1660// toaster banner 1661if(t74_toaster_banner.banner) { 1662 t74_toaster_banner.close.addEventListener("click", T74_set_hide_toaster_cookie, false); 1663 if(t74_toaster_banner.link) { 1664 t74_toaster_banner.link.addEventListener("click", T74_set_hide_toaster_cookie, false); 1665 } 1666 //process the newsletter sign-up 1667 [].slice.call( document.getElementsByClassName('toaster-email-form') ).forEach( function(tform){ 1668 tform.onsubmit = function(){ 1669 t74_formSubmit(event); 1670 }; 1671 }); 1672} 1673 1674//inline forms 1675if(t74_single.inline_form){ 1676 t74_single.inline_form.onsubmit = function(){ 1677 t74_formSubmit(event); 1678 }; 1679} 1680 1681//listen for clicks on featured video list 1682for (var i = 0; i < t74_videos.featured.length; i++) { 1683 t74_videos.featured[i].addEventListener('click', t74_load_video, false); 1684} 1685 1686//listen for clicks on video shorts links 1687for (var i = 0; i < t74_videos.short.length; i++) { 1688 t74_videos.short[i].addEventListener('click', t74_load_video_short, false); 1689} 1690 1691// hide the video short 1692if(document.getElementById('video_shorts_container')){ 1693 document.getElementById('video_shorts_container').addEventListener('click', function(event){ 1694 document.body.classList.remove('video_short_active'); 1695 t74_player_short.pauseVideo(); 1696 }); 1697} 1698 1699 1700//Video Category Page: change hero video on swipe 1701swiper_paginate.on('transitionEnd', function() { 1702 let index = swiper_paginate.realIndex + 1, 1703 video_id = t74_videos.featured[index].getAttribute('data-video_id'); 1704 1705 t74_player.loadVideoById(video_id); 1706 console.log(video_id); 1707 console.log('swiper_paginate.realIndex --->', swiper_paginate.realIndex + 1); 1708}); 1709 1710//process the newsletter sign-up 1711[].slice.call( document.getElementsByClassName('email-form') ).forEach( function(form){ 1712 form.onsubmit = function(){ t74_formSubmit(event); }; 1713}); 1714 1715//newsletters 1716t74_newsletters.selectors.forEach(function (selector){ 1717 selector.addEventListener("click", function(event){ 1718 t74_register_subscription(event); 1719 }); 1720}); 1721 1722//get font size based on screen width; 1723window.addEventListener("resize", function(event) { 1724 t74_set_fontRatio(); 1725}); 1726 1727// load more buttons 1728[].slice.call( document.getElementsByClassName('load-more') ).forEach( function( link ){ 1729 link.onclick = function(){console.log(event); t74v2_loadMore(event); }; 1730}); 1731 1732// zero2eight about pop-up 1733if(zero2eight.about_triggers) { 1734 zero2eight.about_triggers.forEach(function (trigger) { 1735 trigger.addEventListener("click", function (event) { 1736 z2e_show_about(event); 1737 }); 1738 }); 1739} 1740 1741//track for scrolls on Vertical Slideshow Container 1742if(t74_slideshow.vertical){ 1743 t74_slideshow.vertical.addEventListener('scroll', t74_getVerticalSlideshowContainerScrollPosition); 1744}
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.