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