From cca374734678a962a6edf7b77dfe778fff61842b Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 30 Aug 2018 16:30:30 +0200 Subject: [PATCH] popups: better close handlers --- src/browser/js/app/ui/utils.js | 9 ++++++--- src/browser/js/app/widgets/containers/modal.js | 8 ++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/browser/js/app/ui/utils.js b/src/browser/js/app/ui/utils.js index 73cb3052..d3151d82 100644 --- a/src/browser/js/app/ui/utils.js +++ b/src/browser/js/app/ui/utils.js @@ -38,9 +38,12 @@ module.exports = { `) if (this.closable) { - DOM.get(this.html, '.popup-title .closer')[0].addEventListener('fast-click', (e)=>{ - e.detail.preventDefault = true - this.close() + var closer = DOM.get(this.html, '.popup-title .closer')[0] + this.html.addEventListener('fast-click',(e)=>{ + if (e.target === this.html || e.target === closer) { + e.detail.preventDefault = true + this.close() + } }) } diff --git a/src/browser/js/app/widgets/containers/modal.js b/src/browser/js/app/widgets/containers/modal.js index b36a39a6..cb6898f1 100644 --- a/src/browser/js/app/widgets/containers/modal.js +++ b/src/browser/js/app/widgets/containers/modal.js @@ -68,11 +68,6 @@ module.exports = class Modal extends Panel { this.popup.classList.add('y-positionned') } - DOM.get(this.popup, '.closer')[0].addEventListener('fast-click', (e)=>{ - e.detail.preventDefault = true - this.setValue(0, {sync:true, send:true}) - }) - this.light = this.container.appendChild(DOM.create('
')) if (this.getProp('doubleTap')) { @@ -86,8 +81,9 @@ module.exports = class Modal extends Panel { }) } + var closer = DOM.get(this.popup, '.closer')[0] this.popup.addEventListener('fast-click',(e)=>{ - if (e.target == this.popup && this.value == 1) { + if ((e.target === this.popup || e.target === closer) && this.value == 1) { e.detail.preventDefault = true this.setValue(0, {sync:true, send:true}) }