CRM-15855 - crmMailing - For new mailings, automatically save and redirect.
[civicrm-core.git] / js / crm.multilingual.js
CommitLineData
d606fff7
CW
1// http://civicrm.org/licensing
2// JS needed for multilingual installations
3CRM.$(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'),
10 $field = $('#' + $el.data('field'), $form);
11
12 CRM.loadForm($el.attr('href'), {
13 dialog: {width: '50%', height: '50%'}
14 })
f6516cfe 15 // Sync the primary language field with what the user has entered on the main form
d606fff7
CW
16 .on('crmFormLoad', function() {
17 $('.default-lang', this).val($field.val());
18 })
19 .on('crmFormSubmit', function() {
f6516cfe 20 // Sync the primary language field with what the user has entered in the popup
d606fff7
CW
21 $field.val($('.default-lang', this).val());
22 $el.trigger('crmPopupFormSuccess');
23 });
24 e.preventDefault();
25 });
26});