From cc96b86b3a9dbd00c65ebe6b43570f082862c1b5 Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 21 Nov 2018 09:32:56 +0100 Subject: [PATCH 1/3] Fading for dateheaders Included fading for dateheaders option Removed unnecessary switch statement in dateheaders option --- modules/default/calendar/calendar.js | 47 ++++++++++++---------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 34ec254808..2897e64f28 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -144,6 +144,15 @@ Module.register("calendar", { 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 = ""; for (var e in events) { @@ -160,6 +169,10 @@ Module.register("calendar", { dateRow.appendChild(dateCell); wrapper.appendChild(dateRow); + if (e >= startFade) { //fading + currentFadeStep = e - startFade; + dateRow.style.opacity = 1 - (1 / fadeSteps * currentFadeStep); + } lastSeenDate = dateAsString; } @@ -242,22 +255,7 @@ Module.register("calendar", { timeWrapper.className = "time light " + timeClass; timeWrapper.align = "left"; timeWrapper.style.paddingLeft = "2px"; - var timeFormatString = ""; - 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); + timeWrapper.innerHTML = moment(event.startDate, "x").format('LT'); eventWrapper.appendChild(timeWrapper); titleWrapper.align = "right"; } @@ -275,6 +273,8 @@ Module.register("calendar", { var oneHour = oneMinute * 60; var oneDay = oneHour * 24; 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) { timeWrapper.innerHTML = this.capFirst(this.translate("TODAY")); } else if (event.startDate - now < oneDay && event.startDate - now > 0) { @@ -366,19 +366,12 @@ Module.register("calendar", { wrapper.appendChild(eventWrapper); // Create fade effect. - if (this.config.fade && this.config.fadePoint < 1) { - if (this.config.fadePoint < 0) { - this.config.fadePoint = 0; - } - 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); - } + if (e >= startFade) { + currentFadeStep = e - startFade; + eventWrapper.style.opacity = 1 - (1 / fadeSteps * currentFadeStep); } } - + return wrapper; }, From 07770601f63aedc2cdf17535c498c098dbd6e453 Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 21 Nov 2018 10:24:53 +0100 Subject: [PATCH 2/3] Update CHANGELOG.md - Fading for dateheaders timeFormat in Calendar [#1464](https://github.com/MichMich/MagicMirror/issues/1464) - Bug showing FullDayEvents one day too long in calendar fixe --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 302f1215df..aaf036aa6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,11 +19,13 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Screenshot for the current weather - Screenshot for the weather forecast module - Portuguese translation for "Feels" +- Fading for dateheaders timeFormat in Calendar [#1464](https://github.com/MichMich/MagicMirror/issues/1464) ### Fixed - Allow to parse recurring calendar events where the start date is before 1900 - Fixed Polish translation for Single Update Info - Ignore entries with unparseable details in the calendar module +- Bug showing FullDayEvents one day too long in calendar fixed ### Updated - The default calendar setting `showEnd` is changed to `false`. From af459a5a2868fe6dd4b854655dfbcf03813ff49f Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 21 Nov 2018 12:10:39 +0100 Subject: [PATCH 3/3] formatting corrected Corrected formatting due to Travis CI errors --- modules/default/calendar/calendar.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 2897e64f28..38b0426979 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -151,7 +151,7 @@ Module.register("calendar", { var startFade = events.length * this.config.fadePoint; var fadeSteps = events.length - startFade; } - + var currentFadeStep = 0; var lastSeenDate = ""; @@ -255,7 +255,7 @@ Module.register("calendar", { timeWrapper.className = "time light " + timeClass; timeWrapper.align = "left"; timeWrapper.style.paddingLeft = "2px"; - timeWrapper.innerHTML = moment(event.startDate, "x").format('LT'); + timeWrapper.innerHTML = moment(event.startDate, "x").format("LT"); eventWrapper.appendChild(timeWrapper); titleWrapper.align = "right"; } @@ -274,7 +274,7 @@ Module.register("calendar", { var oneDay = oneHour * 24; 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; + event.endDate -= oneSecond; if (event.today) { timeWrapper.innerHTML = this.capFirst(this.translate("TODAY")); } else if (event.startDate - now < oneDay && event.startDate - now > 0) { @@ -371,7 +371,7 @@ Module.register("calendar", { eventWrapper.style.opacity = 1 - (1 / fadeSteps * currentFadeStep); } } - + return wrapper; },