Make sure two overlays can't be open at the same time

This commit is contained in:
Mads Rasmussen
2018-08-27 12:36:40 +02:00
parent 8c663b5993
commit e96d16536b

View File

@@ -10,9 +10,17 @@
function overlayService(eventsService, backdropService) {
function open(overlay) {
var currentOverlay = null;
function open(newOverlay) {
// prevent two open overlays at the same time
if(currentOverlay) {
return;
}
var backdropOptions = {};
var overlay = newOverlay;
// set the default overlay position to center
if(!overlay.position) {
@@ -26,11 +34,13 @@
overlay.show = true;
backdropService.open(backdropOptions);
currentOverlay = overlay;
eventsService.emit("appState.overlay", overlay);
}
function close() {
backdropService.close();
currentOverlay = null;
eventsService.emit("appState.overlay", null);
}