The Right-Wing Outrage Cycle

‘);
}
});

/*
* Scroll IF # id exist in URL
*/
if(url_id!=”){
var s = url_id;
var n = s.indexOf(‘/’);
if(n!=”&& typeof n!= ‘undefined’){
var id_var = s.substring(0, n != -1 ? n : s.length);
$(‘html, body’).animate({
scrollTop: $(‘#’+id_var).offset().top
},2000);
return false;
}
}

/*
* Check for audio
*/

/*
* script to handle Back Button Event
*/

if(window.attachEvent){
window.attachEvent(‘onpopstate’, datHash);
}

function datHash(event){
var str = $(‘#goback’).val();
if(str==”){
window.history.go(-Math.abs(pageChange));
}else{
window.history.go(-Math.abs(pageChange));
}
return false;
}

/*
*
*/
$(‘.post-edit-link’).attr(‘href’, function( _, action){
return action.replace(‘https’, ‘http’);
});

/*
* @function for load article in infinite scroll
*/

$(‘a.inifiniteLoader’).hide();

function loadArticle(pageNumber){

$(‘a.inifiniteLoader’).show(‘fast’);

$.ajax({

url : “https://www.thenation.com/wp-admin/admin-ajax.php”,
type : ‘POST’,
cache : false,
dataType : ‘json’,
data : {action:’infinite_scroll’,page_no: pageNumber,loop_file: ‘articleload’,slug:’humor,media,republicans,conservatives-and-the-american-right’,curr_post_id:’384830′},
success : function(receivedHTML){

if ( typeof receivedHTML == ‘object’ && receivedHTML!=null ){
if(typeof receivedHTML.html!==’undefined’ && receivedHTML.html!=”){
html = receivedHTML.html;
}
}else{
$(‘a.inifiniteLoader’).hide();
$(“#single_article_footer”).show();
}

$(‘a.inifiniteLoader’).hide(‘1000’);

if ( typeof receivedHTML == ‘object’ && receivedHTML!=null ){

$(“#wrap”).append(html); // This will be the div where our content will be loaded

var postID = $($.parseHTML(html)).filter(“.scrolltrace”).attr(‘article-post-id’);

$(‘.abody-‘+postID+’ .article-body-inner’).children(‘p:first-of-type’).html(function (i, html) {
if ( $(‘.abody-‘+postID).children(‘img’).length == “0” ){
var text = $(‘.abody-‘+postID+’ .article-body-inner’).children(‘p:first-of-type’).html();
$(‘.abody-‘+postID+’ .article-body-inner’).children(‘p:first-of-type’).html(text.replace(/^()?([A-Za-z0-9])/g,’$1$2‘));
}
});

if( !$(‘.abody-‘ + postID +”).parent().parent().hasClass(‘textContainer_Truncate’) ){
$(‘

‘).insertAfter(‘.abody-‘ + postID);
}

/*
* Article Divider Count
*/
article_divider = article_divider+1;
$(‘.abody-‘+postID+”).attr(“article-number”,article_divider);

/*for hiding meterpaywall popups when pixel ads call starts here*/
var hidePixelBool = false;
var meetkatstep1 = jQuery(‘#paywall .step.one’);
var meetkatstep2 = jQuery(‘#paywall .step.two’);
var meetkatstep3 = jQuery(‘#paywall .step.three’);
var meetkatstep4 = jQuery(‘#paywall .step.four’);
if( typeof meetkatstep1!=’undefined’ && meetkatstep1.is(‘:visible’) ){
hidePixelBool = true;
}
if ( typeof meetkatstep2!=’undefined’ && meetkatstep2.is(‘:visible’) ){
hidePixelBool = true;
}
if( typeof meetkatstep3!=’undefined’ && meetkatstep3.is(‘:visible’) ){
hidePixelBool = true;
}
if( typeof meetkatstep4!=’undefined’ && meetkatstep4.is(‘:visible’) ){
hidePixelBool = true;
}
if( hidePixelBool===false ){
/*for hiding meterpaywall popups when pixel ads call ends here*/
/****Alternate Popup code start*********/
var enable_alterpopup_check;
enable_alterpopup_check =”;
if( typeof(enable_alterpopup_check) != “undefined” && enable_alterpopup_check == 1 ){
var alternate_article_no;
alternate_article_no = ”;
if( pageCounterPaywall % alternate_article_no == 0 && pageCounterPaywall!=0 ){
show_lightbox(”,”);
}
}
/******Alternate Popup code End********/
}

pageCounterPaywall++;
ajaxCarousel(postID);
ajaxGallery(postID);
articleNLogo(postID);

/** Slider Content **/
flag = false;
$(‘section.article-body:last img’).each(function(){
if($(this).parent(“a”).parent(“figure”).hasClass(‘bx-item’)){
flag = true;
}else{
$(this).parent(“a”).addClass(“gallery”);
}
});

if(flag){
var k = $(‘section.article-body:last’).find(‘.gallery-2’).bxSlider({
adaptiveHeight: true,
adaptiveHeightSpeed: 500,
infiniteLoop: false,
hideControlOnEnd: false,
pager: false
});
k.reloadSlider();
}
/* Slider Content End */

var usera = navigator.userAgent.toLowerCase();
if ( $(‘.article-page’).length ) {
var slickWidth = $(‘.article-list.slick-slide’).width();

if ($(‘.ie9’).length){
slickWidth = $(‘.recirc-carousel.slick-initialized.slick-slider’).width();
}
$(‘.slick-list.draggable’).css({‘width’ : slickWidth});
if( !/android|webos|iphone|ipad|ipod|blackberry/i.test(usera) ){
$(‘.article-list.slick-slide’).children(‘li’).css({‘width’ : slickWidth});
$(‘.slick-list’).css({‘width’ : slickWidth});
}
}

var $newArticles = $(html);
var imagesLoading = [];

$newArticles.find(‘img’).each(function() {

// For each image, create a new deferred object that resolves when the
// image has loaded and add that to an array of deferred objects.

var loadingImage = $.Deferred();
imagesLoading.push(loadingImage);

// “this” is the image element here and should have a complete property.
// See http://stackoverflow.com/a/24201249

if (this.complete){
loadingImage.resolve();
}else{
var adTimeout = window.setTimeout(function() {
loadingImage.resolve();
}, 3000);

this.addEventListener(‘load’, function() {
loadingImage.resolve();
window.clearTimeout(adTimeout);
});

this.addEventListener(‘error’, function() {
// We really don’t care if the image never loads, but we still need
// to resolve the promise so that we can reset the waypoints.
loadingImage.resolve();
window.clearTimeout(adTimeout);
});

// Clean up event listeners
this.removeEventListener(‘load’, function() {
loadingImage.resolve();
window.clearTimeout(adTimeout);
});
this.removeEventListener(‘error’, function() {
loadingImage.resolve();
window.clearTimeout(adTimeout);
});
}
});

$.when.apply(this, imagesLoading).then(function() {
fixedAds($(‘.postid-‘ + postID).children(‘article’));
}, function() {
console.log(arguments);
});
}
}
});
return false;
}

/*
* Load second article on scroll
*/

$(window).bind(‘scroll’, function(){

$(‘.scrolltrace’).each(function(){

var post = $(this);
var topp = post.position().top;
var bott = post.position().top + post.height();
var pos = $(window).scrollTop();

if ( pos>=topp && pos 0){

}else{
window.history.pushState({}, “”, $(‘.currentScr’).attr(‘articlelistlinks’));

articlePostId = $(‘.currentScr’).attr(“article-post-id”);

/*New non subscriber For Infinite Scroll*/
if (null != is_user_logged_in) {
var tn_sfg_local = localStorage.getItem(“tn_sfg_local”);
if (null != tn_sfg_local && undefined != tn_sfg_local && ” != tn_sfg_local) {
tn_sfg_local = JSON.parse(tn_sfg_local);
if (tn_sfg_local.includes(parseInt(articlePostId))) {
$(‘.currentScr’).find(‘.tn-sfg-add-to-list’).addClass(‘selected’);
$(‘.currentScr’).find(‘.tn-sfg-add-to-list’).removeClass(‘hide’);
}else {
$(‘.currentScr’).find(‘.tn-sfg-add-to-list’).removeClass(‘hide’);
}
} else {
$(‘.currentScr’).find(‘.tn-sfg-add-to-list’).removeClass(‘hide’);
}
}
/*New non subscriber For Infinite Scroll*/

var allSubject = $(‘.postid-‘+articlePostId+’.currentScr input[name=”tpTags”]’).val();
var allAuthor = $(‘.postid-‘+articlePostId+’.currentScr input[name=”tpContentAuthor”]’).val();

var username = getCookie(‘SESSname’);
if(username != null){
_cbq.push([‘_acct’, ‘paid’]);
}else{
_cbq.push([‘_acct’, ‘anon’]);
}

console.log(“Chartbeat”);
pSUPERFLY.virtualPage({
sections: allSubject,
authors : allAuthor,
path : window.location.pathname,
title : $(‘.currentScr’).attr(‘articlelisttitle’)
});
}

/* Taxonomy and Author Trigger in GA Event Start */
var allSubject = allSubject.split(‘,’);
$.each( allSubject, function( i, allsubval ) {
gaTaxonomyAuthor( allsubval, $(‘.currentScr’).attr(‘articlelisttitle’), $(‘.currentScr’).attr(‘articlelistlinks’) );
});

var allAuthor = allAuthor.split(‘,’);
$.each( allAuthor, function( i, allautval ) {
gaTaxonomyAuthor( allautval, $(‘.currentScr’).attr(‘articlelisttitle’), $(‘.currentScr’).attr(‘articlelistlinks’) );
});
/* Taxonomy and Author Trigger in GA Event End */

/*
* Call Email Signup for infinite scroll
*/
if( !$(‘.postid-‘+articlePostId+’ .article-body img’).parent(“a”).parent(“figure”).hasClass(‘bx-item’) ){

if( !$(“.abody-“+articlePostId+””).hasClass(“email-signup-visited”) ){
email_signup_module( articlePostId );
}
}

/* Content Page View Event */
dataLayer.push({
‘event’: ‘gaPageViewEvent’,
‘gaEventCategory’: ‘article’,
‘gaEventAction’: $(‘.currentScr’).attr(‘articlelisttitle’),
‘gaEventLabel’: articlePostId,
});
/* Content Page View Event */

/*
* Article Divider Scrolled Over Total Count
*/
dataLayer.push({
‘event’: ‘gaRecirculationEvent’,
‘gaEventCategory’: ‘recirculation’,
‘gaEventAction’: ‘article-divider-scrolled-over’,
‘gaEventLabel’: $(‘.currentScr’).attr(‘articlelistlinks’),
});

/*
* Article Divider Scrolled Over Individual Count
*/
article_number = $(‘.abody-‘+articlePostId+”).attr(“article-number”);
if (typeof article_number !== typeof undefined && article_number !== false) {
dataLayer.push({
‘event’: ‘gaRecirculationEvent’,
‘gaEventCategory’: ‘recirculation’,
‘gaEventAction’: ‘article-divider-scrolled-over-‘+article_number+”,
‘gaEventLabel’: $(‘.currentScr’).attr(‘articlelistlinks’),
});
}

// Google Analytics for Infinite Scroll
/*ga(‘send’, ‘pageview’, {
‘page’: $(‘.currentScr’).attr(‘articlelistlinks’),
‘title’: $(‘.currentScr’).attr(‘articlelisttitle’)
});*/
console.log(“Google”);
ga(‘set’, ‘dimension1’, $(‘.currentScr’).find(‘.tn_publish_date’).text());
ga(‘send’, ‘pageview’, {
‘page’: window.location.pathname,
‘title’: $(‘.currentScr’).attr(‘articlelisttitle’)
});

dataLayer.push({
‘event’:’InfiniteScrollPageView’,
‘virtualPageURL’: window.location.pathname,
‘virtualPageTitle’ : $(‘.currentScr’).attr(‘articlelisttitle’)
});

$(“nav.primary ul li.article-meta h2”).html($(‘.currentScr’).attr(‘articlelisttitle’).substring(0,100));
$(“title”).html($(‘.currentScr’).attr(‘articlelisttitle’));

var linktext = $(‘.currentScr’).find(“.anchor_subject”).html();
if ( linktext!=” ){

var linkredirectval =$(‘.currentScr’).find(“.anchor_subject”).attr(‘subjectlink’);

if(typeof linkredirectval!=’undefined’){
var subject_head_link = ““+linktext+”“;
$(‘.tophead_subject’).html(subject_head_link);
}else{
var subject_head_link = “”;
$(‘.tophead_subject’).html(subject_head_link);
}

}

pageChange = parseInt(pageChange) + 1;
}

}else{
$(this).removeClass(‘currentScr’);
}
});

$current_article = $(‘.scrolltrace.currentScr’);
// Load next leaderboard ad on reach to bottom action tout
if($current_article.hasClass(‘currentScr’)){

articlePostId = $(‘.currentScr’).attr(“article-post-id”);

var windowTop = $(window).scrollTop();

if( $current_article.find(‘.expand-reduce’).length != 0 ){

if( !$(‘#expand-reduce-‘+articlePostId+”).hasClass(‘expand-close’) && !$(‘#expand-reduce-‘+articlePostId+”).hasClass(‘tn-first-expand’)){

if( $(‘.abody-‘+articlePostId+”).hasClass(‘keep-reading’) ){

/* Overflow Hidden Parent Div */
$(‘.abody-‘+articlePostId+”).parent().addClass(“keep-reading-parent”);

/* Hide Article Footer */
$(‘#article-footer-‘+articlePostId+”).hide();

/* Hide Rev Content Block */
$(‘#tabola-block-‘+articlePostId+”).hide();

/* Hide aside wrap modules */
$(‘.scrolltrace.currentScr .aside-wrap .ad-wrap’).not(‘:eq(0)’).hide();

/* Show expand Reduce */
$(‘#expand-reduce-‘+articlePostId+”).show();
}else{

// Execute when the page loaded
eval(“pushDataPianoOnInfinite_”+articlePostId+”()”);
tp.experience.execute();

}
}
}
}

var loadPoint = $(‘.article-body:last’).offset().top – 68;

if (loadPoint!=false && $(window).scrollTop() >= loadPoint){
if( $(‘.scrolltrace’).length==count ){

loagAgn = true;

if(loagAgn){
count++;

if(count
eval(“pushDataPianoOnInfinite_”+$article_id+”()”);
// Execute when the page loaded
tp.experience.execute();

$(‘.abody-‘+$article_id+”).removeClass(‘keep-reading’);

$(‘.abody-‘+$article_id+”).removeClass(‘no-reading’);

/* Overflow Visible Parent */
$(‘.abody-‘+$article_id+”).parent().removeClass(“keep-reading-parent”);

/* Show Article Footer */
$(‘#article-footer-‘+$article_id+”).show();

/* Show Rev Content Block */
$(‘#tabola-block-‘+$article_id+”).show();

/* Show aside wrap modules */
$(‘.postid-‘+$article_id+’ .aside-wrap .ad-wrap’).not(‘:eq(0)’).show();

/* Hide expand Reduce */
$(‘#expand-reduce-‘+$article_id+”).hide();

/*
* Related Single Article Track
*/
relatedSingleArticle( $article_id );

/*
* Related Multiple Article Track
*/
relatedMultiArticle( $article_id );

/*
* Current Issue Module Track
*/
currentIssueModule( $article_id );

/*
* Inline CTA One Track
*/
inlineCtaOne( $article_id );

/*
* Inline CTA Two Track
*/
inlineCtaTwo( $article_id );

/*
* Inline CTA Two Track
*/
inlineCtaSignup( $article_id );

/*
* Author Highlight Track
*/
authorHighlight( $article_id );

/*
* Series Module Track
*/
seriesModule( $article_id );

/*
* Comment Module Track
*/
commentModule( $article_id );

/*
* Books Salad Track
*/
booksSalad( $article_id );

/*
* Action Tout Module Track
*/
actionToutModule( $article_id );

/*
* Sidebar Community Module Track
*/
sidebarCommunityModule( $article_id );
tp.push([“setCustomVariable”, “book_and_arts_article”, “false”]);
console.log(“pushed variable book_and_arts_article false”);

});

$(‘body’).on(‘click’,’.click_comment’,function(event){

event.preventDefault();

/* Basic Data */
var article_id = $(this).attr(“article-post-id”);
var comment_container = $(this).closest(‘.article-footer’).find(‘.commentContainer’);
var post_comment_list = comment_container.find(‘.post_comment_list’);
var _loader = comment_container.find(‘.post_comment_list_loader’);
var _count = $(this).find(‘.title’);

/* Check if user logged_in */
$is_user_logged_in = false;
$username = getCookie(‘SESSname’);
if( $username != null ){
$is_user_logged_in = true;
$username = Base64.decode($username);
comment_container.find(‘.logged-in-as’).find(‘.login_user’).html($username);
}

if( $is_user_logged_in ){
comment_container.find(‘form’).show();
}else{
comment_container.find(‘.must-log-in’).show();
}
/* Check if user logged_in */

/* Open commnet section */
comment_container.slideToggle(‘slow’);

/* Add close class */
$(this).find(‘.open’).toggleClass(‘close’);

/* Check for ajax call */
if( post_comment_list.html().length == 0){

/* Change Focus */
try{
comment_container.find(‘textarea’).focus();
}catch(e){}

/* post_comment_list_loader */
_loader.show();

$.ajax({
url :ajax_object.ajax_url,
data:{
‘action’ : ‘article_comment_list’,
‘article_id’ : article_id
},
type:’POST’,
success:function( response ){
if( typeof response == ‘string’ ){
response = JSON.parse( response );
if( response.status == ‘success’ ){
_loader.hide();
post_comment_list.before(response.sorting);
post_comment_list.append(response.comment_list);
_count.html(‘Comments (‘+response.count+’)’);
}else if( response.status == ‘fail’ ){
_loader.hide();
}
}
}
});
}
});

jQuery( “.action_tout_remove_gallery a” ).removeClass( “gallery imgHover” ).delay( 1000 );

$(document).on(‘click’,’.nation_convsersation’,function(event){

event.preventDefault();

/* Basic Data */
var article_id = $(this).attr(“article-id”);
var _click_comment = $(‘.postid-‘+article_id+’ .click_comment’);
var comment_container = _click_comment.closest(‘.article-footer’).find(‘.commentContainer’);
var post_comment_list = comment_container.find(‘.post_comment_list’);
var _loader = comment_container.find(‘.post_comment_list_loader’);
var _count = _click_comment.find(‘.title’);

/* Check if user logged_in */
$is_user_logged_in = false;
$username = getCookie(‘SESSname’);
if( $username != null ){
$is_user_logged_in = true;
$username = Base64.decode($username);
comment_container.find(‘.logged-in-as’).find(‘.login_user’).html($username);
}

if( $is_user_logged_in ){
comment_container.find(‘form’).show();
}else{
comment_container.find(‘.must-log-in’).show();
}
/* Check if user logged_in */

/* Open commnet section */
comment_container.slideToggle(‘slow’);

/* Add close class */
$(‘html, body’).animate({scrollTop: _click_comment.offset().top},2000);
_click_comment.find(‘.open’).toggleClass(‘close’);

/* Check for ajax call */
if( post_comment_list.html().length == 0){

/* Change Focus */
try{
comment_container.find(‘textarea’).focus();
}catch(e){}

/* post_comment_list_loader */
_loader.show();

$.ajax({
url :ajax_object.ajax_url,
data:{
‘action’ : ‘article_comment_list’,
‘article_id’ : article_id
},
type:’POST’,
success:function( response ){
if( typeof response == ‘string’ ){
response = JSON.parse( response );
if( response.status == ‘success’ ){
_loader.hide();
post_comment_list.before(response.sorting);
post_comment_list.append(response.comment_list);
_count.html(‘Comments (‘+response.count+’)’);
}else if( response.status == ‘fail’ ){
_loader.hide();
}
}
}
});
}

});

$(“.social-share-icon”).click(function(){
$(“.nav-toggle, .logo”).toggleClass(“hidden”);
$(“.share-icons”).toggleClass(“slide-share”);
$(“.header-bar a.social-sharing”).toggleClass(“share-icons-close”);
});

/*
* Click Event Tracking for Related Single Article
*/

$(document).on(‘click’, ‘.related-oneup-click’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaRelatedSingleArticleEvent’,
‘gaEventCategory’: ‘related-single-article’,
‘gaEventAction’: ‘related-single-article-click’,
‘gaEventLabel’: $(this).attr(‘href’),
});
});

/*
* Click Event Tracking for Related Multi Article
*/

$(document).on(‘click’, ‘.related-multi-click’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaRelatedMultiArticleEvent’,
‘gaEventCategory’: ‘related-multi-article’,
‘gaEventAction’: ‘related-multi-article-click’,
‘gaEventLabel’: $(this).attr(‘href’),
});
});

/*
* Click Event Tracking for Current Issue
*/

$(document).on(‘click’, ‘.magazine_button a’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaCurrentIssueModuleEvent’,
‘gaEventCategory’: ‘current-issue-module’,
‘gaEventAction’: ‘current-issue-module-click’,
‘gaEventLabel’: $(this).find(‘input’).val(),
});
});

/*
* Click Event Tracking for In-line CTA 1
*/

$(document).on(‘click’, ‘.inline-cta-1 .cta a’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaInlineCtaOneEvent’,
‘gaEventCategory’: ‘inline-cta-1’,
‘gaEventAction’: ‘inline-cta-1-click’,
‘gaEventLabel’: $(this).find(‘input’).val(),
});
});

/*
* Click Event Tracking for In-line CTA 2
*/

$(document).on(‘click’, ‘.inline-cta-2 .cta a’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaInlineCtaTwoEvent’,
‘gaEventCategory’: ‘inline-cta-2’,
‘gaEventAction’: ‘inline-cta-2-click’,
‘gaEventLabel’: $(this).find(‘input’).val(),
});
});
/*
* Click Event Tracking for In-line CTA Signup
*/

$(document).on(‘click’, ‘.inline-cta_form .cta a’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaInlineCtaSignupEvent’,
‘gaEventCategory’: ‘inline-cta-signup’,
‘gaEventAction’: ‘inline-cta-signup-click’,
‘gaEventLabel’: $(this).find(‘input’).val(),
});
});

