|
|
@@ -45,7 +45,7 @@ TimeGrid.mixin({
|
|
|
|
|
|
for (col = 0; col < segCols.length; col++) { // iterate each column grouping
|
|
|
colSegs = segCols[col];
|
|
|
- placeSlotSegs(colSegs); // compute horizontal coordinates, z-index's, and reorder the array
|
|
|
+ this.placeSlotSegs(colSegs); // compute horizontal coordinates, z-index's, and reorder the array
|
|
|
|
|
|
containerEl = $('<div class="fc-event-container"/>');
|
|
|
|
|
|
@@ -71,6 +71,74 @@ TimeGrid.mixin({
|
|
|
},
|
|
|
|
|
|
|
|
|
+ // Given an array of segments that are all in the same column, sets the backwardCoord and forwardCoord on each.
|
|
|
+ // NOTE: Also reorders the given array by date!
|
|
|
+ placeSlotSegs: function(segs) {
|
|
|
+ var levels;
|
|
|
+ var level0;
|
|
|
+ var i;
|
|
|
+
|
|
|
+ this.sortSegs(segs); // order by date
|
|
|
+ levels = buildSlotSegLevels(segs);
|
|
|
+ computeForwardSlotSegs(levels);
|
|
|
+
|
|
|
+ if ((level0 = levels[0])) {
|
|
|
+
|
|
|
+ for (i = 0; i < level0.length; i++) {
|
|
|
+ computeSlotSegPressures(level0[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (i = 0; i < level0.length; i++) {
|
|
|
+ this.computeSlotSegCoords(level0[i], 0, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
|
|
|
+ // from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
|
|
|
+ // seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
|
|
|
+ //
|
|
|
+ // The segment might be part of a "series", which means consecutive segments with the same pressure
|
|
|
+ // who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
|
|
|
+ // segments behind this one in the current series, and `seriesBackwardCoord` is the starting
|
|
|
+ // coordinate of the first segment in the series.
|
|
|
+ computeSlotSegCoords: function(seg, seriesBackwardPressure, seriesBackwardCoord) {
|
|
|
+ var forwardSegs = seg.forwardSegs;
|
|
|
+ var i;
|
|
|
+
|
|
|
+ if (seg.forwardCoord === undefined) { // not already computed
|
|
|
+
|
|
|
+ if (!forwardSegs.length) {
|
|
|
+
|
|
|
+ // if there are no forward segments, this segment should butt up against the edge
|
|
|
+ seg.forwardCoord = 1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ // sort highest pressure first
|
|
|
+ this.sortForwardSlotSegs(forwardSegs);
|
|
|
+
|
|
|
+ // this segment's forwardCoord will be calculated from the backwardCoord of the
|
|
|
+ // highest-pressure forward segment.
|
|
|
+ this.computeSlotSegCoords(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord);
|
|
|
+ seg.forwardCoord = forwardSegs[0].backwardCoord;
|
|
|
+ }
|
|
|
+
|
|
|
+ // calculate the backwardCoord from the forwardCoord. consider the series
|
|
|
+ seg.backwardCoord = seg.forwardCoord -
|
|
|
+ (seg.forwardCoord - seriesBackwardCoord) / // available width for series
|
|
|
+ (seriesBackwardPressure + 1); // # of segments in the series
|
|
|
+
|
|
|
+ // use this segment's coordinates to computed the coordinates of the less-pressurized
|
|
|
+ // forward segments
|
|
|
+ for (i=0; i<forwardSegs.length; i++) {
|
|
|
+ this.computeSlotSegCoords(forwardSegs[i], 0, seg.forwardCoord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
// Refreshes the CSS top/bottom coordinates for each segment element. Probably after a window resize/zoom.
|
|
|
// Repositions business hours segs too, so not just for events. Maybe shouldn't be here.
|
|
|
updateSegVerticals: function() {
|
|
|
@@ -232,33 +300,25 @@ TimeGrid.mixin({
|
|
|
}
|
|
|
|
|
|
return segCols;
|
|
|
- }
|
|
|
-
|
|
|
-});
|
|
|
-
|
|
|
-
|
|
|
-// Given an array of segments that are all in the same column, sets the backwardCoord and forwardCoord on each.
|
|
|
-// NOTE: Also reorders the given array by date!
|
|
|
-function placeSlotSegs(segs) {
|
|
|
- var levels;
|
|
|
- var level0;
|
|
|
- var i;
|
|
|
+ },
|
|
|
|
|
|
- segs.sort(compareSegs); // order by date
|
|
|
- levels = buildSlotSegLevels(segs);
|
|
|
- computeForwardSlotSegs(levels);
|
|
|
|
|
|
- if ((level0 = levels[0])) {
|
|
|
+ sortForwardSlotSegs: function(forwardSegs) {
|
|
|
+ forwardSegs.sort(proxy(this, 'compareForwardSlotSegs'));
|
|
|
+ },
|
|
|
|
|
|
- for (i = 0; i < level0.length; i++) {
|
|
|
- computeSlotSegPressures(level0[i]);
|
|
|
- }
|
|
|
|
|
|
- for (i = 0; i < level0.length; i++) {
|
|
|
- computeSlotSegCoords(level0[i], 0, 0);
|
|
|
- }
|
|
|
+ // A cmp function for determining which forward segment to rely on more when computing coordinates.
|
|
|
+ compareForwardSlotSegs: function(seg1, seg2) {
|
|
|
+ // put higher-pressure first
|
|
|
+ return seg2.forwardPressure - seg1.forwardPressure ||
|
|
|
+ // put segments that are closer to initial edge first (and favor ones with no coords yet)
|
|
|
+ (seg1.backwardCoord || 0) - (seg2.backwardCoord || 0) ||
|
|
|
+ // do normal sorting...
|
|
|
+ this.compareSegs(seg1, seg2);
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+});
|
|
|
|
|
|
|
|
|
// Builds an array of segments "levels". The first level will be the leftmost tier of segments if the calendar is
|
|
|
@@ -337,50 +397,6 @@ function computeSlotSegPressures(seg) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
|
|
|
-// from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
|
|
|
-// seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
|
|
|
-//
|
|
|
-// The segment might be part of a "series", which means consecutive segments with the same pressure
|
|
|
-// who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
|
|
|
-// segments behind this one in the current series, and `seriesBackwardCoord` is the starting
|
|
|
-// coordinate of the first segment in the series.
|
|
|
-function computeSlotSegCoords(seg, seriesBackwardPressure, seriesBackwardCoord) {
|
|
|
- var forwardSegs = seg.forwardSegs;
|
|
|
- var i;
|
|
|
-
|
|
|
- if (seg.forwardCoord === undefined) { // not already computed
|
|
|
-
|
|
|
- if (!forwardSegs.length) {
|
|
|
-
|
|
|
- // if there are no forward segments, this segment should butt up against the edge
|
|
|
- seg.forwardCoord = 1;
|
|
|
- }
|
|
|
- else {
|
|
|
-
|
|
|
- // sort highest pressure first
|
|
|
- forwardSegs.sort(compareForwardSlotSegs);
|
|
|
-
|
|
|
- // this segment's forwardCoord will be calculated from the backwardCoord of the
|
|
|
- // highest-pressure forward segment.
|
|
|
- computeSlotSegCoords(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord);
|
|
|
- seg.forwardCoord = forwardSegs[0].backwardCoord;
|
|
|
- }
|
|
|
-
|
|
|
- // calculate the backwardCoord from the forwardCoord. consider the series
|
|
|
- seg.backwardCoord = seg.forwardCoord -
|
|
|
- (seg.forwardCoord - seriesBackwardCoord) / // available width for series
|
|
|
- (seriesBackwardPressure + 1); // # of segments in the series
|
|
|
-
|
|
|
- // use this segment's coordinates to computed the coordinates of the less-pressurized
|
|
|
- // forward segments
|
|
|
- for (i=0; i<forwardSegs.length; i++) {
|
|
|
- computeSlotSegCoords(forwardSegs[i], 0, seg.forwardCoord);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
// Find all the segments in `otherSegs` that vertically collide with `seg`.
|
|
|
// Append into an optionally-supplied `results` array and return.
|
|
|
function computeSlotSegCollisions(seg, otherSegs, results) {
|
|
|
@@ -400,14 +416,3 @@ function computeSlotSegCollisions(seg, otherSegs, results) {
|
|
|
function isSlotSegCollision(seg1, seg2) {
|
|
|
return seg1.bottom > seg2.top && seg1.top < seg2.bottom;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-// A cmp function for determining which forward segment to rely on more when computing coordinates.
|
|
|
-function compareForwardSlotSegs(seg1, seg2) {
|
|
|
- // put higher-pressure first
|
|
|
- return seg2.forwardPressure - seg1.forwardPressure ||
|
|
|
- // put segments that are closer to initial edge first (and favor ones with no coords yet)
|
|
|
- (seg1.backwardCoord || 0) - (seg2.backwardCoord || 0) ||
|
|
|
- // do normal sorting...
|
|
|
- compareSegs(seg1, seg2);
|
|
|
-}
|