-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinterface-language-select.html
More file actions
57 lines (52 loc) · 1.31 KB
/
finterface-language-select.html
File metadata and controls
57 lines (52 loc) · 1.31 KB
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
<link rel="import" href="../polymer/polymer.html">
<script>
window.FInterface = window.FInterface || {};
/**
* `FInterface.LanguageSelect` exposes properties for any language select element.
*
* @polymerBehavior
*/
FInterface.LanguageSelect = Polymer.dedupingMixin(function(superClass) {
return class LanguageSelect extends superClass {
static get properties() {
return {
/**
* Language options to choose from. Each item has the following format:
* ```json
* {
* flag: String(ISO 3166-1 alpha-2),
* lang: String(ISO 639-1)
* }```
*
* @default [ us:en, es:es lt:lt ]
*/
options: {
type: Array,
notify: true,
value: function() {
return [
{ flag: 'us', lang: 'en' },
{ flag: 'es', lang: 'es' },
{ flag: 'lt', lang: 'lt' }
];
}
},
/*
* Selected option's `lang` property value.
*/
selected: {
type: String,
notify: true
}
};
}
flagFromLang(lang) {
if (!lang || !this.options) return;
const opt = this.options.find(function(o) {
return o.lang === lang;
});
if (opt) return opt.flag;
}
}
});
</script>