Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fading for dateheaders, solved fullDayEvent bug #1

Merged
merged 1 commit into from
Nov 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 20 additions & 27 deletions modules/default/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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";
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
},

Expand Down