silverstripe-userforms/client/src/bundles/Recipient.js
Dylan Wagstaff 7f208ee927 FIX javascript errors enacting default functionality
Mostly to do with translations, however the errors meant the front end
forms largely didn't work at all. Some of this was to do with the scoping
of `this` in es6 arrow functions, compared to the legacy code with entwine
that uses the fuller `function` definition. Reinstate missing dependency
for translations to function too.
2017-11-20 15:16:03 +13:00

34 lines
822 B
JavaScript

/**
* Email recipient behaviour.
*/
import jQuery from 'jquery';
jQuery.entwine('ss', ($) => {
const recipient = {
// Some fields are only visible when HTML email are being sent.
updateFormatSpecificFields: () => {
const sendPlainChecked = $('input[name="SendPlain"]').is(':checked');
$('.field.toggle-html-only')[sendPlainChecked ? 'hide' : 'show']();
$('.field.toggle-plain-only')[sendPlainChecked ? 'show' : 'hide']();
},
};
$('#Form_ItemEditForm .EmailRecipientForm').entwine({
onmatch: () => {
recipient.updateFormatSpecificFields();
},
onunmatch: () => {
this._super();
},
});
$('#Form_ItemEditForm .EmailRecipientForm input[name="SendPlain"]').entwine({
onchange: () => {
recipient.updateFormatSpecificFields();
},
});
});