From 9db15279b111ff7a2f7bb8b6ec37cc000f5185d1 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 27 Oct 2015 15:32:17 -0400 Subject: [PATCH] CRM-16354 - use crm-wysiwyg-enabled css class more reliably --- js/Common.js | 17 +++++++---------- js/wysiwyg/crm.ckeditor.js | 10 ++++++++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/js/Common.js b/js/Common.js index 6fa458989c..136cd3f47a 100644 --- a/js/Common.js +++ b/js/Common.js @@ -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); diff --git a/js/wysiwyg/crm.ckeditor.js b/js/wysiwyg/crm.ckeditor.js index 853252e88c..4f8e9cb80d 100644 --- a/js/wysiwyg/crm.ckeditor.js +++ b/js/wysiwyg/crm.ckeditor.js @@ -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', @@ -79,8 +81,11 @@ } }); } - - if ($(item).length) { + + if ($(item).hasClass('crm-wysiwyg-enabled')) { + deferred.resolve(); + } + else if ($(item).length) { // Lazy-load ckeditor.js if (window.CKEDITOR) { initialize(); @@ -97,6 +102,7 @@ }; CRM.wysiwyg.destroy = function(item) { + $(item).removeClass('crm-wysiwyg-enabled'); var editor = getInstance(item); if (editor) { editor.destroy(); -- 2.25.1