From: Coleman Watts Date: Tue, 27 Oct 2015 19:32:17 +0000 (-0400) Subject: CRM-16354 - use crm-wysiwyg-enabled css class more reliably X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9db15279b111ff7a2f7bb8b6ec37cc000f5185d1;p=civicrm-core.git CRM-16354 - use crm-wysiwyg-enabled css class more reliably --- 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();