1 // https://civicrm.org/licensing
4 $('.crm-shortcode-button').click(function(e
) {
6 CRM
.loadPage($(this).attr('href'), {dialog
: {width
: '50%', height
: '50%'}}).on('crmLoad', loadForm
);
10 var $form
= $('form.CRM_Core_Form_ShortCode');
12 function changeComponent() {
13 var component
= $(this).val(),
14 entities
= $(this).data('entities');
16 $('.shortcode-param[data-components]', $form
).each(function() {
17 $(this).toggle($.inArray(component
, $(this).data('components')) > -1);
19 if (entities
[component
]) {
20 $('input[name=entity]')
22 .data('key', entities
[component
].key
)
23 .data('select-params', null)
24 .data('api-params', null)
25 .crmEntityRef(entities
[component
]);
31 $form
.closest('.ui-dialog-content').dialog('close');
35 var code
= '[civicrm';
36 $('.shortcode-param:visible', $form
).each(function() {
37 var $el
= $('input:checked, select, input.crm-form-entityref', this);
38 code
+= ' ' + $el
.data('key') + '="' + $el
.val() + '"';
40 window
.send_to_editor(code
+ ']');
44 $('select[name=component]', $form
).each(changeComponent
).change(changeComponent
);
46 $(this).dialog('option', 'buttons', [
49 icons
: {primary
: "fa-check"},
54 icons
: {primary
: "fa-times"},