/*
* Click Event Tracking for Footer Last Latest From NAtion
*/

$(document).on(‘click’, ‘#article-footer-last .latest-from h3 a’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaInfiniteScrollfooterEvent’,
‘gaEventCategory’: ‘infinite-scroll-footer-latest-articles’,
‘gaEventAction’: ‘infinite-scroll-footer-latest-articles-click’,
‘gaEventLabel’: $(this).attr(‘href’),
});
});

/*
* Click Event Tracking for Footer Last Editor Picks
*/

$(document).on(‘click’, ‘#article-footer-last .editors-picks h3 a, #article-footer-last .editors-picks .story a’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaInfiniteScrollfooterEvent’,
‘gaEventCategory’: ‘infinite-scroll-footer-editor-picks’,
‘gaEventAction’: ‘infinite-scroll-footer-editor-picks-click’,
‘gaEventLabel’: $(this).attr(‘href’),
});
});

/*
* Click Event Tracking for Author Highlight
*/

$(document).on(‘click’, ‘.author-modules .newrelated-blocks > a’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaAuthorHighlight’,
‘gaEventCategory’: ‘author-Highlight’,
‘gaEventAction’: ‘author-Highlight-click’,
‘gaEventLabel’: $(this).attr(‘href’),
});
});

/*
* Click Event Tracking for Series Module
*/

