Commit | Line | Data |
---|---|---|
d606fff7 CW |
1 | // http://civicrm.org/licensing |
2 | // JS needed for multilingual installations | |
3 | CRM.$(function($) { | |
f6516cfe CW |
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 | |
d606fff7 CW |
7 | $('body').on('click', 'a.crm-multilingual-edit-button', function(e) { |
8 | var $el = $(this), | |
9 | $form = $el.closest('form'), | |
071e5a4f CW |
10 | $field = $('#' + $el.data('field'), $form), |
11 | wysiwyg = $field.hasClass('crm-form-wysiwyg'); | |
d606fff7 CW |
12 | |
13 | CRM.loadForm($el.attr('href'), { | |
14 | dialog: {width: '50%', height: '50%'} | |
15 | }) | |
f6516cfe | 16 | // Sync the primary language field with what the user has entered on the main form |
d606fff7 | 17 | .on('crmFormLoad', function() { |
071e5a4f CW |
18 | CRM.wysiwyg.setVal($('.default-lang', this), CRM.wysiwyg.getVal($field)); |
19 | $('.default-lang', this).triggerHandler('change'); | |
d606fff7 CW |
20 | }) |
21 | .on('crmFormSubmit', function() { | |
f6516cfe | 22 | // Sync the primary language field with what the user has entered in the popup |
071e5a4f CW |
23 | CRM.wysiwyg.setVal($field, CRM.wysiwyg.getVal($('.default-lang', this))); |
24 | $field.triggerHandler('change'); | |
d606fff7 CW |
25 | $el.trigger('crmPopupFormSuccess'); |
26 | }); | |
27 | e.preventDefault(); | |
28 | }); | |
29 | }); |