{% extends "_layouts/base" %} {% set title = "Preview"|t('sprout-email') %} {% block body %}
{% set emailUrl = null %} {% set separator = '&' %} {% set htmlBody = null %} {% set body = null %} {% if emailType == 'campaign' %} {% set email = craft.sproutEmail.getCampaignEmailById(emailId) %} {#{% set shareUrl = craft.sproutEmail.getCampaignEmailShareUrl() %}#} {% if email.status != 'sent' or not email.getUrl() %} {# Draft Email or Email without URLs #} {% set emailUrl = craft.sproutEmail.getCampaignEmailShareUrl(email.id, email.campaignTypeId) %} {% else %} {# Live Email with URLs #} {% set emailUrl = email.getUrl() %} {% set separator = '?' %} {% endif %} {% endif %} {% if emailType == 'notification' %} {% set email = craft.sproutEmail.getNotificationEmailById(emailId) %} {% set emailUrl = actionUrl('sprout-base/notifications/share-notification-email', { notificationId: email.id }) %} {% endif %} {% if emailType == 'sent' %} {% set email = craft.sproutEmail.getSentEmailById(emailId) %} {% set body = email.body %} {% set htmlBody = email.htmlBody %} {% endif %}
{% if htmlBody is not empty %} {% else %} {#

{{ "No HTML content"|t('sprout-email') }}

#} {% endif %}
{% if body is not empty %}
{{ body }}
{% else %} {#

{{ "No Text content"|t('sprout-email') }}

#} {% endif %}
{% js %} {% set isText = (craft.app.request.getParam('type') == 'text') ? true : false %} {% if isText == true %} jQuery(document).ready(function() { jQuery('.preview-text-btn').click(); }); {% endif %} jQuery(".sentemail-btn").click(function() { jQuery(".sentemail-btn").removeClass('active'); jQuery(this).addClass('active'); var previewTarget = jQuery(this).data('preview-target'); var previewTargetClass = ".sentemail-" + previewTarget; jQuery('.sentemail-pane').removeClass('active'); jQuery(previewTargetClass).addClass('active'); }) {% endjs %} {% endblock %}