Просмотр исходного кода

intervalUnit -> currentRangeUnit

Adam Shaw 9 лет назад
Родитель
Сommit
1e28a67239
3 измененных файлов с 11 добавлено и 10 удалено
  1. 2 2
      src/basic/BasicView.js
  2. 8 7
      src/common/View.js
  3. 1 1
      src/util.js

+ 2 - 2
src/basic/BasicView.js

@@ -46,7 +46,7 @@ var BasicView = FC.BasicView = View.extend({
 		var renderRange = View.prototype.computeRenderRange.call(this, currentRange);
 
 		// year and month views should be aligned with weeks. this is already done for week
-		if (/^(year|month)$/.test(this.intervalUnit)) {
+		if (/^(year|month)$/.test(this.currentRangeUnit)) {
 			renderRange.start.startOf('week');
 
 			// make end-of-week if not already
@@ -62,7 +62,7 @@ var BasicView = FC.BasicView = View.extend({
 	// Renders the view into `this.el`, which should already be assigned
 	renderDates: function() {
 
-		this.dayGrid.breakOnWeeks = /year|month|week/.test(this.intervalUnit); // do before Grid::setRange
+		this.dayGrid.breakOnWeeks = /year|month|week/.test(this.currentRangeUnit); // do before Grid::setRange
 		this.dayGrid.setRange(this.renderRange);
 
 		this.dayNumbersVisible = this.dayGrid.rowCnt > 1; // TODO: make grid responsible

+ 8 - 7
src/common/View.js

@@ -26,7 +26,8 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
 	// range the view is formally responsible for (moments)
 	// may be different from start/end. for example, a month view might have 1st-31st, excluding padded dates
 	currentRange: null,
-	intervalUnit: null, // name of largest unit being displayed, like "month" or "week"
+	currentRangeUnit: null, // name of largest unit being displayed, like "month" or "week"
+
 	dateIncrement: null,
 
 	// date range with a rendered skeleton
@@ -155,7 +156,7 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
 			// some sort of change
 
 			this.currentRange = ranges.currentRange;
-			this.intervalUnit = ranges.currentRangeUnit; // TODO: rename intervalUnit
+			this.currentRangeUnit = ranges.currentRangeUnit;
 			this.renderRange = ranges.renderRange;
 			this.visibleRange = ranges.visibleRange;
 			this.dateIncrement = ranges.dateIncrement;
@@ -278,7 +279,7 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
 	// Computes the new date when the user hits the prev button, given the current date
 	computePrevDate: function(date) {
 		return this.massageCurrentDate(
-			date.clone().startOf(this.intervalUnit).subtract(this.dateIncrement), -1
+			date.clone().startOf(this.currentRangeUnit).subtract(this.dateIncrement), -1
 		);
 	},
 
@@ -286,7 +287,7 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
 	// Computes the new date when the user hits the next button, given the current date
 	computeNextDate: function(date) {
 		return this.massageCurrentDate(
-			date.clone().startOf(this.intervalUnit).add(this.dateIncrement)
+			date.clone().startOf(this.currentRangeUnit).add(this.dateIncrement)
 		);
 	},
 
@@ -336,7 +337,7 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
 		var range;
 
 		// for views that span a large unit of time, show the proper interval, ignoring stray days before and after
-		if (/^(year|month)$/.test(this.intervalUnit)) {
+		if (/^(year|month)$/.test(this.currentRangeUnit)) {
 			range = this.currentRange;
 		}
 		else { // for day units or smaller, use the actual day range
@@ -358,10 +359,10 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
 	// Generates the format string that should be used to generate the title for the current date range.
 	// Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
 	computeTitleFormat: function() {
-		if (this.intervalUnit == 'year') {
+		if (this.currentRangeUnit == 'year') {
 			return 'YYYY';
 		}
-		else if (this.intervalUnit == 'month') {
+		else if (this.currentRangeUnit == 'month') {
 			return this.opt('monthYearFormat'); // like "September 2014"
 		}
 		else if (this.currentRangeAs('days') > 1) {

+ 1 - 1
src/util.js

@@ -545,7 +545,7 @@ function intersectRanges(subjectRange, constraintRange) {
 /* Date Utilities
 ----------------------------------------------------------------------------------------------------------------------*/
 
-FC.computeIntervalUnit = computeIntervalUnit;
+FC.computeIntervalUnit = computeIntervalUnit; // TODO: rename to greatestUnit or something
 FC.divideRangeByDuration = divideRangeByDuration;
 FC.divideDurationByDuration = divideDurationByDuration;
 FC.multiplyDuration = multiplyDuration;