|
|
@@ -10,6 +10,7 @@ var TimeGrid = Grid.extend({
|
|
|
maxTime: null, // Duration object that denotes the exclusive visible end time of any given day
|
|
|
colDates: null, // whole-day dates for each column. left to right
|
|
|
labelFormat: null, // formatting string for times running along vertical axis
|
|
|
+ labelInterval: null, // duration of how often a label should be displayed for a slot
|
|
|
|
|
|
dayEls: null, // cells elements in the day-row background
|
|
|
slatEls: null, // elements running horizontally across all columns
|
|
|
@@ -70,20 +71,19 @@ var TimeGrid = Grid.extend({
|
|
|
var view = this.view;
|
|
|
var isRTL = this.isRTL;
|
|
|
var html = '';
|
|
|
- var slotNormal = this.slotDuration.asMinutes() % 15 === 0;
|
|
|
var slotTime = moment.duration(+this.minTime); // wish there was .clone() for durations
|
|
|
var slotDate; // will be on the view's first day, but we only care about its time
|
|
|
- var minutes;
|
|
|
+ var isLabeled;
|
|
|
var axisHtml;
|
|
|
|
|
|
// Calculate the time for each slot
|
|
|
while (slotTime < this.maxTime) {
|
|
|
- slotDate = this.start.clone().time(slotTime); // will be in UTC but that's good. to avoid DST issues
|
|
|
- minutes = slotDate.minutes();
|
|
|
+ slotDate = this.start.clone().time(slotTime); // after .time() will be in UTC. but that's good, avoids DST issues
|
|
|
+ isLabeled = isInt(divideDurationByDuration(slotTime, this.labelInterval));
|
|
|
|
|
|
axisHtml =
|
|
|
'<td class="fc-axis fc-time ' + view.widgetContentClass + '" ' + view.axisStyleAttr() + '>' +
|
|
|
- ((!slotNormal || !minutes) ? // if irregular slot duration, or on the hour, then display the time
|
|
|
+ (isLabeled ?
|
|
|
'<span>' + // for matchCellWidths
|
|
|
htmlEscape(slotDate.format(this.labelFormat)) +
|
|
|
'</span>' :
|
|
|
@@ -92,7 +92,7 @@ var TimeGrid = Grid.extend({
|
|
|
'</td>';
|
|
|
|
|
|
html +=
|
|
|
- '<tr ' + (!minutes ? '' : 'class="fc-minor"') + '>' +
|
|
|
+ '<tr ' + (isLabeled ? '' : 'class="fc-minor"') + '>' +
|
|
|
(!isRTL ? axisHtml : '') +
|
|
|
'<td class="' + view.widgetContentClass + '"/>' +
|
|
|
(isRTL ? axisHtml : '') +
|
|
|
@@ -114,6 +114,7 @@ var TimeGrid = Grid.extend({
|
|
|
var view = this.view;
|
|
|
var slotDuration = view.opt('slotDuration');
|
|
|
var snapDuration = view.opt('snapDuration');
|
|
|
+ var input;
|
|
|
|
|
|
slotDuration = moment.duration(slotDuration);
|
|
|
snapDuration = snapDuration ? moment.duration(snapDuration) : slotDuration;
|
|
|
@@ -129,6 +130,30 @@ var TimeGrid = Grid.extend({
|
|
|
view.opt('slotLabelFormat') ||
|
|
|
view.opt('axisFormat') || // deprecated
|
|
|
view.opt('smallTimeFormat'); // the computed default
|
|
|
+
|
|
|
+ input = view.opt('slotLabelInterval');
|
|
|
+ this.labelInterval = input ?
|
|
|
+ moment.duration(input) :
|
|
|
+ this.computeLabelInterval(slotDuration);
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // Computes an automatic value for slotLabelInterval
|
|
|
+ computeLabelInterval: function(slotDuration) {
|
|
|
+ var i;
|
|
|
+ var labelInterval;
|
|
|
+ var slotsPerLabel;
|
|
|
+
|
|
|
+ // find the smallest stock label interval that results in more than one slots-per-label
|
|
|
+ for (i = AGENDA_STOCK_SUB_DURATIONS.length - 1; i >= 0; i--) {
|
|
|
+ labelInterval = moment.duration(AGENDA_STOCK_SUB_DURATIONS[i]);
|
|
|
+ slotsPerLabel = divideDurationByDuration(labelInterval, slotDuration);
|
|
|
+ if (isInt(slotsPerLabel) && slotsPerLabel > 1) {
|
|
|
+ return labelInterval;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return moment.duration(slotDuration); // fall back. clone
|
|
|
},
|
|
|
|
|
|
|