Implements "Add template" button for email settings

close #16
Subjects now mandatory if send mail enabled
This commit is contained in:
Chrisbr 2014-07-23 13:42:03 +02:00
parent 7192e2fe49
commit 6f3426b6a2
10 changed files with 275 additions and 111 deletions

View file

@ -1,5 +1,51 @@
$(function() {
$(function () {
/**
* Toggles email template help below email body textarea field.
*/
$(document).ready( function() {
$(".template-help").hide();
$(".template_help_link").click(function() {
var id = $(this).data('name');
$("#" + id).toggle();
});
});
/**
* Adds the default template as value to the regarding email textarea field.
*/
$(".load_template").on('click', function () {
var template = $(this).data('template');
var textarea_name = $(this).data('name');
$('#' + textarea_name).val(template);
});
/**
* Toggle the required attribute on click on_send_email radio button.
*/
$('.send_on_radio').click(function () {
toggle_required_for_mail_subjects($(this))
});
/**
* Adds required attribute to on_send_email radio button if necessary.
*/
$('.send_on_radio').each(function () {
toggle_required_for_mail_subjects($(this))
});
/**
* Toggle the required attribute helper function.
*/
function toggle_required_for_mail_subjects($this) {
var name = $this.data('name');
if ($this.is(':checked')) {
$('#' + name).prop('required', true);
} else {
$('#' + name).removeAttr('required');
}
}
/**
/**
* Opens a prompt with the URL to copy to clipboard.
* Used in the campaign index view.
*/