Unverified Commit c2c15c27 authored by Puranjay Jain's avatar Puranjay Jain Committed by GitHub
Browse files

Merge pull request #238 from ricioli/hotfix/change-year

Keep the month and day when you change the year and hide the controls…
parents 6bd6c4d9 62264b0e
......@@ -910,12 +910,16 @@ class mdDateTimePicker {
const subtitle = me._sDialog.subtitle
const currentYear = document.getElementById('mddtp-date__currentYear')
if (mdDateTimePicker.dialog.view) {
me._sDialog.right.style.display = 'none'
me._sDialog.left.style.display = 'none'
viewHolder.classList.add('zoomOut')
years.classList.remove('mddtp-picker__years--invisible')
years.classList.add('zoomIn')
// scroll into the view
currentYear.scrollIntoViewIfNeeded && currentYear.scrollIntoViewIfNeeded()
} else {
me._sDialog.right.style.display = 'initial'
me._sDialog.left.style.display = 'initial'
years.classList.add('zoomOut')
viewHolder.classList.remove('zoomOut')
viewHolder.classList.add('zoomIn')
......@@ -1146,6 +1150,10 @@ class mdDateTimePicker {
el.onclick = function (e) {
if (e.target && e.target.nodeName === 'LI') {
const selected = document.getElementById('mddtp-date__currentYear')
const subtitle = me._sDialog.subtitle
const titleDay = me._sDialog.titleDay
const titleMonth = me._sDialog.titleMonth
// clear previous selected
selected.id = ''
selected.classList.remove('mddtp-picker__li--current')
......@@ -1156,6 +1164,11 @@ class mdDateTimePicker {
me._switchToDateView(el, me)
// set the tdate to it
me._sDialog.tDate.year(parseInt(e.target.textContent, 10))
// update temp date object with the date selected
me._sDialog.sDate = me._sDialog.tDate.clone()
me._fillText(subtitle, me._sDialog.tDate.year())
me._fillText(titleDay, me._sDialog.tDate.format('ddd, '))
me._fillText(titleMonth, me._sDialog.tDate.format('MMM D'))
// update the dialog
me._initViewHolder()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment