Starter Lab Productions Play
Project Docs Github
Log in
ittf site docs play t js appManager.js.ittf Edit
  • /ittf/site/docs/play/t/js/appManager.js.ittf
  • /ittf/site/docs/play/t/js/app/splash.js.ittf
  • /ittf/site/docs/play/t/js/app/initial_snippets.js.ittf
  • /ittf/site/docs/play/t/js/app/initial_ittfs.js.ittf
  • /t/js/event_emit.js.ittf
  • /t/js/event_on.js.ittf

/ittf/site/docs/play/t/js/appManager.js.ittf (primary)

edit
                                            
1 $group
2 $include app/splash
3 $include app/initial_snippets
4 $include app/initial_ittfs
5 class AppManager
6 ctor
7 param props
8 set this.props = props
9 set this.store = null
10 set this.timers = {}
11 m start
12 set this.dataManager
13 new DataManager
14 {
15 set this.treeManager
16 new TreeManager
17 {
18 _ this.initStore
19 _ this.createEditors
20 _ this.setEvents
21 _ this.createOptions
22 _ this.dataManager.getCheatsheetList
23 m initStore
24 set this.store = new LocalStorage('wizzify')
25 if !this.store.get('lastSchema')
26 _ this.store.set('lastSchema', 'js')
27 m createOptions
28 set this.selectedSchema = this.store.get('lastSchema')
29 $$ VIA _ wz.value('selectedSchema', this.selectedSchema)
30 # _ this.setIttfContentFromStore
31 # _ this.setSnippetContentFromStore
32 $* VIA
33 _ wz.change
34 @ 'selectedSchema'
35 =>
36 log 'onChangeSchema', event.target.value
37 _ this.selectSchema
38 @ event.target.value
39 *$
40 _ wz.clickClass
41 @ 'sh-bo-lsb-schema-button'
42 =>
43 # log 'onClick', event.target.id.substring(3)
44 $*
45 _ wz.value
46 @ 'selectedSchema'
47 @ event.target.id.substring(3)
48 *$
49 _ this.selectSchema
50 @ event.target.id.substring(3)
51 _ wz.addClass
52 @ 'id_' + this.selectedSchema
53 @ 'selected'
54 {
55 @ removeOnClass 'sh-bo-lsb-schema-button'
56 js/event_emit( schema-selected)
57 @ name this.selectedSchema
58 $$ VIA _ wz.show('selectedSchema')
59 m selectSchema
60 param schema
61 set this.selectedSchema = schema
62 js/event_emit( schema-selected)
63 @ name this.selectedSchema
64 _ this.store.set('lastSchema', this.selectedSchema)
65 _ this.applySchemaChange
66 @ this.lastKey
67 @ this.lastValue
68 @ 100
69 _ wz.addClass
70 @ 'id_' + schema
71 @ 'selected'
72 {
73 @ removeOnClass 'sh-bo-lsb-schema-button'
74 js/event_emit( seteditvalue)
75 @ key 'gen-ittf'
76 @ value ''
77 js/event_emit( seteditvalue)
78 @ key 'gen-result'
79 @ value ''
80 js/event_emit( seteditvalue)
81 @ key 'snippet-source'
82 @ value ''
83 js/event_emit( seteditvalue)
84 @ key 'snippet-result'
85 @ value ''
86 # _ this.setIttfContentFromStore
87 # _ this.setSnippetContentFromStore
88 m setIttfContentFromStore
89 var content
90 _ this.store.get
91 @ this.selectedSchema + '_ittf_content'
92 @ initialIttfs[this.selectedSchema] || this.selectedSchema
93 @ true
94 js/event_emit( seteditvalue)
95 @ key 'gen-ittf'
96 @ value content
97 m setSnippetContentFromStore
98 var content
99 _ this.store.get
100 @ this.selectedSchema + '_snippet_content'
101 @ initialSnippets[this.selectedSchema] || this.selectedSchema
102 @ true
103 js/event_emit( seteditvalue)
104 @ key 'snippet-source'
105 @ value content
106 m createEditors
107 set this.genIttfEditor
108 new EditorControl
109 {
110 @ key 'gen-ittf'
111 @ elementId 'gen-ittf-editor'
112 _ this.genIttfEditor.initialize
113 set this.genResultEditor
114 new EditorControl
115 {
116 @ key 'gen-result'
117 @ elementId 'gen-result-editor'
118 @ readOnly true
119 _ this.genResultEditor.initialize
120 set this.snippetSourceEditor
121 new EditorControl
122 {
123 @ key 'snippet-source'
124 @ elementId 'snippet-source-editor'
125 _ this.snippetSourceEditor.initialize
126 set this.snippetResultEditor
127 new EditorControl
128 {
129 @ key 'snippet-result'
130 @ elementId 'snippet-result-editor'
131 @ readOnly true
132 _ this.snippetResultEditor.initialize
133 m setEvents
134 js/event_on( ittf-cheatsheet-item-changed)
135 var content
136 _ this.dataManager.getIttfCheatsheetItem
137 @ data.id
138 # _ alert(content);
139 js/event_emit( seteditvalue)
140 @ key 'gen-ittf'
141 @ value content
142 _ this.generate
143 @ content
144 js/event_on( snippet-cheatsheet-item-changed)
145 var content
146 _ this.dataManager.getSnippetCheatsheetItem
147 @ data.id
148 # _ alert(content);
149 js/event_emit( seteditvalue)
150 @ key 'snippet-source'
151 @ value content
152 _ this.wizzify
153 @ content
154 js/event_on( editvaluechanged)
155 set this.lastKey = data.key
156 set this.lastValue = data.value
157 var elapse = data.defer ? 2 * 1500 : 100
158 _ this.applySchemaChange
159 @ data.key
160 @ data.value
161 @ data.defer ? 2 * 1500 : 100
162 return
163 if key === 'gen-ittf'
164 if this.timers['gen']
165 _ clearTimeout
166 @ this.timers['gen']
167 set this.timers['gen']
168 _ setTimeout
169 =>
170 _ this.generate
171 @ value
172 @ elapse
173 _ this.store.set
174 @ this.selectedSchema + '_ittf_content'
175 @ value
176 elif key === 'snippet-source'
177 if this.timers['wizzify']
178 _ clearTimeout
179 @ this.timers['wizzify']
180 set this.timers['wizzify']
181 _ setTimeout
182 =>
183 _ this.wizzify
184 @ value
185 @ elapse
186 _ this.store.set
187 @ this.selectedSchema + '_snippet_content'
188 @ value
189 m applySchemaChange
190 param key
191 param value
192 param elapse
193 if key === 'gen-ittf'
194 if this.timers['gen']
195 _ clearTimeout
196 @ this.timers['gen']
197 set this.timers['gen']
198 _ setTimeout
199 =>
200 _ this.generate
201 @ value
202 @ elapse
203 _ this.store.set
204 @ this.selectedSchema + '_ittf_content'
205 @ value
206 elif key === 'snippet-source'
207 if this.timers['wizzify']
208 _ clearTimeout
209 @ this.timers['wizzify']
210 set this.timers['wizzify']
211 _ setTimeout
212 =>
213 _ this.wizzify
214 @ value
215 @ elapse
216 _ this.store.set
217 @ this.selectedSchema + '_snippet_content'
218 @ value
219 m generate
220 param value
221 var genFunc = "genFromText"
222 if this.selectedSchema == 'ittf'
223 set genFunc = "mTreeFromText"
224 _ wz[genFunc]
225 @ value
226 {
227 @ schema this.selectedSchema || 'js'
228 =>
229 param err
230 param result
231 if err
232 log 'generate.err', err
233 js/event_emit( seteditvalue)
234 @ key 'gen-result'
235 @ value JSON.stringify(err, null, 2)
236 else
237 js/event_emit( artifactgenerated)
238 @ content result
239 js/event_emit( seteditvalue)
240 @ key 'gen-result'
241 @ value result
242 m wizzify
243 param value
244 _ wz.wizzify
245 @ this.selectedSchema || 'js'
246 @ value
247 =>
248 param err
249 param result
250 log 'wizzify', err
251 if err
252 log 'wizzify.err', err
253 js/event_emit( seteditvalue)
254 @ key 'snippet-result'
255 @ value JSON.stringify(err, null, 2)
256 else
257 js/event_emit( artifactwizzified)
258 @ content result
259 js/event_emit( seteditvalue)
260 @ key 'snippet-result'
261 @ value result

/ittf/site/docs/play/t/js/app/splash.js.ittf

edit
                                            
1 $group
2 class SplashControl
3 ctor
4 param props
5 set this.props = props
6 set this.splashEl = null
7 set this.state = []
8 set this.visible == false
9 m initialize
10 var containerEl
11 _ wz.element
12 @ this.props.container
13 set this.splashEl = document.createElement('div')
14 _ this.splashEl.setAttribute('class', this.props.className)
15 _ containerEl.appendChild(this.splashEl)
16 _ this.show
17 m hide
18 if this.visible == false
19 return
20 set this.visible = false
21 var containerEl
22 _ wz.element
23 @ this.props.container
24 foreach item in containerEl.children
25 if item != this.splashEl
26 _ wz.show
27 @ item
28 if this.state[item]
29 set item.style.display = this.state[item]
30 _ wz.hide
31 @ this.splashEl
32 m show
33 if this.visible
34 return
35 set this.visible = true
36 var containerEl
37 _ wz.element
38 @ this.props.container
39 _ wz.show
40 @ this.splashEl
41 foreach item in containerEl.children
42 if item != this.splashEl
43 set this.state[item] = item.style.display
44 _ wz.hide
45 @ item

/ittf/site/docs/play/t/js/app/initial_snippets.js.ittf

edit
                                            
1 $group
2 var initialSnippets
3 {
4 @ js 'function hello(name) { console.log("hello"); }'
5 @ html '<html><head></head><body></body></html>'
6 @ css 'body { margin:0 }'

/ittf/site/docs/play/t/js/app/initial_ittfs.js.ittf

edit
                                            
1 $group
2 var initialIttfs
3 {
4 @ js 'module\n\tkind react\n\treact Mycomponent'
5 @ html 'html\n\thead\n\tbody\n\t\th1 hello world'
6 @ css 'css\n\t< body\n\t\tmargin 0'

/t/js/event_emit.js.ittf

edit
                                            
1 $group
2 $params name
3 _ glEventHub.emit
4 @ '${name}'
5 {
6 $hook

/t/js/event_on.js.ittf

edit
                                            
1 $group
2 $params name
3 _ glEventHub.on
4 @ '${name}'
5 =>
6 param data
7 log 'on ${name}', data
8 $hook
Save
Save & Refresh
Cancel