-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtangy-complete-button.js
110 lines (100 loc) · 2.27 KB
/
tangy-complete-button.js
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
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
import './util/html-element-props.js'
import './style/tangy-element-styles.js';
import './style/tangy-common-styles.js'
/**
* `tangy-complete-button`
*
*
* @customElement
* @polymer
* @demo demo/index.html
*/
class TangyCompleteButton extends PolymerElement {
static get template() {
return html`
<style include="tangy-common-styles"></style>
<style>
:host([hidden]) {
display: none;
}
:host([required]:not([disabled])) label::before {
content: "*";
color: red;
position: absolute;
top: 4px;
right: 5px;
}
.text-outer {
position: relative;
height: 100%;
}
.text-inner {
/*
position: absolute;
top: 20px;
left: 20px;
height: 30%;
/*width: 50%;
margin: -15% 0 0 -25%;*/
}
.text-inner ::slotted(*) {
}
</style>
<paper-button id="button">
<slot></slot>
</paper-button>
`;
}
static get is() { return 'tangy-complete-button'; }
static get properties() {
return {
name: {
type: String,
value: '',
reflectToAttribute: true
},
value: {
type: String,
value: '',
reflectToAttribute: true,
observer: 'onValueChange'
},
disabled: {
type: Boolean,
value: false,
observer: 'onDisabledChange',
reflectToAttribute: true
},
goHome: {
type: Boolean,
value: false,
reflectToAttribute: true
}
};
}
connectedCallback() {
super.connectedCallback();
this.addEventListener('click', this.completePressed.bind(this))
}
completePressed() {
if (this.goHome) window.location.href = './index.html'
if (this.disabled) return
if (this.value == '') {
this.value = 'on'
} else {
this.value = ''
}
}
onDisabledChange(newState, oldState) {
this.$.button = this.disabled
}
onValueChange(newState, oldState) {
if (newState == '') {
this.pressed = false
} else {
this.pressed = true
}
}
}
window.customElements.define(TangyCompleteButton.is, TangyCompleteButton);