Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #25082 from evanxd/bug-1075455-v2.1
Browse files Browse the repository at this point in the history
Bug 1075455 - Sync present date on month view. r=evanxd
  • Loading branch information
BavarianTomcat committed Oct 14, 2014
2 parents 7e2e65a + 712df63 commit c1fef90
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
13 changes: 13 additions & 0 deletions apps/calendar/js/app.js
Expand Up @@ -448,6 +448,18 @@ Calendar.App = (function(window) {
}.bind(this), 0);
},

_setPresentDate: function() {
var id = Calendar.Calc.getDayId(new Date());
var presentDate = document.querySelector(
'#month-view [data-date="' + id + '"]'
);
var previousDate = document.querySelector('#month-view .present');

previousDate.classList.remove('present');
previousDate.classList.add('past');
presentDate.classList.add('present');
},

_showTodayDate: function() {
document.querySelector('#today .icon-calendar-today').innerHTML =
new Date().getDate();
Expand All @@ -462,6 +474,7 @@ Calendar.App = (function(window) {
var timeout = midnight.getTime() - now.getTime();

setTimeout(function() {
this._setPresentDate();
this._showTodayDate();
this._syncTodayDate();
}.bind(this), timeout);
Expand Down
22 changes: 20 additions & 2 deletions apps/calendar/test/unit/app_test.js
Expand Up @@ -454,8 +454,17 @@ suite('app', function() {
clock = sinon.useFakeTimers(baseTimestamp);

container = document.createElement('div');
container.innerHTML = '<a id="today" href="#today">' +
'<span class="icon-calendar-today">7</span></a>';
container.innerHTML = [
'<section id="month-view">',
'<ol>',
'<li class="present" data-date="d-1991-9-7">7</li>',
'<li class="future" data-date="d-1991-9-8">8</li>',
'</ol>',
'</section>',
'<a id="today" href="#today">',
'<span class="icon-calendar-today">7</span>',
'</a>'
].join('');
document.body.appendChild(container);
});

Expand All @@ -472,5 +481,14 @@ suite('app', function() {
8
);
});

test('Set present date in month view after midnight', function() {
subject._syncTodayDate();
clock.tick(1500);
assert.equal(
document.querySelector('#month-view .present').innerHTML,
8
);
});
});
});

0 comments on commit c1fef90

Please sign in to comment.