Skip to content

Commit

Permalink
fix the overlay button inside the TinyMCE plugin. For some reasons, i…
Browse files Browse the repository at this point in the history
…n Firefox the button was not easily clickable. Thanks to Olli!

--HG--
extra : convert_revision : svn%3Afc1ba2b4-ac28-11dd-a772-7fcde58d38e6/trunk%40109
  • Loading branch information
mihai.sucan committed Aug 12, 2009
1 parent 6b83d5a commit 28367d3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Expand Up @@ -10,6 +10,11 @@ displayed at the top of PaintWeb, when it runs inside TinyMCE. The background
color is now yellow, and the two Save/Cancel actions use inputs of type=button.
Thanks to Olli Savolainen.

- The overlay button which shows "Edit" on top of images inside TinyMCE is now
no longer a link. It is an input of type=button. This change also fixed the
problem affecting Firefox users: they couldn't easily click the link, for some
reason. Thanks Olli Savolainen, again!

- The TinyMCE plugin now sets up a reference to the current TinyMCE editor
instance in the current PaintWeb.config instance. This allows extensions from
inside PaintWeb to access the TinyMCE editor - using
Expand Down
55 changes: 26 additions & 29 deletions ext/tinymce-plugin/paintweb/editor_plugin_src.js
Expand Up @@ -17,7 +17,7 @@
* along with PaintWeb. If not, see <http://www.gnu.org/licenses/>.
*
* $URL: http://code.google.com/p/paintweb $
* $Date: 2009-08-12 18:42:12 +0300 $
* $Date: 2009-08-12 19:57:50 +0300 $
*/

/**
Expand Down Expand Up @@ -187,10 +187,8 @@ function paintwebLoaded () {
*/
function paintwebInitialized (ev) {
if (overlayButton && targetEditor) {
overlayButton.title = targetEditor.getLang('paintweb.overlayButton',
overlayButton.value = targetEditor.getLang('paintweb.overlayButton',
'Edit');
overlayButton.replaceChild(document.createTextNode(overlayButton.title),
overlayButton.firstChild);
}

if (ev.state !== PaintWeb.INIT_DONE) {
Expand Down Expand Up @@ -326,10 +324,8 @@ function paintwebEditStart () {

var pwStart = function () {
if (overlayButton && overlayButton.parentNode) {
overlayButton.title = targetEditor.getLang('paintweb.overlayLoading',
overlayButton.value = targetEditor.getLang('paintweb.overlayLoading',
'Loading PaintWeb...');
overlayButton.replaceChild(document.createTextNode(overlayButton.title),
overlayButton.firstChild);
}

if (paintwebInstance) {
Expand Down Expand Up @@ -486,10 +482,8 @@ function paintwebHide () {
paintwebInstance.gui.hide();

if (overlayButton && targetEditor) {
overlayButton.title = targetEditor.getLang('paintweb.overlayButton',
overlayButton.value = targetEditor.getLang('paintweb.overlayButton',
'Edit');
overlayButton.replaceChild(document.createTextNode(overlayButton.title),
overlayButton.firstChild);
}

if (pluginBar && pluginBar.parentNode) {
Expand Down Expand Up @@ -710,19 +704,12 @@ tinymce.create('tinymce.plugins.paintweb', {
ed.onRemove.add(this.edPreProcess);
ed.onInit.add(overlayButtonCleanup);

overlayButton = document.createElement('a');
overlayStyle = overlayButton.style;

overlayButton = document.createElement('input');
overlayButton.type = 'button';
overlayButton.className = 'paintwebOverlayButton';
overlayButton.title = ed.getLang('paintweb.overlayButton', 'Edit');
overlayButton.appendChild(document.createTextNode(overlayButton.title));

overlayStyle.position = 'absolute';
overlayStyle.background = '#fff';
overlayStyle.padding = '4px 6px';
overlayStyle.border = '1px solid #000';
overlayStyle.textDecoration = 'none';
overlayStyle.color = '#000';
overlayButton.value = ed.getLang('paintweb.overlayButton', 'Edit');

overlayButton.style.position = 'absolute';
}

// Handle the dblclick events for image elements, if the user wants it.
Expand Down Expand Up @@ -833,16 +820,26 @@ tinymce.create('tinymce.plugins.paintweb', {
}

if (!disabled) {
var offsetTop = 5,
offsetLeft = 5,
sibling = null;

// Try to avoid adding the overlay button inside an anchor.
if (n.parentNode.nodeName.toLowerCase() === 'a') {
pNode = n.parentNode.parentNode;
sibling = n.parentNode.nextSibling;
} else {
pNode = n.parentNode;
sibling = n.nextSibling;
}

// Add the overlay button.
overlayButton._targetImage = n;
overlayButton.style.top = (n.offsetTop + 5) + 'px';
overlayButton.style.left = (n.offsetLeft + 5) + 'px';
overlayButton.title = ed.getLang('paintweb.overlayButton', 'Edit');
overlayButton.replaceChild(document.createTextNode(overlayButton.title),
overlayButton.firstChild);
overlayButton.style.top = (n.offsetTop + offsetTop) + 'px';
overlayButton.style.left = (n.offsetLeft + offsetLeft) + 'px';
overlayButton.value = ed.getLang('paintweb.overlayButton', 'Edit');

pNode = n.parentNode;
pNode.insertBefore(overlayButton, n.nextSibling);
pNode.insertBefore(overlayButton, sibling);
} else if (overlayButton._targetImage) {
overlayButton._targetImage = null;
}
Expand Down

0 comments on commit 28367d3

Please sign in to comment.