-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpetitionemail.js
80 lines (74 loc) · 3.15 KB
/
petitionemail.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
cj(document).ready( function() {
showHideEmailPetition();
populateUserFieldOptions();
cj("input#email_petition").click( function() { showHideEmailPetition(); });
cj("#profile_id").change( function() { populateUserFieldOptions(); });
cj('.petitionemail-matching-group_id :input').each( function () {
if (cj(this).val() > 0) {
cj("input.target-group").prop("checked", true);
}
});
if (cj('#recipients').val() != '') {
cj("input.target-individuals").prop("checked", true);
}
showHideTargetGroup();
showHideTargetIndividuals();
cj("input.target-group").click( function() { showHideTargetGroup(); });
cj("input.target-individuals").click( function() { showHideTargetIndividuals(); });
});
function populateUserFieldOptions() {
var actProfile = cj("#profile_id").val();
var selected_message = cj('#message_field').val();
var selected_subject = cj('#subject_field').val();
var options = {};
cj('#message_field').empty();
cj('#subject_field').empty();
if(actProfile) {
CRM.api("UFField","get",{ "uf_group_id" : actProfile },{ success:function (data) {
if(data['is_error'] == 0) {
cj('#message_field').append('<option value="">--Choose one--</option>');
cj('#subject_field').append('<option value="">--Choose one--</option>');
cj.each(data["values"], function(key, value) {
cj('#message_field').append('<option value="' + value['field_name'] + '">' + value['label'] + '</option>');
cj('#subject_field').append('<option value="' + value['field_name'] + '">' + value['label'] + '</option>');
});
cj('#message_field').val(selected_message);
cj('#subject_field').val(selected_subject);
}
}});
}
else {
options[''] = "No activity profile selected.";
cj('#message_field').append('<option value="">No activity profile selected.</option>');
cj('#subject_field').append('<option value="">No activity profile selected.</option>');
}
}
function showHideEmailPetition() {
if( cj("input#email_petition:checked").length == 1 ) {
cj("tr.crm-campaign-survey-form-block-subject").show("fast");
cj("tr.crm-campaign-survey-form-block-subject_field").show("fast");
cj("tr.crm-campaign-survey-form-block-default_message").show("fast");
cj("tr.crm-campaign-survey-form-block-message_field").show("fast");
cj("tr.crm-campaign-survey-form-block-recipient_options").show("fast");
} else {
cj("tr.crm-campaign-survey-form-block-subject").hide("fast");
cj("tr.crm-campaign-survey-form-block-subject_field").hide("fast");
cj("tr.crm-campaign-survey-form-block-default_message").hide("fast");
cj("tr.crm-campaign-survey-form-block-message_field").hide("fast");
cj("tr.crm-campaign-survey-form-block-recipient_options").hide("fast");
}
}
function showHideTargetGroup() {
if (cj("input.target-group").prop("checked")) {
cj(".petition-email-target-group").show();
} else {
cj(".petition-email-target-group").hide();
}
}
function showHideTargetIndividuals() {
if (cj("input.target-individuals").prop("checked")) {
cj(".petition-email-target-individuals").show();
} else {
cj(".petition-email-target-individuals").hide();
}
}