i18n - Improve multilingual popup for text and wysiwyg fields
authorColeman Watts <coleman@civicrm.org>
Tue, 18 Jun 2019 17:48:38 +0000 (13:48 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 18 Jun 2019 19:38:06 +0000 (15:38 -0400)
CRM/Core/I18n/Form.php
js/crm.multilingual.js
js/wysiwyg/crm.wysiwyg.js

index bc8b776af1fa4bbdcaff6dc63c9675836e792e34..dd7aa9bd31dccdc8147002b54a9d8cca10e28df5 100644 (file)
@@ -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);
index ced31483b764ea3c3219ec6ae201d5f9ebc7c31b..f3af7145d4046aded1ced7c9759da94eff61df24 100644 (file)
@@ -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();
index f80b6e3388d68acaef420dbb4994a9d324c554ca..41adc35d4e74bf73899113780554858ed807951d 100644 (file)
@@ -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('<div class="replace-plain" tabindex="0"></div>');
       $(item).next('.replace-plain')
         .attr('title', ts('Click to edit'))