| 1 | // http://civicrm.org/licensing |
| 2 | // JS needed for multilingual installations |
| 3 | CRM.$(function($) { |
| 4 | // This is partially redundant with what the CRM.popup function would do, |
| 5 | // with a small amount of added functionality, |
| 6 | // and the difference that this loads unconditionally regardless of ajaxPopupsEnabled setting |
| 7 | $('body').on('click', 'a.crm-multilingual-edit-button', function(e) { |
| 8 | var $el = $(this), |
| 9 | $form = $el.closest('form'), |
| 10 | $field = $('#' + $el.data('field'), $form), |
| 11 | wysiwyg = $field.hasClass('crm-form-wysiwyg'); |
| 12 | |
| 13 | CRM.loadForm($el.attr('href'), { |
| 14 | dialog: {width: '50%', height: '50%'} |
| 15 | }) |
| 16 | // Sync the primary language field with what the user has entered on the main form |
| 17 | .on('crmFormLoad', function() { |
| 18 | CRM.wysiwyg.setVal($('.default-lang', this), CRM.wysiwyg.getVal($field)); |
| 19 | $('.default-lang', this).triggerHandler('change'); |
| 20 | }) |
| 21 | .on('crmFormSubmit', function() { |
| 22 | // Sync the primary language field with what the user has entered in the popup |
| 23 | CRM.wysiwyg.setVal($field, CRM.wysiwyg.getVal($('.default-lang', this))); |
| 24 | $field.triggerHandler('change'); |
| 25 | $el.trigger('crmPopupFormSuccess'); |
| 26 | }); |
| 27 | e.preventDefault(); |
| 28 | }); |
| 29 | }); |