Merge pull request #1467 from lavolp3/calendar_issues

Fading for dateheaders, fixed bug for fulldayevents
This commit is contained in:
Michael Teeuw 2018-11-29 10:18:09 +01:00 committed by GitHub
commit b02702fe80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 26 deletions

View File

@ -19,11 +19,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Screenshot for the current weather - Screenshot for the current weather
- Screenshot for the weather forecast module - Screenshot for the weather forecast module
- Portuguese translation for "Feels" - Portuguese translation for "Feels"
- Fading for dateheaders timeFormat in Calendar [#1464](https://github.com/MichMich/MagicMirror/issues/1464)
### Fixed ### Fixed
- Allow to parse recurring calendar events where the start date is before 1900 - Allow to parse recurring calendar events where the start date is before 1900
- Fixed Polish translation for Single Update Info - Fixed Polish translation for Single Update Info
- Ignore entries with unparseable details in the calendar module - Ignore entries with unparseable details in the calendar module
- Bug showing FullDayEvents one day too long in calendar fixed
### Updated ### Updated
- The default calendar setting `showEnd` is changed to `false`. - The default calendar setting `showEnd` is changed to `false`.

View File

@ -144,6 +144,15 @@ Module.register("calendar", {
return wrapper; return wrapper;
} }
if (this.config.fade && this.config.fadePoint < 1) {
if (this.config.fadePoint < 0) {
this.config.fadePoint = 0;
}
var startFade = events.length * this.config.fadePoint;
var fadeSteps = events.length - startFade;
}
var currentFadeStep = 0;
var lastSeenDate = ""; var lastSeenDate = "";
for (var e in events) { for (var e in events) {
@ -160,6 +169,10 @@ Module.register("calendar", {
dateRow.appendChild(dateCell); dateRow.appendChild(dateCell);
wrapper.appendChild(dateRow); wrapper.appendChild(dateRow);
if (e >= startFade) { //fading
currentFadeStep = e - startFade;
dateRow.style.opacity = 1 - (1 / fadeSteps * currentFadeStep);
}
lastSeenDate = dateAsString; lastSeenDate = dateAsString;
} }
@ -242,22 +255,7 @@ Module.register("calendar", {
timeWrapper.className = "time light " + timeClass; timeWrapper.className = "time light " + timeClass;
timeWrapper.align = "left"; timeWrapper.align = "left";
timeWrapper.style.paddingLeft = "2px"; timeWrapper.style.paddingLeft = "2px";
var timeFormatString = ""; timeWrapper.innerHTML = moment(event.startDate, "x").format("LT");
switch (config.timeFormat) {
case 12: {
timeFormatString = "h:mm A";
break;
}
case 24: {
timeFormatString = "HH:mm";
break;
}
default: {
timeFormatString = "HH:mm";
break;
}
}
timeWrapper.innerHTML = moment(event.startDate, "x").format(timeFormatString);
eventWrapper.appendChild(timeWrapper); eventWrapper.appendChild(timeWrapper);
titleWrapper.align = "right"; titleWrapper.align = "right";
} }
@ -275,6 +273,8 @@ Module.register("calendar", {
var oneHour = oneMinute * 60; var oneHour = oneMinute * 60;
var oneDay = oneHour * 24; var oneDay = oneHour * 24;
if (event.fullDayEvent) { if (event.fullDayEvent) {
//subtract one second so that fullDayEvents end at 23:59:59, and not at 0:00:00 one the next day
event.endDate -= oneSecond;
if (event.today) { if (event.today) {
timeWrapper.innerHTML = this.capFirst(this.translate("TODAY")); timeWrapper.innerHTML = this.capFirst(this.translate("TODAY"));
} else if (event.startDate - now < oneDay && event.startDate - now > 0) { } else if (event.startDate - now < oneDay && event.startDate - now > 0) {
@ -366,16 +366,9 @@ Module.register("calendar", {
wrapper.appendChild(eventWrapper); wrapper.appendChild(eventWrapper);
// Create fade effect. // Create fade effect.
if (this.config.fade && this.config.fadePoint < 1) { if (e >= startFade) {
if (this.config.fadePoint < 0) { currentFadeStep = e - startFade;
this.config.fadePoint = 0; eventWrapper.style.opacity = 1 - (1 / fadeSteps * currentFadeStep);
}
var startingPoint = events.length * this.config.fadePoint;
var steps = events.length - startingPoint;
if (e >= startingPoint) {
var currentStep = e - startingPoint;
eventWrapper.style.opacity = 1 - (1 / steps * currentStep);
}
} }
} }