CRM-16354 - use crm-wysiwyg-enabled css class more reliably
authorColeman Watts <coleman@civicrm.org>
Tue, 27 Oct 2015 19:32:17 +0000 (15:32 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 27 Oct 2015 21:40:58 +0000 (17:40 -0400)
js/Common.js
js/wysiwyg/crm.ckeditor.js

index 6fa458989c215e30edc0bb5fc9b1cffe3f0aac7d..136cd3f47a61c7b6fffc880ee5eb1cd747fd4937 100644 (file)
@@ -928,16 +928,13 @@ if (!CRM.vars) CRM.vars = {};
       $('form[data-warn-changes] :input', e.target).each(function() {
         $(this).data('crm-initial-value', $(this).is(':checkbox, :radio') ? $(this).prop('checked') : $(this).val());
       });
-      $('textarea.crm-form-wysiwyg', e.target)
-        .not('.crm-wysiwyg-enabled')
-        .addClass('crm-wysiwyg-enabled')
-        .each(function() {
-          if ($(this).hasClass("collapsed")) {
-            CRM.wysiwyg.createCollapsed(this);
-          } else {
-            CRM.wysiwyg.create(this);
-          }
-        });
+      $('textarea.crm-form-wysiwyg', e.target).each(function() {
+        if ($(this).hasClass("collapsed")) {
+          CRM.wysiwyg.createCollapsed(this);
+        } else {
+          CRM.wysiwyg.create(this);
+        }
+      });
     })
     .on('dialogopen', function(e) {
       var $el = $(e.target);
index 853252e88c4894229ecdbbb9e8e9df00538a3a84..4f8e9cb80d85adcd8e748035fd714912a5bea4d0 100644 (file)
@@ -66,6 +66,8 @@
         browseUrl = CRM.config.resourceBase + "packages/kcfinder/browse.php?cms=civicrm",
         uploadUrl = CRM.config.resourceBase + "packages/kcfinder/upload.php?cms=civicrm";
 
+      $(item).addClass('crm-wysiwyg-enabled');
+
       CKEDITOR.replace($(item)[0], {
         filebrowserBrowseUrl: browseUrl + '&type=files',
         filebrowserImageBrowseUrl: browseUrl + '&type=images',
         }
       });
     }
-    
-    if ($(item).length) {
+
+    if ($(item).hasClass('crm-wysiwyg-enabled')) {
+      deferred.resolve();
+    }
+    else if ($(item).length) {
       // Lazy-load ckeditor.js
       if (window.CKEDITOR) {
         initialize();
   };
 
   CRM.wysiwyg.destroy = function(item) {
+    $(item).removeClass('crm-wysiwyg-enabled');
     var editor = getInstance(item);
     if (editor) {
       editor.destroy();