Use event sorting from daycol to keep event order within a row more consistent

This commit is contained in:
Nathan Gray 2016-04-20 15:40:09 +00:00
parent 02c7014a0a
commit ea612aeb8e

View File

@ -309,6 +309,20 @@ var et2_calendar_planner_row = (function(){ "use strict"; return et2_valueWidget
this._children.sort(function(a,b) { this._children.sort(function(a,b) {
var start = new Date(a.options.value.start) - new Date(b.options.value.start); var start = new Date(a.options.value.start) - new Date(b.options.value.start);
var end = new Date(a.options.value.end) - new Date(b.options.value.end); var end = new Date(a.options.value.end) - new Date(b.options.value.end);
// Whole day events sorted by ID, normal events by start / end time
if(a.options.value.whole_day && b.options.value.whole_day)
{
// Longer duration comes first so we have nicer bars across the top
var duration =
(new Date(b.options.value.end) - new Date(b.options.value.start)) -
(new Date(a.options.value.end) - new Date(a.options.value.start));
return duration ? duration : (a.options.value.app_id - b.options.value.app_id);
}
else if (a.options.value.whole_day || b.options.value.whole_day)
{
return a.options.value.whole_day ? -1 : 1;
}
return start ? start : end; return start ? start : end;
}); });