From f91b1c0cd749bacd3c723d5f90a8b2b023a6cc43 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 27 Apr 2015 22:50:30 -0600 Subject: [PATCH] CRM-16354 - wysiwyg code cleanup --- ang/crmUi.js | 20 ++--- js/Common.js | 6 +- js/crm.ajax.js | 18 ++--- js/wysiwyg/crm.ckeditor.js | 32 +++++--- js/wysiwyg/crm.wysiwyg.js | 92 +++++++++++----------- templates/CRM/Contact/Page/View/Summary.js | 13 --- 6 files changed, 78 insertions(+), 103 deletions(-) diff --git a/ang/crmUi.js b/ang/crmUi.js index 952e75c168..0821c5ff9d 100644 --- a/ang/crmUi.js +++ b/ang/crmUi.js @@ -355,14 +355,13 @@ // Example: // ') + .on('blur', function () { + CRM.wysiwyg.destroy(item); + $(item).hide().next('.replace-plain').show().html($(item).val()); + }); + $(item).next('.replace-plain').attr('title', ts('Click to edit')).on('click keypress', function () { + $(item).show().next('.replace-plain').hide(); + CRM.wysiwyg.create(item); + }); + } }; - CRM.wysiwyg.setVal = function(item, val) { - return $(item).val(val); - }; - CRM.wysiwyg.insert = function(item, text) { - CRM.wysiwyg.insertIntoTextarea(item, text); - }; - CRM.wysiwyg.insertIntoTextarea = function(item, text) { - var origVal = $(item).val(); - var origPos = item[0].selectionStart; - var newVal = origVal + text; - $(item).val(newVal); - var newPos = (origPos + text.length); - item[0].selectionStart = newPos; - item[0].selectionEnd = newPos; - $(item).triggerHandler('change'); - CRM.wysiwyg.focus(item); - }; - CRM.wysiwyg.focus = function(item) { - $(item).focus(); - }; - CRM.wysiwyg.createPlain = function(item) { - $(item) - .hide() - .after('
'); - $(item).next('.replace-plain').click(function(){ - openWysiwyg(item); - }); - $(item).next('.replace-plain').keypress(function(){ - openWysiwyg(item); - }); - }; - })(CRM.$, CRM._); diff --git a/templates/CRM/Contact/Page/View/Summary.js b/templates/CRM/Contact/Page/View/Summary.js index 960ec099c1..b38941d962 100644 --- a/templates/CRM/Contact/Page/View/Summary.js +++ b/templates/CRM/Contact/Page/View/Summary.js @@ -7,19 +7,6 @@ beforeSubmit: function(arr, $form, options) { $form.block(); }, - beforeSerialize: function(form, options) { - // Copied from crm.ajax.js - if (window.CKEDITOR && window.CKEDITOR.instances) { - $.each(CKEDITOR.instances, function() { - if (this.updateElement) this.updateElement(); - }); - } - if (window.tinyMCE && tinyMCE.editors) { - $.each(tinyMCE.editors, function() { - this.save(); - }); - } - }, success: requestHandler, error: errorHandler }; -- 2.25.1