Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

Hide currently opened dialog when it is shown for another element. #317

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/toolbar/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand All @@ -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");
}
Expand Down
4 changes: 4 additions & 0 deletions src/toolbar/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down