* Calendar - fix events on weekend were sometimes shown on Friday if weekends were hidden

This commit is contained in:
nathangray 2018-03-19 10:54:55 -06:00
parent 810a90af56
commit b118f9109c

View File

@ -634,6 +634,15 @@ var et2_calendar_planner_row = (function(){ "use strict"; return et2_valueWidget
}
}
// Skip events entirely on hidden weekends
if(this._hidden_weekend_event(event))
{
var node = this._children[n];
this.removeChild(n--);
node.free();
continue;
}
var event_start = new Date(event.start).valueOf();
for(var row = 0; row_end[row] > event_start; ++row); // find a "free" row (no other event)
if(typeof rows[row] === 'undefined') rows[row] = [];
@ -644,6 +653,26 @@ var et2_calendar_planner_row = (function(){ "use strict"; return et2_valueWidget
return rows;
},
/**
* Check to see if the event is entirely on a hidden weekend
*
* @param values Array of event values, not an et2_widget_event
*/
_hidden_weekend_event: function(values)
{
if(!this._parent || this._parent.options.group_by == 'month' || this._parent.options.show_weekend)
{
return false;
}
// Starts on Saturday or Sunday, ends Sat or Sun, less than 2 days long
else if([0,6].indexOf(values.start.getUTCDay()) !== -1 && [0,6].indexOf(values.end.getUTCDay()) !== -1
&& values.end - values.start < 2 * 24 * 3600 * 1000)
{
return true;
}
return false;
},
/**
* Calculates the horizontal position based on the time given, as a percentage
* between the start and end times