From b61f5e4a38c99359e1902c3e394f6e67a5dc7ca4 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Sun, 20 Jan 2013 19:25:43 +0100 Subject: [PATCH 1/2] Hide currently opened dialog when it is shown for another element. --- src/toolbar/dialog.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/toolbar/dialog.js b/src/toolbar/dialog.js index e655948a..ffe85c6f 100644 --- a/src/toolbar/dialog.js +++ b/src/toolbar/dialog.js @@ -163,8 +163,13 @@ * Show the dialog element */ show: function(elementToChange) { - if (dom.hasClass(this.link, CLASS_NAME_OPENED)) { - return; + if (this.opened) { + if (this.elementToChange == elementToChange) { + return; + } + else { + this.hide(); + } } var that = this, @@ -176,6 +181,7 @@ this.interval = setInterval(function() { that._interpolate(true); }, 500); } dom.addClass(this.link, CLASS_NAME_OPENED); + this.opened = true; this.container.style.display = ""; this.fire("show"); if (firstField && !elementToChange) { @@ -189,9 +195,14 @@ * Hide the dialog element */ hide: function() { + if (!this.opened) { + return; + } + clearInterval(this.interval); this.elementToChange = null; dom.removeClass(this.link, CLASS_NAME_OPENED); + this.opened = false; this.container.style.display = "none"; this.fire("hide"); } From 96a9454c36afe48a8536a2748baa147b4575b877 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Sun, 20 Jan 2013 19:26:20 +0100 Subject: [PATCH 2/2] Bubble editor 'hide' event up through editor as 'hide:dialog'. --- src/toolbar/toolbar.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/toolbar/toolbar.js b/src/toolbar/toolbar.js index fcfd125e..8a097603 100644 --- a/src/toolbar/toolbar.js +++ b/src/toolbar/toolbar.js @@ -85,6 +85,10 @@ that.editor.fire("show:dialog", { command: command, dialogContainer: dialogElement, commandLink: link }); }); + dialog.on("hide", function() { + that.editor.fire("hide:dialog", { command: command, dialogContainer: dialogElement, commandLink: link }); + }); + dialog.on("save", function(attributes) { if (caretBookmark) { that.composer.selection.setBookmark(caretBookmark);