-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclient.dialog.coffee
51 lines (51 loc) · 2.38 KB
/
client.dialog.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
ui.board.addSquareButton = (text, position, clickHandler) ->
element = parseElement("""
<g transform="translate(#{position.x},#{position.y})" cursor="pointer"
xmlns="http://www.w3.org/2000/svg">
<rect x="-52" y="-52" width="104" height="104" rx="8" opacity="0.8"
fill="rgb(0,128,255)" stroke="rgb(255,255,255)" stroke-width="3" />
<text x="0" y="20" fill="rgb(255,255,255)" font-size="56" text-anchor="middle" />
</g>
""")
element.getElementsByTagName("text")[0].textContent = text
setElementClickHandler(element, clickHandler) if clickHandler?
ui.boardDialog.appendChild(element)
element
ui.board.addButton = (text, position, clickHandler) ->
element = parseElement("""
<g transform="translate(#{position.x},#{position.y})" cursor="pointer"
xmlns="http://www.w3.org/2000/svg">
<rect x="-104" y="-52" width="208" height="104" opacity="0.8"
fill="rgb(0,128,255)" stroke="rgb(255,255,255)" stroke-width="3" />
<text x="0" y="20" fill="rgb(255,255,255)" font-size="56" text-anchor="middle" />
</g>
""")
element.backgroundChecked = "rgb(255,48,48)"
element.backgroundUnchecked = "rgb(0,128,255)"
element.isChecked = false
element.getElementsByTagName("text")[0].textContent = text
setElementClickHandler(element, clickHandler) if clickHandler?
ui.boardDialog.appendChild(element)
element
ui.board.addSmallButton = (text, position, clickHandler) ->
element = ui.board.addButton(text, position, clickHandler)
setElementScale(element, 0.75)
element
ui.board.addLabel = (text, position, fontSize) ->
fontSize ?= 56
element = parseElement("""
<text x="0" y="#{fontSize / 2.8}" fill="rgb(0,0,0)" font-size="#{fontSize}"
text-anchor="middle" transform="translate(#{position.x},#{position.y})"
xmlns="http://www.w3.org/2000/svg" />
""")
element.textContent = text
ui.boardDialog.appendChild(element)
element
ui.board.setButtonChecked = (button) ->
rect = button.getElementsByTagName("rect")[0]
rect.setAttribute("fill", button.backgroundChecked)
button.isChecked = true
ui.board.setButtonUnchecked = (button) ->
rect = button.getElementsByTagName("rect")[0]
rect.setAttribute("fill", button.backgroundUnchecked)
button.isChecked = false