Get daily news on TV, video, publishing and other media.
Thank you, {{form.subscriptionEmail}}! Your newsletter preferences have been saved.
// This is a simple listener for clicking on the close button in the error message.
$('#close-error-btn').click(function () {
$('#error-message-wrapper').hide();
});
// This is the listener that will receive the post message from your front-end JS in case of an error.
window.addEventListener("message", function (e) {
// We verify that the error message is coming from Piano, so it must be what we're looking for.
if (typeof e.data.piano != 'undefined') {
// Get the object with the result.
var result = e.data.piano;
// We know how this object should be structured, so we're checking for the "success" field.
// We're expecting it to be false, so we can show an error message.
var newsletterSubmitBtn = $('button[external-event="adage-newsletter-sign-up"]');
if (!result.success) {
if (result.message === "loading") {
// Hide error message
$('#error-message-wrapper').hide();
// Hide button text and disable button
$('#submit-btn-text').hide();
newsletterSubmitBtn.attr('disabled', 'disabled').css('cursor', 'none');
// Show loading icon
$('#loading-icon').show();
} else {
// Hide loading icon
$('#loading-icon').hide();
// Show button text and enable button
$('#submit-btn-text').show();
newsletterSubmitBtn.removeAttr('disabled').css('cursor', 'pointer');
// Show the error block.
$('#error-message-wrapper').show();
// Append the text message into the block.
$('#error-message').text(result.message);
}
} else {
// Show button text and enable button
$('#submit-btn-text').show();
newsletterSubmitBtn.removeAttr('disabled').css('cursor', 'pointer');
// Hide loading icon
$('#loading-icon').hide();
// Hide form and show thank you message
$('#pn-adage-form').hide();
$('#pn-adage-thank-you').show();
}
}
return;
}, false);