1 // https://civicrm.org/licensing
4 var $form
= $('form.CRM_Core_Form_ShortCode');
6 function changeComponent() {
7 var component
= $(this).val(),
8 entities
= $(this).data('entities');
10 $('.shortcode-param[data-components]', $form
).each(function() {
11 $(this).toggle($.inArray(component
, $(this).data('components')) > -1);
13 if (entities
[component
]) {
14 $('input[name=entity]')
16 .data('key', entities
[component
].key
)
17 .data('select-params', null)
18 .data('api-params', null)
19 .crmEntityRef(entities
[component
]);
25 $form
.closest('.ui-dialog-content').dialog('close');
29 var code
= '[civicrm';
30 $('.shortcode-param:visible', $form
).each(function() {
31 var $el
= $('input:checked, select, input.crm-form-entityref', this);
32 code
+= ' ' + $el
.data('key') + '="' + $el
.val() + '"';
34 window
.send_to_editor(code
+ ']');
38 $('select[name=component]', $form
).each(changeComponent
).change(changeComponent
);
40 $form
.closest('.ui-dialog-content').dialog('option', 'buttons', [
43 icons
: {primary
: "ui-icon-check"},
48 icons
: {primary
: "ui-icon-close"},