1 import {fadeIn, fadeOut} from "../services/animations";
2 import {onSelect} from "../services/dom";
5 * Popup window that will contain other content.
6 * This component provides the show/hide functionality
7 * with the ability for popup@hide child references to close this.
13 this.container = this.$el;
14 this.hideButtons = this.$manyRefs.hide || [];
18 this.setupListeners();
22 let lastMouseDownTarget = null;
23 this.container.addEventListener('mousedown', event => {
24 lastMouseDownTarget = event.target;
27 this.container.addEventListener('click', event => {
28 if (event.target === this.container && lastMouseDownTarget === this.container) {
33 onSelect(this.hideButtons, e => this.hide());
36 hide(onComplete = null) {
37 fadeOut(this.container, 120, onComplete);
39 window.removeEventListener('keyup', this.onkeyup);
47 show(onComplete = null, onHide = null) {
48 fadeIn(this.container, 120, onComplete);
50 this.onkeyup = (event) => {
51 if (event.key === 'Escape') {
55 window.addEventListener('keyup', this.onkeyup);