-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectAccount.js
More file actions
71 lines (59 loc) · 1.49 KB
/
selectAccount.js
File metadata and controls
71 lines (59 loc) · 1.49 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
/**
Template Controllers
@module Templates
*/
/**
The select account template
@class [template] dapp_selectAccount
@constructor
*/
Template['dapp_selectAccount'].onCreated(function(){
if(this.data ) {
if(this.data.value) {
TemplateVar.set('value', this.data.value);
} else if(this.data.accounts && this.data.accounts[0]) {
TemplateVar.set('value', this.data.accounts[0].address);
}
}
});
Template['dapp_selectAccount'].helpers({
/**
Check if its a normal account
@method (isAccount)
*/
'isAccount': function(){
return this.type === 'account' && Template.parentData(1).showAccountTypes;
},
/**
Return the selected attribute if its selected
@method (selected)
*/
'selected': function(){
return (TemplateVar.get('value') === this.address)
? {selected: true}
: {};
},
/**
Check if the current selected unit is not ether
@method (isNotSeroUnit)
*/
'isNotSeroUnit': function() {
return SeroTools.getUnit().toLowerCase() !== 'sero';
},
/**
Check if the current selected unit is not ether
@method (isNotSeroUnit)
*/
'isAddress': function() {
return web3.isAddress(TemplateVar.get('value'));
}
});
Template['dapp_selectAccount'].events({
/**
Set the selected address.
@event change select
*/
'change select': function(e){
TemplateVar.set('value', e.currentTarget.value);
}
});