-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.html
180 lines (165 loc) · 6 KB
/
state.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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<dom-module id="md-state-select">
<style></style>
<template>
<span id="span-icon"></span>
<span id="prefix-icon" style="display:none"></span>
<select>
<option value="Select">Select State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
<option value="AS">American Samoa</option>
<option value="GU">Guam</option>
<option value="MP">Northern Mariana Islands</option>
<option value="PR">Puerto Rico</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="VI">Virgin Islands</option>
</select>
<label>[[label]]</label>
<input type="hidden">
</template>
</dom-module>
<script>
Polymer({
is: 'md-state-select',
behaviors: [Elliptical.ComponentBehavior, Elliptical.MDInputBehavior],
properties: {
label: {
type: String,
value: ''
},
icon: {
type: String,
value: 'arrow-drop-down'
},
prefixIcon:{
type:String,
value:null
},
required: {
type: Boolean,
value: false
},
dataId: {
type: String,
value: null
},
dataName: {
type: String,
value: null
},
dataValue: {
type: String,
value: null
},
disabled: {
type: Boolean,
value: false
}
},
listeners: {},
ready: function () {
this._inputEvents();
this._setRequired();
this._setValueProp();
this._setId();
this._setName();
this._setValue();
this._setIcon();
this._setPrefixIcon();
this._setReadonly();
this._setDisabled();
},
_inputEvents: function () {
var self = this;
this._event(this.element, 'change', 'select', function (event) {
var target = $(event.currentTarget);
var val = target.val();
self.value = val;
self._resetSemanticState();
self._onChange(target, val);
});
},
_setValue: function (val) {
if (this.dataValue && this.dataValue !== undefined) {
var select = this.element.find('select');
select.val(this.dataValue);
this.value = this.dataValue;
}
},
_setIcon:function(){
var span=this.$['span-icon'];
var icon = 'icon-' + this.icon;
span.classList.add(icon);
},
_setPrefixIcon:function(){
if (!this.prefixIcon) return;
var span=this.$['prefix-icon'];
var icon = 'icon-' + this.prefixIcon;
span.classList.add(icon);
span.classList.add('prefix');
span.setAttribute('style','');
},
_onChange: function (target, val) {
var id = this.dataId;
var name = this.dataName;
var data = {
value: val,
id: id,
name: name
};
this.fire('md-state-select-change', data);
},
_setDisabled: function () {
if (this.disabled) this.element.find('select').attr('disabled', true);
}
});
</script>