UNPKG

pragma-views2

Version:

40 lines (31 loc) 1.13 kB
import {createFullPageLayer, disposeFullPageLayer} from "./dom-helper.js"; export class ActionDialogManager { constructor(contentElement, doneCallback) { this.contentElement = contentElement; this.doneCallback = doneCallback; this.showDialog(); } dispose() { delete this.doneCallback; this.dialog.container.removeChild(this.dialog.container.firstChild); this.dialog.accept = null; this.dialog.close = null; this.layer.removeChild(this.dialog); this.dialog = null; disposeFullPageLayer(); this.layer = null; } showDialog() { this.layer = createFullPageLayer(); this.dialog = document.createElement("pragma-action-dialog"); this.dialog.classList.add("dialog"); this.dialog.accept = () => { this.doneCallback(true); }; this.dialog.close = () => { this.doneCallback(false); }; this.layer.appendChild(this.dialog); this.dialog.container.appendChild(this.contentElement); } }