var request=new XMLHttpRequest;request.open("GET",creodeSpectatorPianoUrl+"available-newsletters.json",!1),request.send(null);var availableNewsletters=JSON.parse(request.responseText); var signUpToContinue={initialised:!1,init:function(i){this.initialised||(this.args=i,this.args&&(this.getArticleBody(),this.articleBody.length&&(this.addWrapper(),this.getElements(),this.setEvents(),this.addSignUpForm())),this.initialised=!0)},getArticleBody:function(){this.articleBody=jQuery(".article-content .article-body")},addWrapper:function(){var i='
[ heading ]
[ bottom call to action link ]
';void 0!==this.args.prefixText&&(i='
'+this.args.prefixText+" [ prefix link ]"+i,void 0!==this.args.prefixLinkText?(i=i.replace("[ prefix link ]",'
"),i=void 0!==this.args.prefixLinkUrl?i.replace("[ prefix link url ]",this.args.prefixLinkUrl):i.replace("[ prefix link url ]","#")):i=i.replace("[ prefix link ]","")),void 0!==this.args.headingText?(i=i.replace("[ heading ]",'

'+this.args.headingText+"

[ heading suffix ]
"),i=void 0!==this.args.headingSuffix?i.replace("[ heading suffix ]",'
'+this.args.headingSuffix+"
"):i.replace("[ heading suffix ]","")):i=i.replace("[ heading ]",""),void 0!==this.args.bottomCallToActionLinkText?(i=i.replace("[ bottom call to action link ]",''+this.args.bottomCallToActionLinkText+""),i=void 0!==this.args.bottomCallToActionLinkUrl?i.replace("[ bottom call to action link url ]",this.args.bottomCallToActionLinkUrl):i.replace("[ bottom call to action link url ]","#")):i=i.replace("[ bottom call to action link ]","");var t=jQuery(i),n=jQuery();this.articleBody.find("p").each(function(){var i=jQuery(this);if(!i.parents(".book-meta, .mejs-player-holder, .arts-meta, blockquote").length)return n=i,!1}),n.length&&(n.parent().children().each(function(){var i=jQuery(this);i.is(n)||i.remove()}),t.insertAfter(n),t.parent().append("

"))},getElements:function(){this.prefixLink=jQuery(".sign-up-to-continue__prefix-call-to-action"),this.formWrapper=jQuery(".sign-up-to-continue__iframe-wrapper"),this.bottomCallToActionLink=jQuery(".sign-up-to-continue__bottom-call-to-action")},setEvents:function(){var i=this;i.prefixLink.length&&void 0!==i.args.prefixLinkOnClick&&i.prefixLink.on("click",function(t){t.preventDefault(),i.args.prefixLinkOnClick()}),i.bottomCallToActionLink.length&&void 0!==i.args.bottomCallToActionLinkOnClick&&i.bottomCallToActionLink.on("click",i.args.bottomCallToActionLinkOnClick)},addSignUpForm:function(){var i=this;if(i.args&&i.articleBody.length&&i.formWrapper.length&&"undefined"!=typeof tp){var t={screen:"register",displayMode:"inline",containerSelector:".sign-up-to-continue__iframe-wrapper"};"undefined"!=typeof pianoDefaultCountry&&(t.stage=pianoDefaultCountry),tp.pianoId.show(t),pianoLoginFunctions.loggedIn=function(){i.gaTrack("registration"),window.scrollTo(0,0),initialNewsletterSignUp()},pianoLoginFunctions.loggedOut=function(){location.reload()}}},gaTrack:function(i){if("undefined"!=typeof dataLayer){var t=window.location.pathname;if(tp.pianoId.isUserValid()){var n=tp.pianoId.getUser().sub;"registration"==i&&dataLayer.push({event:"User registration",status:'User registered successfully through "Sign in to continue" component',path:t,piano_user:n})}}}}; var subscribeRibbon={SignUpFormHeading:"Register for 3 articles a week",animationDuration:500,templateName:"",meterValue:-1,signUpSectionProportionalHeight:.6666,init:function(){this.addWrapper(),this.getElements(),this.wrapper.length&&this.overlay.length&&this.signUpSection.length&&this.innerSignUpSection.length&&this.signUpSectionHeading.length&&this.signUpSectionImageWrapper.length&&this.formWrapper.length&&(this.setEvents(),this.addSignUpForm(),this.addCloseCallbackToSignInPopup())},addWrapper:function(){var e=jQuery('
');void 0!==document.readyState&&"complete"!=document.readyState&&(e.css("left","10000px"),window.addEventListener("load",function(){e.css("left","0px")})),jQuery("body").append(e)},getElements:function(){this.wrapper=jQuery(".subscribe-ribbon__wrapper"),this.overlay=jQuery(".subscribe-ribbon__overlay"),this.signUpSection=jQuery(".subscribe-ribbon__sign-up-section"),this.innerSignUpSection=jQuery(".subscribe-ribbon__inner-sign-up-section"),this.signUpSectionHeading=jQuery(".subscribe-ribbon__sign-up-section-heading"),this.signUpSectionCloseButton=jQuery(".subscribe-ribbon__sign-up-section-close-button"),this.signUpSectionImageWrapper=jQuery(".subscribe-ribbon__sign-up-section-image"),this.formWrapper=jQuery(".subscribe-ribbon__sign-up-section-form")},setEvents:function(){var e=this;e.previousWindowWidth=jQuery(window).width(),jQuery(window).resize(function(){e.resizeSignUpSection()}),tp.push(["addHandler","customEvent",function(i,n,t,o){"subscribe-ribbon--close"==i.eventName&&(e.gaTrack("close_button_click"),e.close()),"subscribe-ribbon--open-close-sign-up-form"==i.eventName&&(e.gaTrack("register_button_click"),e.openCloseSignUpForm()),"subscribe-ribbon--subscribe-button-click"==i.eventName&&e.gaTrack("subscribe_button_click"),"open-sign-in-popup"==i.eventName&&e.gaTrack("login_button_click")}]),window.addEventListener("message",function(i){i.data.templateName&&(e.templateName=i.data.templateName,e.gaTrack("ribbon_displayed"),e.hjTrack("ribbon_displayed"));try{var n=JSON.parse(i.data);void 0!==n.sender&&void 0!==n.event&&jQuery(".subscribe-ribbon__sign-up-section-form iframe").length&&n.sender==jQuery(".subscribe-ribbon__sign-up-section-form iframe").attr("id")&&"resize"==n.event&&e.scrollToTopOfSignUpForm()}catch(e){}}),e.signUpSectionCloseButton.length&&e.signUpSectionCloseButton.on("click",function(){e.openCloseSignUpForm()})},close:function(){jQuery(".subscribe-ribbon__wrapper");this.wrapper.length&&this.overlay.length&&(this.signUpSection.removeClass("subscribe-ribbon__sign-up-section--open"),this.wrapper.remove(),this.overlay.remove(),jQuery("body").removeClass("body--fixed"),jQuery("#app").show())},openCloseSignUpForm:function(){this.signUpSection.toggleClass("subscribe-ribbon__sign-up-section--open"),this.signUpSection.hasClass("subscribe-ribbon__sign-up-section--open")?this.openSignUpSection():this.closeSignUpSection()},openSignUpSection:function(){var e=this;if(e.onSmallScreen()){jQuery("body").removeClass("body--fixed");var i=100-e.wrapper.height()/jQuery(window).height()*100;jQuery("html, body").animate({scrollTop:0},e.animationDuration),e.wrapper.animate({bottom:i+"%"},e.animationDuration),setTimeout(function(){e.wrapper.addClass("subscribe-ribbon__wrapper--absolute"),jQuery("#app").hide()},e.animationDuration+100)}else e.wrapper.animate({bottom:100*e.signUpSectionProportionalHeight+"%"},e.animationDuration),e.signUpSection.css("height",e.signUpSectionProportionalHeight*jQuery(window).height()+"px"),e.overlay.fadeIn(e.animationDuration),jQuery("body").addClass("body--fixed");this.iFrame.length||(this.iFrame=jQuery(".subscribe-ribbon__inner-wrapper iframe")),e.iFrame.length&&e.iFrame[0].contentWindow.postMessage({signUpFormOpen:!0},"*"),pianoLoginFunctions.loggedIn=function(){e.signUpSectionHeading.remove(),initialNewsletterSignUp()},pianoLoginFunctions.loggedOut=function(){location.reload()}},closeSignUpSection:function(){var e=this;e.onSmallScreen()?(jQuery("#app").show(),jQuery("html, body").animate({scrollTop:0},.1*e.animationDuration),setTimeout(function(){e.wrapper.removeClass("subscribe-ribbon__wrapper--absolute"),e.wrapper.animate({bottom:0},.9*e.animationDuration)},.1*e.animationDuration)):(e.wrapper.animate({bottom:"0%"},e.animationDuration),setTimeout(function(){e.signUpSection.css("height",""),jQuery("body").removeClass("body--fixed")},e.animationDuration),e.overlay.fadeOut(e.animationDuration)),this.iFrame.length||(this.iFrame=jQuery(".subscribe-ribbon__inner-wrapper iframe")),e.iFrame.length&&e.iFrame[0].contentWindow.postMessage({signUpFormOpen:!1},"*")},resizeSignUpSection:function(){this.signUpSection.hasClass("subscribe-ribbon__sign-up-section--open")&&(this.onSmallScreen()?(jQuery("body").removeClass("body--fixed"),jQuery("#app").hide(),this.wrapper.addClass("subscribe-ribbon__wrapper--absolute"),this.wrapper.css("bottom",""),this.signUpSection.css("height",""),this.overlay.css("display","none")):(jQuery("body").addClass("body--fixed"),jQuery("#app").show(),this.wrapper.removeClass("subscribe-ribbon__wrapper--absolute"),this.wrapper.css("bottom",100*this.signUpSectionProportionalHeight+"%"),this.signUpSection.css("height",this.signUpSectionProportionalHeight*jQuery(window).height()+"px"),this.overlay.css("display","block")))},addRibbon:function(e,i,n){tp.template.show({offerId:e,templateId:i,displayMode:"inline",containerSelector:".subscribe-ribbon__inner-wrapper"}),this.iFrame=jQuery(".subscribe-ribbon__inner-wrapper iframe"),void 0!==n&&(this.meterValue=n)},removeRibbon:function(){var e=jQuery(".subscribe-ribbon__inner-wrapper");e.length&&e.empty()},addSignUpImage:function(e,i){if(this.signUpSectionImageWrapper.length){var n=jQuery(''+i+'');this.signUpSectionImageWrapper.prepend(n)}},addSignUpForm:function(){var e=this;if("undefined"!=typeof tp&&!tp.pianoId.isUserValid()){var i={screen:"register",displayMode:"inline",containerSelector:".subscribe-ribbon__sign-up-section-form"};"undefined"!=typeof pianoDefaultCountry&&(i.stage=pianoDefaultCountry),tp.pianoId.show(i),pianoLoginFunctions.loggedIn=function(){e.signUpSectionHeading.remove(),initialNewsletterSignUp(".subscribe-ribbon__sign-up-section-form")},pianoLoginFunctions.loggedOut=function(){location.reload()}}},scrollToTopOfSignUpForm:function(){this.signUpSection.hasClass("subscribe-ribbon__sign-up-section--open")&&(this.onSmallScreen()?jQuery("html, body").animate({scrollTop:this.signUpSection.offset().top}):this.signUpSection.animate({scrollTop:0}))},addCloseCallbackToSignInPopup:function(){var e=this;signInPopup.closeCallback=function(){pianoLoginFunctions.loggedIn=function(){e.signUpSectionHeading.remove(),initialNewsletterSignUp(".subscribe-ribbon__sign-up-section-form")},pianoLoginFunctions.loggedOut=function(){location.reload()}}},onSmallScreen:function(){return jQuery(window).width()<600},gaTrack:function(e){"undefined"!=typeof dataLayer&&("ribbon_displayed"==e&&dataLayer.push({event:"Ribbon",status:"Ribbon Displayed",template_name:this.templateName,meter_value:this.meterValue}),"register_button_click"==e&&dataLayer.push({event:"Ribbon",status:"Ribbon register button click",template_name:this.templateName,meter_value:this.meterValue}),"close_button_click"==e&&dataLayer.push({event:"Ribbon",status:"Ribbon close button click",template_name:this.templateName,meter_value:this.meterValue}),"subscribe_button_click"==e&&dataLayer.push({event:"Ribbon",status:"Ribbon subscribe button click",template_name:this.templateName,meter_value:this.meterValue}),"login_button_click"==e&&dataLayer.push({event:"Ribbon",status:"Ribbon login button click",template_name:this.templateName,meter_value:this.meterValue}))},hjTrack:function(e){"undefined"!=typeof hj&&"ribbon_displayed"==e&&hj("trigger","ribbon_presentations")}}; var timeToSubscribe={initialised:!1,init:function(e){this.initialised||(this.args=e,this.getArticleBody(),this.articleBody.length&&(this.addWrapper(),this.wrapper.length&&(this.addTemplate(),this.setEvents(),this.gaTrack("displayed"))),this.initialised=!0)},getArticleBody:function(){this.articleBody=jQuery(".article-content .article-body")},addWrapper:function(){var e=jQuery('
'),a=jQuery();this.articleBody.find("p").each(function(){var e=jQuery(this);if(!e.parents(".book-meta, .mejs-player-holder, .arts-meta, blockquote").length)return a=e,!1}),a.length&&(a.parent().children().each(function(){var e=jQuery(this);e.is(a)||e.remove()}),e.insertAfter(a)),this.wrapper=jQuery(".time-to-subscribe")},addTemplate:function(){"undefined"!=typeof tp&&void 0!==this.args&&void 0!==this.args.offerId&&void 0!==this.args.templateId&&tp.template.show({offerId:this.args.offerId,templateId:this.args.templateId,displayMode:"inline",containerSelector:".time-to-subscribe"})},setEvents:function(){var e=this;tp.push(["addHandler","customEvent",function(a,t,i,s){"paywall-subscribe-click"==a.eventName&&e.gaTrack("paywall-subscribe-click"),"hard-paywall-subscribe-click"==a.eventName&&e.gaTrack("hard-paywall-subscribe-click")}])},gaTrack:function(e){var a=window.location.pathname;if(tp.pianoId.isUserValid())var t=tp.pianoId.getUser().sub;else var t="";"displayed"==e&&dataLayer.push({event:"Paywall",status:"Displayed",path:a,piano_user:t}),"paywall-subscribe-click"==e&&dataLayer.push({event:"Paywall Subscribe Click",status:"Paywall Click",path:a,piano_user:t}),"hard-paywall-subscribe-click"==e&&dataLayer.push({event:"Paywall Subscribe Click",status:"Hard Paywall Click",path:a,piano_user:t})}}; var commentRestrictor={args:{info1:"Don’t miss out.",info2:"Join the conversation with other Spectator readers. [link] to leave your comments.",linkText:"Subscribe",linkUrl:"/subscription"},init:function(i){if(void 0!==i)for(var t in i)this.args[t]=i[t];this.generateInfoString(),this.getElements(),this.disqusThread.length&&(this.restrict(),this.setLineHeight())},getElements:function(){this.disqusThread=jQuery("#disqus_thread")},generateInfoString:function(){this.info="",void 0!==this.args.info1&&(this.info=this.info+this.args.info1),void 0!==this.args.info1&&void 0!==this.args.info2&&(this.info=this.info+"
"),void 0!==this.args.info2&&(this.info=this.info+this.args.info2),void 0!==this.args.linkText&&void 0!==this.args.linkUrl&&(this.info=this.info.replace("[link]",''+this.args.linkText+""))},restrict:function(){var i=jQuery('
');this.element=jQuery('

'+this.info+"

"),this.disqusThread.wrap(i),this.element.insertBefore(this.disqusThread)},setLineHeight:function(){if(this.element.length){var i=this.element.height();this.element.css("line-height",i+"px")}}}; var dataWall={init:function(a){a&&(this.args=a,this.getFirstParagraph(),this.firstParagraph.length&&(this.cleanArticle(),this.addPrefix(),this.addWrapper(),this.addTemplate(),this.setEvents()))},getFirstParagraph:function(){var a=this,t=jQuery(".article-content .article-body");a.firstParagraph=jQuery(),t.length&&t.find("p").each(function(){var t=jQuery(this);if(!t.parents(".book-meta, .mejs-player-holder, .arts-meta, blockquote").length)return a.firstParagraph=t,!1})},cleanArticle:function(){var a=this;a.firstParagraph.parent().children().each(function(){var t=jQuery(this);t.is(a.firstParagraph)||t.remove()})},addPrefix:function(){var a=this;if(void 0!==a.args.prefixText){var t='
'+a.args.prefixText+"[ prefix link ]
";t=void 0!==a.args.prefixLinkText?t.replace("[ prefix link ]",' '+a.args.prefixLinkText+""):t.replace("[ prefix link ]",""),a.prefix=jQuery(t),void 0!==a.args.prefixLinkText&&"function"==typeof a.args.prefixLinkOnClick&&a.prefix.find(".data-wall__prefix-link").on("click",function(t){t.preventDefault(),a.args.prefixLinkOnClick()}),a.firstParagraph.parent().append(a.prefix)}},addWrapper:function(){this.wrapper=jQuery('
'),this.inner=jQuery('
'),this.templateWrapper=jQuery('
'),this.inner.append(this.templateWrapper),this.wrapper.append(this.inner),this.firstParagraph.parent().append(this.wrapper)},addTemplate:function(){"string"==typeof this.args.templateId&&tp.template.show({templateId:this.args.templateId,displayMode:"inline",containerSelector:".data-wall__template-wrapper"})},setEvents:function(){var a=this;tp.push(["addHandler","customEvent",function(t,e,r,i){-1!==t.eventName.indexOf("data-wall--")&&a.gaTrack(t.eventName)}])},gaTrack:function(a){if("undefined"!=typeof dataLayer){var t={event:"Datawall",component:"Datawall",action:"",path:window.location.pathname};void 0!==this.args.hardDataWall&&this.args.hardDataWall&&(t.component="Hard Datawall"),"data-wall--subscribe-button-1-click"==a&&(t.action="Subscribe button 1 click"),"data-wall--register-button-click"==a&&(t.action="Register button click"),"data-wall--subscribe-button-2-click"==a&&(t.action="Subscribe button 2 click"),dataLayer.push(t)}}};