-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic-month-and-year.html
More file actions
97 lines (77 loc) · 1.97 KB
/
basic-month-and-year.html
File metadata and controls
97 lines (77 loc) · 1.97 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!--
Shows a culture's name for the current month and the year.
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-and-year
@demo http://basic-web-components.github.io/basic-web-components/src/basic-month-and-year/?dom=shadow
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../basic-shared/basic-shared.html">
<link rel="import" href="../basic-month-name/basic-month-name.html">
<dom-module id="basic-month-and-year">
<template>
<style>
:host(.rtl) {
direction: rtl;
}
</style>
<basic-month-name id="monthName"></basic-month-name>
<span id="year"></span>
</template>
</dom-module>
<script>
Polymer({
behaviors: [
Basic.CalendarHelpers,
Basic.Generic
],
is: 'basic-month-and-year',
properties: {
/**
* The Globalize culture/language assigned to this element.
*
* @attribute culture
*/
culture: {
value: null,
observer: '_cultureChanged'
},
/**
* The date controlling which month and year are shown in this element.
*
* @attribute date
* @type Date
* @default today
*/
date: {
type: Date,
value: null,
reflectToAttribute: true,
observer: '_dateChanged'
}
},
ready: function() {
if (!this.date) {
// By default show the current month and year.
this.date = new Date();
}
},
_cultureChanged: function() {
if (!this.date) {
return;
}
this.$.monthName.culture = this.culture;
// Ensure the month-year order matches the direction of the text.
var rtl = this.isRTL(culture);
this.classList.toggle('rtl', rtl);
},
_dateChanged: function() {
if (!this.date) {
return;
}
var date = this.date;
this.$.monthName.month = date.getMonth();
this.$.year.textContent = date.getFullYear();
}
});
</script>