silverstripe-userforms/javascript/Recipient.js

38 lines
841 B
JavaScript
Raw Normal View History

/**
* Email recipient behaviour.
*/
(function ($) {
$(document).ready(function () {
var recipient = {
// Some fields are only visible when HTML email are being sent.
updateFormatSpecificFields: function () {
2015-07-24 04:37:48 +02:00
var sendPlainChecked = $('#SendPlain')
.find('input[type="checkbox"]')
.is(':checked');
2015-07-24 04:37:48 +02:00
$(".field.toggle-html-only")[sendPlainChecked ? 'hide' : 'show']();
$(".field.toggle-plain-only")[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));