/
FloatWindow.coffee
75 lines (52 loc) · 1.44 KB
/
FloatWindow.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Shortcuts
dir = 'ui'
mod = "#{dir}/FloatWindow"
$$ = (require "#{dir}/style").style
trace = (mes)-> Ti.API.info "#{mod}:#{mes}"
mix = (require 'helpers/util').mix
class Window
constructor: ()->
trace "start constructor"
# Local Variables
# UI
window = Ti.UI.createWindow mix $$.window,
left: 0
width: 320
height: 460
backgroundColor: '#990000'
leftBtn = Ti.UI.createButton mix $$.menuBtn,
left: 10
title: 'Left'
window.add leftBtn
rightBtn = Ti.UI.createButton mix $$.menuBtn,
right: 10
title: 'Right'
window.add rightBtn
# Functions
refresh = (color)->
if color is 'red'
window.backgroundColor = '#990000'
else
window.backgroundColor = '#000099'
return
_bubble = (type, options, propagation, source)->
window.fireEvent 'bubble',
btype: type
boptions: options || {}
bpropagation: typeof propagation == 'undefined' && true || propagation
bsource: source || mod
return
_catchBubble = (e)->
return
leftBtn.addEventListener 'click', ()->
_bubble 'showMenu'
return
rightBtn.addEventListener 'click', ()->
_bubble 'showDetail'
return
# Disclose
window.refresh = refresh
trace "end constructor"
return window
trace "end load"
module.exports = Window