CRM-15821 PCP Improvements
[civicrm-core.git] / js / crm.multilingual.js
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
12 CRM.loadForm($el.attr('href'), {
13 dialog: {width: '50%', height: '50%'}
14 })
15 // Sync the primary language field with what the user has entered on the main form
16 .on('crmFormLoad', function() {
17 $('.default-lang', this).val($field.val());
18 })
19 .on('crmFormSubmit', function() {
20 // Sync the primary language field with what the user has entered in the popup
21 $field.val($('.default-lang', this).val());
22 $el.trigger('crmPopupFormSuccess');
23 });
24 e.preventDefault();
25 });
26 });