forked from civicrm/civicrm-wordpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
civicrm.js
69 lines (67 loc) · 2.61 KB
/
civicrm.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
// http://civicrm.org/licensing
jQuery(function ($) {
$('#crm-wp-insert-shortcode').on('click', function () {
var form_id = $("#add_civicomponent_id").val();
if (form_id == "") {
alert('Please select a frontend element.');
return;
}
var component = $("#add_civicomponent_id").val();
var shortcode = '[civicrm component="' + component + '"';
switch (component) {
case 'contribution':
shortcode += ' id="' + $("#add_contributepage_id").val() + '"';
shortcode += ' mode="' + $("input[name='component_mode']:checked").val() + '"';
break;
case 'event':
shortcode += ' id="' + $("#add_eventpage_id").val() + '"';
shortcode += ' action="' + $("input[name='event_action']:checked").val() + '"';
shortcode += ' mode="' + $("input[name='component_mode']:checked").val() + '"';
break;
case 'profile':
shortcode += ' gid="' + $("#add_profilepage_id").val() + '"';
shortcode += ' mode="' + $("input[name='profile_mode']:checked").val() + '"';
break;
case 'user-dashboard':
break;
case 'petition':
shortcode += ' id="' + $("#add_petition_id").val() + '"';
break;
}
shortcode += ']';
window.send_to_editor(shortcode);
});
$('#add_civicomponent_id').on('change', function () {
switch ($(this).val()) {
case 'contribution':
$('#contribution-section, #component-section').show();
$('#profile-section, #profile-mode-section').hide();
$('#event-section, #action-section-event').hide();
$('#petition-section').hide();
break;
case 'event':
$('#contribution-section').hide();
$('#profile-section, #profile-mode-section').hide();
$('#event-section, #component-section, #action-section-event').show();
$('#petition-section').hide();
break;
case 'profile':
$('#contribution-section, #component-section').hide();
$('#profile-section, #profile-mode-section').show();
$('#event-section, #action-section-event').hide();
$('#petition-section').hide();
break;
case 'petition':
$('#contribution-section, #component-section').hide();
$('#profile-section, #profile-mode-section').hide();
$('#event-section, #action-section-event').hide();
$('#petition-section').show();
break;
default:
$('#contribution-section, #event-section, #component-section, #action-section-event').hide();
$('#profile-section, #profile-mode-section').hide();
$('#petition-section').hide();
break;
}
});
});