// Copyright 2017 Kjell Winblad (kjellwinblad@gmail.com, http://winsh.me) // License: MIT License, see the LICENSE file var WTPLAN = WTPLAN || {}; (function() { //Constructor WTPLAN.DayListDay = function(state) { WTPLAN.Component.call(this); this.state = state; } //Extending Component WTPLAN.DayListDay.prototype = Object.create(WTPLAN.Component.prototype); WTPLAN.DayListDay.prototype.constructor = WTPLAN.DayListDay; //Methods WTPLAN.DayListDay.prototype.render = function() { var currentDay = this.state.currentDay; var nextDay = new Date(currentDay.getTime()); nextDay.setDate(currentDay.getDate() + 1); var itemsToday = this.state.calendarItems.filter(function(item) { var itemStartDate = item.startDate(); var itemEndDate = item.endDate(); return (itemStartDate.getTime() >= currentDay.getTime() && itemStartDate < nextDay.getTime()) || (itemEndDate.getTime() >= currentDay.getTime() && itemEndDate < nextDay.getTime()) || (itemStartDate.getTime() < currentDay.getTime() && itemEndDate >= nextDay.getTime()); }); this.tmpItemItemDivIdList = itemsToday.map(function(item, index) { return { 'item': item, itemId: "item" + index }; }); var itemDivs = this.tmpItemItemDivIdList.reduce(function(acc, curr) { return acc + '
'; }, ""); var dayHeader = WTPLAN.template( '