silverstripe-userforms/javascript/Recipient.js
2015-08-10 13:15:59 +12:00

38 lines
841 B
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');
$(".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));