forked from bradparks/io-bundle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathio-value-config.html
82 lines (75 loc) · 1.82 KB
/
io-value-config.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
<link rel="import" href="../polymer/polymer.html">
<script type="text/javascript">
(function() {
var i;
/*
Global io-value configutation.
Polymer.ioValueConfig is a list of conditions and configurations
used by io-value to determine which editor to use depending on
a specified value, key and parent object.
You can add your own configutations here.
Make sure you put you custom configurations at the beggining of the list.
@polymerBehavior Polymer.ioValueConfig
*/
Polymer.ioValueConfig = [
function (value, key, parent) {
if (value === undefined ||
value === null ||
typeof value === 'function' ||
(typeof value === 'number' && isNaN(value))) {
return {
editor: 'io-input',
properties: {
type: 'any'
}
}
}
},
function (value, key, parent) {
if (typeof value === 'string') {
return {
editor: 'io-input',
properties: {
type: 'string'
}
}
}
},
function (value, key, parent) {
if (typeof value === 'number') {
return {
editor: 'io-input',
properties: {
type: 'float'
}
}
}
},
function (value, key, parent) {
if (typeof value === 'boolean') {
return {
editor: 'io-boolean',
properties: {
icon: true
}
}
}
},
function (value, key, parent) {
if (typeof value === 'object') {
return {
editor: 'io-object'
}
}
}
];
Polymer.ioValueConfig.getConfig = function (value, key, parent) {
for (i = 0; i < this.length; i++) {
config = this[i](value, key, parent);
if (config) {
return config;
}
}
}
}());
</script>