FIX Selector for HTML/plain email content toggle. Show preview button for both.

This commit is contained in:
Robbie Averill 2017-06-09 11:04:52 +12:00
parent 802c750a77
commit e96594247b
2 changed files with 5 additions and 9 deletions

View File

@ -258,12 +258,9 @@ class UserDefinedForm_EmailRecipient extends DataObject
->addExtraClass('toggle-html-only'), ->addExtraClass('toggle-html-only'),
TextareaField::create('EmailBody', _t('UserDefinedForm.EMAILBODY', 'Body')) TextareaField::create('EmailBody', _t('UserDefinedForm.EMAILBODY', 'Body'))
->addExtraClass('toggle-plain-only'), ->addExtraClass('toggle-plain-only'),
LiteralField::create( LiteralField::create('EmailPreview', $preview)
'EmailPreview',
'<div id="EmailPreview" class="field toggle-html-only">' . $preview . '</div>'
)
)); ));
$fields->fieldByName('Root.EmailContent')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILCONTENTTAB', 'Email Content')); $fields->fieldByName('Root.EmailContent')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILCONTENTTAB', 'Email Content'));
// Custom rules for sending this field // Custom rules for sending this field

View File

@ -5,12 +5,11 @@
(function ($) { (function ($) {
$(document).ready(function () { $(document).ready(function () {
var sendPlain = $('input[name="SendPlain"]');
var recipient = { var recipient = {
// Some fields are only visible when HTML email are being sent. // Some fields are only visible when HTML email are being sent.
updateFormatSpecificFields: function () { updateFormatSpecificFields: function () {
var sendPlainChecked = $('#SendPlain') var sendPlainChecked = sendPlain.is(':checked');
.find('input[type="checkbox"]')
.is(':checked');
$(".field.toggle-html-only")[sendPlainChecked ? 'hide' : 'show'](); $(".field.toggle-html-only")[sendPlainChecked ? 'hide' : 'show']();
$(".field.toggle-plain-only")[sendPlainChecked ? 'show' : 'hide'](); $(".field.toggle-plain-only")[sendPlainChecked ? 'show' : 'hide']();
@ -27,7 +26,7 @@
} }
}); });
$('#SendPlain').entwine({ sendPlain.entwine({
onchange: function () { onchange: function () {
recipient.updateFormatSpecificFields(); recipient.updateFormatSpecificFields();
} }