Project Docs Github
Log in
ittf meta html t js modalManager.js.ittf Edit
  • /ittf/meta/html/t/js/modalManager.js.ittf

/ittf/meta/html/t/js/modalManager.js.ittf (primary)

edit
                                            
1 $group
2 class ModalManager
3 ctor
4 param ctx
5 set this.ctx = ctx
6 set this.dialogs = {}
7 m checkClick
8 param dialogKey
9 param target
10 # Not implemented yet
11 # log 'wz.ModalManager.checkClick', target
12 return false
13 m show
14 param dialogKey
15 param formId
16 var dialogData
17 _ this.createMarkup
18 @ dialogKey
19 if !dialogData.currentContent
20 var formEl
21 _ wz.element( '#' + formId)
22 if !formEl
23 throw new Error('In wz.modalManager.show() the formId is not an existing html element: ' + formId)
24 _ dialogData.modalContentElement.appendChild
25 @ formEl
26 set formEl.style.display = "block"
27 set dialogData.currentContent = formEl
28 set dialogData.modalElement.style.display = "block"
29 m hide
30 param dialogKey
31 var dialogData
32 _ this.createMarkup
33 @ dialogKey
34 if !dialogData
35 throw new Error('In wz.modalManager.hide() the dialogKey is unknown: ' + dialogKey)
36 set dialogData.modalElement.style.display = "none"
37 m createMarkup
38 param dialogKey
39 if !this.dialogs[dialogKey]
40 set this.dialogs[dialogKey] = {}
41 var dialog = this.dialogs[dialogKey]
42 if dialog.modalElement
43 return dialog
44 var modalsContainer = wz.element('#' + this.ctx.modalsContainerId)
45 if !modalsContainer
46 set modalsContainer = document.createElement('div')
47 _ modalsContainer.setAttribute('id', this.ctx.modalsContainerId)
48 _ document.body.appendChild(modalsContainer)
49 # . modal
50 # id edit-modal
51 # . modal-content
52 # id edit-modal-content
53 # span ×
54 # class modal-close
55 var spanClose = document.createElement('span')
56 _ spanClose.setAttribute('class', 'modal-close')
57 _ wz.text(spanClose, 'X')
58 var that = this
59 _ wz.click
60 @ spanClose
61 function
62 _ that.hide
63 @ dialogKey
64 set dialog.modalContentElement = document.createElement('div')
65 _ dialog.modalContentElement.setAttribute('class', 'modal-content')
66 _ dialog.modalContentElement.setAttribute('id', dialogKey + '-modal-content')
67 set dialog.modalElement = document.createElement('div')
68 _ dialog.modalElement.setAttribute('class', 'modal')
69 _ dialog.modalElement.setAttribute('id', dialogKey + '-modal')
70 _ dialog.modalContentElement.appendChild(spanClose)
71 _ dialog.modalElement.appendChild(dialog.modalContentElement)
72 _ modalsContainer.appendChild(dialog.modalElement)
73 return dialog
Save
Save & Refresh
Cancel