-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynaButton.coffee
More file actions
141 lines (137 loc) · 5.05 KB
/
dynaButton.coffee
File metadata and controls
141 lines (137 loc) · 5.05 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
dyna = @dyna
Template.dynaButton.created = ->
dyna.reset()
if Meteor.user()
dyna.identity = Meteor.user().emails[0].address
dyna.emailMaybe = dyna.identity
dyna.nextStep 'finished'
if Session.equals 'dynaStep', 'resetPassword'
dyna.nextStep 'resetPassword'
else
dyna.nextStep 'init'
Template.dynaButton.button = ->
step = Session.get 'dynaStep' or 'init'
switch step
when 'init', 'identify', 'resetPassword'
return {
textL: 'Join!'
styleL: 'btn-primary'
iconL: ''
textR: ''
styleR: 'btn-success'
iconR: 'glyphicon glyphicon-log-in'
size: ''
tooltipR: 'Log in.'
tooltipL: 'Sign up!'
}
when 'confirmation'
return {
textL: dyna.emailMaybe
styleL: 'btn-danger'
iconL: 'glyphicon glyphicon-remove-sign'
textR: ''
styleR: 'btn-danger'
iconR: 'glyphicon glyphicon-remove-sign'
size: ''
tooltipR: 'Correct unconfirmed email.'
tooltipL: 'Correct unconfirmed email.'
}
when 'signUpNew'
return {
textL: dyna.emailMaybe
styleL: 'btn-danger'
iconL: 'glyphicon glyphicon-remove-sign'
textR: ''
styleR: 'btn-danger'
iconR: 'glyphicon glyphicon-remove-sign'
size: ''
tooltipR: 'Use a different email address.'
tooltipL: 'Use a different email address.'
}
when 'signBack'
return {
textL: dyna.emailMaybe
styleL: 'btn-danger'
iconL: 'glyphicon glyphicon-remove-sign'
textR: 'Password'
styleR: 'btn-inverse btn-default'
iconR: 'glyphicon glyphicon-question-sign'
size: ''
tooltipR: 'Reset password'
tooltipL: 'Change email?'
}
when 'finished' # logged in? or somethings wrong.
return {
textL: Meteor.user()?.emails[0]?.address or 'No User.'
styleL: 'btn-inverse'
iconL: 'glyphicon glyphicon-user'
textR: ''
styleR: 'btn-danger'
iconR: 'glyphicon glyphicon-log-out'
size: 'btn-xs'
tooltipL: 'Go to dashboard.'
tooltipR: 'Log out.'
}
when 'forgot'
return {
textL: 'Join!'
styleL: 'btn-primary'
iconL: ''
textR: ''
styleR: 'btn-success'
iconR: 'glyphicon glyphicon-log-in'
size: ''
tooltipR: 'Log in.'
tooltipL: 'Sign up!'
}
Template.dynaButton.events
'click button#dynaButtonLeft': (e, t) ->
step = Session.get('dynaStep')
switch step
when 'init', 'resetPassword'
b3.flashInfo ' please provide an email.', {
header: 'Hello!'
}
b3.flashInfo ' only important emails.', {
region: 'bottomLeft'
header: 'No spam:'
}
dyna.nextStep 'identify'
when 'identify'
dyna.reset()
dyna.nextStep 'init'
when 'finished'
lrs.updateModuleStats()
b3.dashboardModal 'dashboardX'
when 'confirmation', 'signUpNew', 'signBack'
b3.flashInfo 'Correct identification.'
dyna.nextStep 'identify'
when 'forgot'
b3.flashInfo 'Request an email to reset your password.'
dyna.nextStep 'forgot'
#send reset password link
else
'click button#dynaButtonRight': ( e, t ) ->
switch Session.get 'dynaStep'
when 'init'
b3.flashSuccess 'please authenticate.', { header: 'Welcome:' }
dyna.nextStep 'identify'
when 'identify', 'confirmation'
b3.flashInfo ' RESET', { header: 'Identity:' }
dyna.nextStep 'init'
when 'signBack', 'forgot'
b3.flashInfo 'Request an email to reset your password.'
dyna.nextStep 'forgot'
when 'signUpNew'
b3.flashInfo 'a mix of letters and numbers known secretly by you.', { header: 'Password:' }
dyna.nextStep 'signUpNew'
when 'finished'
return Meteor.logout(->
dyna.reset()
b3.flashInfo 'Logout complete.', { single: 'logout' }
dyna.nextStep 'init'
)
else
throw new Meteor.error 415, 'dynaDign state invalid.'
'mouseenter button': ( e, t ) ->
$(e.target).tooltip('toggle')