$(document).on(‘click’, ‘.series-modules .series-modules-blocks .series-blocks > a’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaSeriesModule’,
‘gaEventCategory’: ‘series-module’,
‘gaEventAction’: ‘series-module-click’,
‘gaEventLabel’: $(this).attr(‘href’),
});
});

/*
* Click Event Tracking for Comment Module
*/

$(document).on(‘click’, ‘.comment-module .comment-blocks .cta input’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaCommentsModule’,
‘gaEventCategory’: ‘comments-module’,
‘gaEventAction’: ‘comments-module-click’,
‘gaEventLabel’: $(this).val(),
});
});

/*
* Click Event Tracking for Books Salad
*/

$(document).on(‘click’, ‘.book-module .newrelated-blocks a’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaBooksSalad’,
‘gaEventCategory’: ‘books-salad’,
‘gaEventAction’: ‘books-salad-click’,
‘gaEventLabel’: $(this).parent().parent().find(‘h5’).text(),
});

});

/*
* Click Event Tracking for Action Tout Module
*/

$(document).on(‘click’, ‘aside.takeaction .cta input’,function(){
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaActionToutModule’,
‘gaEventCategory’: ‘action-tout-module’,
‘gaEventAction’: ‘action-tout-module-click’,
‘gaEventLabel’: document.URL,
});
});

