1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Calculate event offsets in js

Summary: Ref T8300, Calculate event offsets in js

Test Plan: no user facing changes

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T8300

Differential Revision: https://secure.phabricator.com/D12981
This commit is contained in:
lkassianik 2015-05-22 15:30:17 -07:00
parent 04584131f7
commit e032bab9ef
2 changed files with 29 additions and 1 deletions

View file

@ -89,6 +89,7 @@ final class PHUICalendarDayView extends AphrontView {
'eventStartEpoch' => $event->getEpochStart(),
'eventEndEpoch' => $event->getEpochEnd(),
'eventName' => $event->getName(),
'eventID' => $event->getEventID(),
);
}
}
@ -109,10 +110,11 @@ final class PHUICalendarDayView extends AphrontView {
$first_event_hour = $hour;
}
$js_hourly_events[$event->getEventID()] = array(
$js_hourly_events[] = array(
'eventStartEpoch' => $event->getEpochStart(),
'eventEndEpoch' => $event->getEpochEnd(),
'eventName' => $event->getName(),
'eventID' => $event->getEventID(),
'hour' => $hour,
'offset' => '0',
'width' => '100%',

View file

@ -55,5 +55,31 @@ JX.behavior('day-view', function(config) {
return clusters;
}
function updateEventsFromCluster(cluster, hourly_events) {
var cluster_size = cluster.length;
var n = 0;
for(var i=0; i < cluster.length; i++) {
var cluster_member = cluster[i];
var event_id = cluster_member.eventID;
var offset = ((n / cluster_size) * 100) + '%';
var width = ((1 / cluster_size) * 100) + '%';
for (var j=0; j < hourly_events.length; j++) {
if (hourly_events[j].eventID == event_id) {
hourly_events[j]['offset'] = offset;
hourly_events[j]['width'] = width;
}
}
n++;
}
return hourly_events;
}
var today_clusters = findTodayClusters();
for(var i=0; i < today_clusters.length; i++) {
hourly_events = updateEventsFromCluster(today_clusters[i], hourly_events);
}
});