Skip to content

Commit

Permalink
BUGFIX Resetting image sidepanel fields when opening the panel instea…
Browse files Browse the repository at this point in the history
…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
Sam Minnee committed Oct 13, 2010
1 parent e2d17d9 commit d99c2c7
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions javascript/tiny_mce_improvements.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = '';
}
},

Expand Down Expand Up @@ -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
});
Expand Down

0 comments on commit d99c2c7

Please sign in to comment.