Skip to content

Commit

Permalink
Only allow one tooltip at one time. Fix #233
Browse files Browse the repository at this point in the history
  • Loading branch information
aarranz committed Oct 4, 2016
1 parent 6999b2d commit 2eafe31
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/wirecloud/commons/static/js/StyledElements/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
var _show = function _show(refPosition) {

if ('Wirecloud' in window) {
Wirecloud.UserInterfaceManager._registerPopup(this);
Wirecloud.UserInterfaceManager._registerTooltip(this);
}

if (this.visible) {
Expand Down Expand Up @@ -177,7 +177,7 @@
document.body.removeChild(this.element);
this.element = null;
if ('Wirecloud' in window) {
Wirecloud.UserInterfaceManager._unregisterPopup(this);
Wirecloud.UserInterfaceManager._unregisterTooltip(this);
}
}
};
Expand Down
22 changes: 20 additions & 2 deletions src/wirecloud/platform/static/js/wirecloud/UserInterfaceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
};

var coverLayerElement = null;
var currentTooltip = null;

/**
* @private
Expand Down Expand Up @@ -130,7 +131,7 @@

// Add some event listeners
window.addEventListener("resize", resizeUI.bind(this), true);
document.addEventListener('click', on_task_click.bind(this), true);
document.addEventListener('click', on_click.bind(this), true);
};

UserInterfaceManager.changeCurrentView = function changeCurrentView(newView, options) {
Expand Down Expand Up @@ -192,13 +193,30 @@
showCover();
};

UserInterfaceManager._unregisterTooltip = function _unregisterTooltip(tooltip) {
if (currentTooltip === tooltip) {
currentTooltip = null;
}
};

UserInterfaceManager._unregisterPopup = function _unregisterPopup(popup) {
var index = this.currentPopups.indexOf(popup);
if (index !== -1) {
this.currentPopups.splice(index, 1);
}
};

UserInterfaceManager._registerTooltip = function _registerTooltip(tooltip) {
if (tooltip != null && !('hide' in tooltip)) {
throw new TypeError('invalid tooltip parameter');
}

if (currentTooltip != null) {
currentTooltip.hide();
}
currentTooltip = tooltip;
};

UserInterfaceManager._registerPopup = function _registerPopup(popup) {
if (popup != null && !('hide' in popup)) {
throw new TypeError('invalid popup parameter');
Expand Down Expand Up @@ -277,7 +295,7 @@
}
};

var on_task_click = function on_task_click(event) {
var on_click = function on_click(event) {
var loadingElement = document.getElementById("loading-window");
if (!(loadingElement.classList.contains("in"))) {
loadingElement.classList.remove("fade");
Expand Down

0 comments on commit 2eafe31

Please sign in to comment.