mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
350fdee850
- Developers can add email templates via a configurable path. - Content editors can select the email templates via a dropdown. - Content editors can embed HTML content in emails. - Content editors can preview HTML emails. - Content editors can use field values (merge fields) in emails.
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
/**
|
|
* Email recipient behaviour.
|
|
*/
|
|
|
|
(function ($) {
|
|
$(document).ready(function () {
|
|
|
|
var recipient = {
|
|
// Some fields are only visible when HTML email are being sent.
|
|
updateFormatSpecificFields: function () {
|
|
var sendPlainChecked = $('#SendPlain').find('input[type="checkbox"]').is(':checked');
|
|
|
|
// Hide the preview link when 'SendPlain' is selected.
|
|
$('#EmailPreview')[sendPlainChecked ? 'hide' : 'show']();
|
|
|
|
// Hide the template selector when 'SendPlain' is selected.
|
|
$('#EmailTemplate')[sendPlainChecked ? 'hide' : 'show']();
|
|
|
|
// Hide the HTML editor when 'SendPlain' is selected.
|
|
$('#EmailBodyHtml')[sendPlainChecked ? 'hide' : 'show']();
|
|
|
|
// Show the body teaxtarea when 'SendPlain' is selected.
|
|
$('#EmailBody')[sendPlainChecked ? 'show' : 'hide']();
|
|
}
|
|
};
|
|
|
|
$.entwine('udf.recipient', function ($) {
|
|
$('#Form_ItemEditForm').entwine({
|
|
onmatch: function () {
|
|
recipient.updateFormatSpecificFields();
|
|
},
|
|
onunmatch: function () {
|
|
this._super();
|
|
}
|
|
});
|
|
|
|
$('#SendPlain').entwine({
|
|
onchange: function () {
|
|
recipient.updateFormatSpecificFields();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}(jQuery));
|