-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect.html
80 lines (70 loc) · 1.94 KB
/
select.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
<dom-module id="ui-select">
<template>
<content></content>
</template>
</dom-module>
<script>
Polymer({
is:'ui-select',
behaviors:[Elliptical.ComponentBehavior],
properties:{
dataId:{
type:String,
value:null
},
dataName:{
type:String,
value:null
},
dataValue:{
type:String,
value:null
}
},
ready:function(){
this._setValueProp();
this._setId();
this._setName();
this._setValue();
this._setListener();
},
_setValueProp:function(){
var element=this.element;
var node=this;
Object.defineProperty(node, 'value', {
get: function() { return element.find('select').val(); },
set: function(newValue) { element.find('select').val(newValue); },
enumerable: true,
configurable: true
});
},
_setId:function(){
if(this.dataId){
var select=this.element.find('select');
select.attr('id',this.dataId);
}
},
_setName:function(){
if(this.dataName){
var select=this.element.find('select');
select.attr('name',this.dataName);
}
},
_setValue:function(){
if(this.dataValue){
this.value=this.dataValue;
}
},
_setListener:function(){
this._event(this.element,'change','select',this._onChange.bind(this));
},
_onChange:function(){
var data={
value:this.value,
id:this.dataId,
name:this.dataName
};
this.fire('ui-select-change',data);
}
});
</script>