Permalink
Browse files

BUGFIX Resetting image sidepanel fields when opening the panel instea…

…d 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
  • Loading branch information...
1 parent e2d17d9 commit d99c2c7ee4f812c76bd91953f7b5e00380e53869 @sminnee sminnee committed Oct 13, 2010
Showing with 20 additions and 6 deletions.
  1. +20 −6 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
});

0 comments on commit d99c2c7

Please sign in to comment.