diff options
author | TrueDoctor <d-kobert@web.de> | 2018-09-30 00:00:06 +0200 |
---|---|---|
committer | TrueDoctor <d-kobert@web.de> | 2018-09-30 00:00:06 +0200 |
commit | 7db0e121521733273a8ca3977e91e6f88756f38a (patch) | |
tree | af132ad3652163f323118601b9d196b207360f0a /WebInterface/NodeJSServer/src/modules/ui/modal.js | |
parent | 632781d1adf54287ecfe7cbcbc17074e14a769b2 (diff) | |
parent | f97f25ea54a0f888d2195d6868346854a2a005e0 (diff) |
Merge branch 'WebApi' of https://github.com/TrueDoctor/DiscoBot into WebApi
Diffstat (limited to 'WebInterface/NodeJSServer/src/modules/ui/modal.js')
-rw-r--r-- | WebInterface/NodeJSServer/src/modules/ui/modal.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/WebInterface/NodeJSServer/src/modules/ui/modal.js b/WebInterface/NodeJSServer/src/modules/ui/modal.js new file mode 100644 index 0000000..e1aa8a2 --- /dev/null +++ b/WebInterface/NodeJSServer/src/modules/ui/modal.js @@ -0,0 +1,39 @@ +export default class Modal { + constructor(titleString) { + let modalBackground = document.createElement('div'); + let modal = document.createElement('div'); + let title = document.createElement('h1'); + let body = document.createElement('div'); + + modalBackground.className = 'modal-container'; + modal.className = 'modal'; + title.className = 'modal-title'; + body.className = 'modal-body' + + title.textContent = titleString; + + modal.appendChild(title); + modalBackground.appendChild(modal); + document.body.appendChild(modalBackground); + + this.bg = modalBackground; + this.modal = modal; + this.title = title; + this.body = body; + + this.registerEvents(); + } + + registerEvents() { + this.bg.addEventListener('click', () => { + this.bg.classList.add('hidden'); + this.bg.addEventListener('transitionend', () => { + document.body.removeChild(this.bg); + }); + }); + } + + setBodyText(text) { + this.body.textContent = text; + } +} |