Commit d1c6ae24 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Updating image description in image selector in TinyMCE. Bug 1502373"

parents e618ed73 d03fd4d8
......@@ -165,6 +165,27 @@ tinymce.PluginManager.add('imagebrowser', function(editor) {
if (deletebutton.length) {
deletebutton.focus();
}
// As we have several submit buttons in the form
// Add the attribute clicked=true to the clicked button
// This will help identify which submit button was clicked
jQuery('form' + formname + ' input[type=submit], button[type=submit]').click(function() {
jQuery("input[type=submit], button[type=submit]", jQuery(this).parents('form' + formname)).removeAttr("clicked");
// Add the submit button name/value as a hidden field to get this to work in FF
if (jQuery('#edit_file').length) {
jQuery('#edit_file').prop('name', jQuery(this).context.name).prop('value', jQuery(this).context.value);
}
else {
jQuery('<input>').attr({
type: 'hidden',
id: 'edit_file',
name: jQuery(this).context.name,
value: jQuery(this).context.value
}).appendTo(jQuery(this).parents('form' + formname));
}
jQuery(this).attr("clicked", "true");
});
} // end of addImageBrowser()
function getSelectedImageUrl() {
......@@ -178,76 +199,87 @@ tinymce.PluginManager.add('imagebrowser', function(editor) {
return url;
}
function onSubmitForm() {
function waitLoad(imgElm) {
function selectImage() {
imgElm.onload = imgElm.onerror = null;
editor.selection.select(imgElm);
editor.nodeChanged();
function onSubmitForm(e) {
// Find which submit button was clicked
var clickedButton = jQuery('form' + formname + " input[type=submit][clicked=true]");
if ((clickedButton.length > 0)
&& ('#' + clickedButton[0].id == formname + '_artefactid_edit_artefact')) {
var fileBrowserForm = window["imgbrowserconf_artefactid"];
if (fileBrowserForm) {
fileBrowserForm.submitform();
}
imgElm.onload = function() {
if (!data.width && !data.height) {
dom.setAttribs(imgElm, {
width: imgElm.clientWidth,
height: imgElm.clientHeight
});
}
else {
function waitLoad(imgElm) {
function selectImage() {
imgElm.onload = imgElm.onerror = null;
editor.selection.select(imgElm);
editor.nodeChanged();
}
selectImage();
};
imgElm.onerror = selectImage;
}
imgElm.onload = function() {
if (!data.width && !data.height) {
dom.setAttribs(imgElm, {
width: imgElm.clientWidth,
height: imgElm.clientHeight
});
}
selectImage();
};
imgElm.onerror = selectImage;
}
updateStyle();
updateStyle();
var data = getFormVals();
var data = getFormVals();
if (data.width === '') {
data.width = null;
}
if (data.width === '') {
data.width = null;
}
if (data.height === '') {
data.height = null;
}
if (data.height === '') {
data.height = null;
}
if (data.style === '') {
data.style = null;
}
if (data.style === '') {
data.style = null;
}
data = {
src: data.src,
alt: data.alt,
width: data.width,
height: data.height,
style: data.style
};
data = {
src: data.src,
alt: data.alt,
width: data.width,
height: data.height,
style: data.style
};
editor.undoManager.transact(function() {
if (!data.src) {
if (imgElm) {
dom.remove(imgElm);
editor.nodeChanged();
editor.undoManager.transact(function() {
if (!data.src) {
if (imgElm) {
dom.remove(imgElm);
editor.nodeChanged();
}
return;
}
return;
}
if (!imgElm) {
data.id = '__mcenew';
editor.focus();
editor.selection.setContent(dom.createHTML('img', data));
imgElm = dom.get('__mcenew');
dom.setAttrib(imgElm, 'id', null);
} else {
dom.setAttribs(imgElm, data);
}
if (!imgElm) {
data.id = '__mcenew';
editor.focus();
editor.selection.setContent(dom.createHTML('img', data));
imgElm = dom.get('__mcenew');
dom.setAttrib(imgElm, 'id', null);
} else {
dom.setAttribs(imgElm, data);
}
waitLoad(imgElm);
});
if (jQuery('#configureblock').length) {
jQuery('#configureblock').removeClass('hidden');
waitLoad(imgElm);
});
if (jQuery('#configureblock').length) {
jQuery('#configureblock').removeClass('hidden');
}
removeImageBrowser();
}
removeImageBrowser();
} // end onSubmitForm
function removeImageBrowser() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment