-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic-month-name.html
More file actions
83 lines (66 loc) · 1.7 KB
/
basic-month-name.html
File metadata and controls
83 lines (66 loc) · 1.7 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
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
<!--
Shows a culture's name for a given month.
To the degree possible, all language/culture-specific aspects of this component
are localizable with the Globalize library (https://github.com/jquery/globalize).
@element basic-month-name
@demo http://basic-web-components.github.io/basic-web-components/src/basic-month-name/?dom=shadow
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../basic-shared/basic-shared.html">
<dom-module id="basic-month-name">
<style>
:host {
display: inline-block;
}
</style>
<template>
<span id="name"></span>
</template>
</dom-module>
<script>
Polymer({
behaviors: [Basic.CalendarHelpers],
is: 'basic-month-name',
properties: {
/**
* The Globalize culture/language assigned to this element.
*
* @attribute culture
*/
culture: {
value: null,
observer: '_cultureChanged'
},
/**
* The index of the month to show: 0 = January, 1 = February, etc.
*
* @attribute month
* @type integer
* @default The index of the current month
*/
month: {
value: null,
type: Number,
reflectToAttribute: true,
observer: '_monthChanged'
}
},
ready: function() {
if (!this.month) {
// If no month is supplied, default to the current month.
this.month = (new Date()).getMonth();
}
},
_cultureChanged: function() {
// Force update of month name.
this._monthChanged();
},
_monthChanged: function() {
culture = this.culture;
monthNameEnum = this.monthsOfYear(culture);
monthName = monthNameEnum['wide'][this.month + 1];
this.$.name.textContent = monthName;
}
});
</script>
</polymer-element>