- var $form = $('form.CRM_Core_Form_ShortCode');
-
- function changeComponent() {
- var component = $(this).val(),
- entities = $(this).data('entities');
-
- $('.shortcode-param[data-components]', $form).each(function() {
- $(this).toggle($.inArray(component, $(this).data('components')) > -1);
-
- if (entities[component]) {
- $('input[name=entity]')
- .val('')
- .data('key', entities[component].key)
- .data('select-params', null)
- .data('api-params', null)
- .crmEntityRef(entities[component]);
- }
- });
- }
+ $('.crm-shortcode-button').click(function(e) {
+ e.preventDefault();
+ CRM.loadPage($(this).attr('href'), {dialog: {width: '50%', height: '50%'}}).on('crmLoad', loadForm);
+ });
+
+ function loadForm() {
+ var $form = $('form.CRM_Core_Form_ShortCode');
+
+ function changeComponent() {
+ var component = $(this).val(),
+ entities = $(this).data('entities');
+
+ $('.shortcode-param[data-components]', $form).each(function() {
+ $(this).toggle($.inArray(component, $(this).data('components')) > -1);
+
+ if (entities[component]) {
+ $('input[name=entity]')
+ .val('')
+ .data('key', entities[component].key)
+ .data('select-params', null)
+ .data('api-params', null)
+ .crmEntityRef(entities[component]);
+ }
+ });
+ }