From ea612aeb8ee00f79b7293de54b3b377dcb815a4a Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 20 Apr 2016 15:40:09 +0000 Subject: [PATCH] Use event sorting from daycol to keep event order within a row more consistent --- calendar/js/et2_widget_planner_row.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/calendar/js/et2_widget_planner_row.js b/calendar/js/et2_widget_planner_row.js index 2e149650ea..ff10e0444d 100644 --- a/calendar/js/et2_widget_planner_row.js +++ b/calendar/js/et2_widget_planner_row.js @@ -309,6 +309,20 @@ var et2_calendar_planner_row = (function(){ "use strict"; return et2_valueWidget this._children.sort(function(a,b) { 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); + // 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; });