From d99c2c7ee4f812c76bd91953f7b5e00380e53869 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 13 Oct 2010 01:23:29 +0000 Subject: [PATCH] BUGFIX Resetting image sidepanel fields when opening the panel instead of inserting an image, to avoid losing focus of TinyMCE in IE. Using getBookmark() in TinyMCE to save the original location. (fixes #5263) (from r101975) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112052 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/tiny_mce_improvements.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/javascript/tiny_mce_improvements.js b/javascript/tiny_mce_improvements.js index bf28b7e24..1412abb5c 100755 --- a/javascript/tiny_mce_improvements.js +++ b/javascript/tiny_mce_improvements.js @@ -450,6 +450,19 @@ ImageForm.prototype = { this.elements.Width.onchange = function() { __form.update_params('Width'); }; this.elements.Height.onchange = function() { __form.update_params('Height'); }; }, + toggle: function(ed) { + this.ToolbarForm.toggle(ed); + + this.resetFields(); + }, + resetFields: function() { + this.elements.AltText.value = ''; + this.elements.ImageTitle.value = ''; + this.elements.CSSClass.value = 'left'; + this.elements.CaptionText.value = ''; + this.elements.CaptionText.disabled = ''; + this.elements.CSSClass.disabled = ''; + }, destroy: function() { this.ToolbarForm = null; this.onsubmit = null; @@ -521,12 +534,6 @@ ImageForm.prototype = { this.elements.Height.value = imgElement.style.height ? parseInt(imgElement.style.height) : imgElement.height; } else { this.selectedNode = null; - this.elements.AltText.value = ''; - this.elements.ImageTitle.value = ''; - this.elements.CSSClass.value = 'left'; - this.elements.CaptionText.value = ''; - this.elements.CaptionText.disabled = ''; - this.elements.CSSClass.disabled = ''; } }, @@ -650,6 +657,13 @@ ImageThumbnail.prototype = { if(el && el.nodeName == 'IMG') { ed.dom.setAttribs(el, attributes); } else { + // Focus gets saved in tinymce_ssbuttons when opening the sidebar. + // Unless the focus has changed in the meantime, reset it to the previous position. + // This is necessary because IE can lose its focus if any of the sidebar input fields are used. + if(ed.ss_focus_bookmark) { + ed.selection.moveToBookmark(ed.ss_focus_bookmark); + delete ed.ss_focus_bookmark; + } ed.execCommand('mceInsertContent', false, html, { skip_undo : 1 });