From: Coleman Watts Date: Tue, 18 Jun 2019 17:48:38 +0000 (-0400) Subject: i18n - Improve multilingual popup for text and wysiwyg fields X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=071e5a4f43909e57c7c42b2e3eecddeb78c017ed;p=civicrm-core.git i18n - Improve multilingual popup for text and wysiwyg fields --- diff --git a/CRM/Core/I18n/Form.php b/CRM/Core/I18n/Form.php index bc8b776af1..dd7aa9bd31 100644 --- a/CRM/Core/I18n/Form.php +++ b/CRM/Core/I18n/Form.php @@ -78,7 +78,10 @@ class CRM_Core_I18n_Form extends CRM_Core_Form { if ($widget['type'] == 'RichTextEditor') { $widget['type'] = 'wysiwyg'; - $attributes['class'] .= ' collapsed'; + $attributes['class'] = 'collapsed'; + } + elseif ($widget['type'] == 'Text') { + $attributes['class'] = 'huge'; } $languages = CRM_Core_I18n::languages(TRUE); diff --git a/js/crm.multilingual.js b/js/crm.multilingual.js index ced31483b7..f3af7145d4 100644 --- a/js/crm.multilingual.js +++ b/js/crm.multilingual.js @@ -7,18 +7,21 @@ CRM.$(function($) { $('body').on('click', 'a.crm-multilingual-edit-button', function(e) { var $el = $(this), $form = $el.closest('form'), - $field = $('#' + $el.data('field'), $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() { - $('.default-lang', this).val($field.val()); + 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 - $field.val($('.default-lang', this).val()); + CRM.wysiwyg.setVal($field, CRM.wysiwyg.getVal($('.default-lang', this))); + $field.triggerHandler('change'); $el.trigger('crmPopupFormSuccess'); }); e.preventDefault(); diff --git a/js/wysiwyg/crm.wysiwyg.js b/js/wysiwyg/crm.wysiwyg.js index f80b6e3388..41adc35d4e 100644 --- a/js/wysiwyg/crm.wysiwyg.js +++ b/js/wysiwyg/crm.wysiwyg.js @@ -54,6 +54,9 @@ CRM.wysiwyg.destroy(item); $(item).hide().next('.replace-plain').show().html($(item).val()); }) + .on('change', function() { + $(this).next('.replace-plain').html($(this).val()); + }) .after('
'); $(item).next('.replace-plain') .attr('title', ts('Click to edit'))