/*
* Click Event Tracking for Keep Reading 2/3/4/5
*/

$(document).on(‘click’, ‘.expand-reduce a’,function(){

var article_number = $(this).parents(‘.scrolltrace’).find(‘.article-body’).attr(‘article-number’);

if (typeof article_number !== typeof undefined && article_number !== false) {
/*
* Click Event
*/
dataLayer.push({
‘event’: ‘gaKeepReading’,
‘gaEventCategory’: ‘keep-reading’,
‘gaEventAction’: ‘keep-reading-‘+article_number+’-click’,
‘gaEventLabel’: document.URL,
});
}
});

/*
* Article Email Sign Up
*/

$(document).on(‘click’,’.para_one_button_email’,function(){
/*
* Track Click On Sign Up Button GTM
*/
var current_email_signup = $(this).parents(“.email-signup-module”);
var current_step = current_email_signup.attr(“data-section”);
var article_id = $(this).parents(“#url-title”).parent().attr(“article-post-id”);
paragraphOneClickEvent(article_id, current_step);

var email = current_email_signup.find(“#para-one-email-input-“+current_step+””).val();
var sailthru_list = current_email_signup.find(“#para-one-sailthru-list-“+current_step+””).val();
var current_parent = $(this).parent();

if( email!=” && typeof email!==typeof undefined){
jQuery.ajax({
url :ajax_object.ajax_url,
type :”POST”,
data :”sailthru_email_take_action=”+email+”&take_action_sailthru_list_final=”+sailthru_list+”&action=action_tout_sailthru”,
success : function(data){
if( data.indexOf(‘errormsg’) > 0 ){
current_parent.find(‘.footer_email_error’).html(data);
}else{
/*
* Track Successful Sign Up GTM
*/

if( typeof article_id !== typeof undefined && typeof current_step !== typeof undefined && (typeof paragraph_module !== typeof undefined) && (paragraph_module[article_id][current_step].event_name!=””) ){
dataLayer.push({
‘event’: ‘gaParagraphOneEvent’,
‘gaEventCategory’: ”+ paragraph_module[article_id][current_step].event_name +”,
‘gaEventAction’: ”+ paragraph_module[article_id][current_step].event_name +’-list’,
‘gaEventLabel’: email,
});
}

var nextTNstep = parseInt(current_step)+1;
nextTNstep = ( nextTNstep > 5 )? 0 : nextTNstep;
var step = getParaOneNextStep(article_id, nextTNstep);

var cookieDateTNstep = new Date();
cookieDateTNstep.setTime(cookieDateTNstep.getTime() + (30*24*60*60*1000));
document.cookie = “TNstep=”+step+”;expires=”+cookieDateTNstep.toUTCString()+”;path=/”;

var cookieDateTNlifetime = new Date();
cookieDateTNlifetime.setTime(cookieDateTNlifetime.getTime() + (10*365*24*60*60*1000));
document.cookie = “TNlifetime=”+step+”;expires=”+cookieDateTNlifetime.toUTCString()+”;path=/”;

$(“.abody-“+article_id+” .email-signup-module”).hide();
current_email_signup.next(“#para-one-thankyou-“+article_id+””).show();
}
}
});
}else{
current_parent.find(‘.footer_email_error’).html(‘Please Enter Email’);
}
});

/*
* Paragraph one other module
*/

$(document).on(‘click’,’.para_one_button’,function(){
/*
* Track Click On Sign Up Button GTM
*/
var current_step = $(this).parents(“.email-signup-module”).attr(“data-section”);
var article_id = $(this).parents(“#url-title”).parent().attr(“article-post-id”);
var nextTNstep = parseInt(current_step)+1;

nextTNstep = ( nextTNstep > 5 )? 0 : nextTNstep;
var step = getParaOneNextStep(article_id, nextTNstep);

var cookieDateTNstep = new Date();
cookieDateTNstep.setTime(cookieDateTNstep.getTime() + (30*24*60*60*1000));
document.cookie = “TNstep=”+step+”;expires=”+cookieDateTNstep.toUTCString()+”;path=/”;

var cookieDateTNlifetime = new Date();
cookieDateTNlifetime.setTime(cookieDateTNlifetime.getTime() + (10*365*24*60*60*1000));
document.cookie = “TNlifetime=”+step+”;expires=”+cookieDateTNlifetime.toUTCString()+”;path=/”;

paragraphOneClickEvent(article_id, current_step);
});

$(document).on(‘click’,’.inline_cta_signup’,function(){

var current_email_signup = $(this).parents(“.inline-cta-form-module”);
var article_id = $(this).parents(“#url-title”).parent().attr(“article-post-id”);
$(“.inline_cta__form_error_”+article_id).html(“”);
$(“.inline_cta__form_toperror_”+article_id).html(“”);
var email = $(“#inline_cta__email_”+article_id).val();
var sailthru_list = $(“#inline_cta__sail_list_”+article_id).val();
var current_parent = $(this).parent();

if( email!=” && typeof email!==typeof undefined){
if(!isValidEmailAddress(email)){
$(“.inline_cta__form_error_”+article_id).html(”);
}
else{
jQuery.ajax({
url :ajax_object.ajax_url,
type :”POST”,
data :”article_id=”+article_id+”&email=”+email+”&list=”+sailthru_list+”&action=inlinecta-signup”,
success : function(data){
if( data.indexOf(‘errormsg’) > 0 ){
$(“.inline_cta__form_error_”+article_id).html(data);
}else{
$(“.inline_cta__signup_module_”+article_id).hide();
if (data.indexOf(‘verify_email’) > 0) {
$(“#inline_cta__form_thanks”+article_id).html(data);
}
$(“#inline_cta__form_thanks”+article_id).show();
}
}
});
}
}else{
$(“.inline_cta__form_error_”+article_id).html(”);
}
});

});