-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtef_button.html
68 lines (64 loc) · 2.17 KB
/
tef_button.html
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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../core-style/core-style.html">
<link rel="import" href="tef_button_styles.html">
<polymer-element name="tef-button" attributes ="href block size type disabled toggle active" on-click="{{onClick}}">
<template>
<core-style ref="tef-button"></core-style>
<a href="{{href}}" class="{{resolveClass(size,type,disabled,active)}}">
<content></content>
</a>
</template>
<script>
Polymer({
publish: {
active: {
value: false,
reflect: true
},
block: {
value: false,
reflect: true
},
disabled: {
value: false,
reflect: true
},
href: {
value: "javascript:void(0)",
reflect: false
},
toggle: {
value: false,
reflect: true
}
},
onClick: function() {
if (!this.disabled) {
if (this.toggle) {
this.active = !this.active;
if (this.active) {
this.fire('toggle-on');
} else {
this.fire('toggle-off');
}
} else {
this.fire('clicked');
}
}
},
resolveClass: function(e) {
var localClass = 'tef-button';
if (this.size) localClass += ' ' + this.size;
if (this.type) localClass += ' ' + this.type;
if (this.disabled) {
localClass += ' disabled';
} else {
if (this.toggle && this.active)
localClass += ' active';
}
if (this.block) localClass += ' block';
return localClass;
}
});
</script>
</polymer-element>