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)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@101975 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-03-31 06:37:30 +00:00 committed by Sam Minnee
parent 65c711cfea
commit a4c9707af2

View File

@ -451,6 +451,19 @@ ImageForm.prototype = {
this.elements.Width.onchange = function() { __form.update_params('Width'); }; this.elements.Width.onchange = function() { __form.update_params('Width'); };
this.elements.Height.onchange = function() { __form.update_params('Height'); }; 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() { destroy: function() {
this.ToolbarForm = null; this.ToolbarForm = null;
this.onsubmit = null; this.onsubmit = null;
@ -522,12 +535,6 @@ ImageForm.prototype = {
this.elements.Height.value = imgElement.style.height ? parseInt(imgElement.style.height) : imgElement.height; this.elements.Height.value = imgElement.style.height ? parseInt(imgElement.style.height) : imgElement.height;
} else { } else {
this.selectedNode = null; 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 = '';
} }
}, },
@ -651,6 +658,13 @@ ImageThumbnail.prototype = {
if(el && el.nodeName == 'IMG') { if(el && el.nodeName == 'IMG') {
ed.dom.setAttribs(el, attributes); ed.dom.setAttribs(el, attributes);
} else { } 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, { ed.execCommand('mceInsertContent', false, html, {
skip_undo : 1 skip_undo : 1
}); });