close dialogs when clicking outside of the dialog container

This commit is contained in:
juliandescottes 2016-10-02 00:56:13 +02:00
parent 4e515f4820
commit dd58af30b9

View File

@ -42,6 +42,8 @@
// adding the .animated class here instead of in the markup to avoid an animation during app startup // adding the .animated class here instead of in the markup to avoid an animation during app startup
this.dialogWrapper_.classList.add('animated'); this.dialogWrapper_.classList.add('animated');
pskl.utils.Event.addEventListener(this.dialogWrapper_, 'click', this.onWrapperClicked_, this);
}; };
ns.DialogsController.prototype.onCreatePaletteShortcut_ = function () { ns.DialogsController.prototype.onCreatePaletteShortcut_ = function () {
@ -69,6 +71,12 @@
this.showDialog(args.dialogId, args.initArgs); this.showDialog(args.dialogId, args.initArgs);
}; };
ns.DialogsController.prototype.onWrapperClicked_ = function (evt) {
if (evt.target === this.dialogWrapper_) {
this.hideDialog();
}
};
ns.DialogsController.prototype.showDialog = function (dialogId, initArgs) { ns.DialogsController.prototype.showDialog = function (dialogId, initArgs) {
if (this.isDisplayingDialog_()) { if (this.isDisplayingDialog_()) {
return; return;