Adam Shaw 9 年 前
コミット
50bb125329
5 ファイル変更22 行追加17 行削除
  1. 8 4
      src/Calendar.js
  2. 2 2
      src/basic/BasicView.js
  3. 2 1
      src/common/Grid.events.js
  4. 2 2
      src/common/View.date-range.js
  5. 8 8
      src/util.js

+ 8 - 4
src/Calendar.js

@@ -150,6 +150,8 @@ var Calendar = FC.Calendar = Class.extend({
 			if (duration.valueOf()) { // valid?
 			if (duration.valueOf()) { // valid?
 
 
 				unit = computeGreatestUnit(duration);
 				unit = computeGreatestUnit(duration);
+
+				// prevent days:7 from being interpreted as a week
 				if (unit === 'week' && typeof durationInput === 'object' && durationInput.days) {
 				if (unit === 'week' && typeof durationInput === 'object' && durationInput.days) {
 					unit = 'day';
 					unit = 'day';
 				}
 				}
@@ -293,12 +295,12 @@ var Calendar = FC.Calendar = Class.extend({
 
 
 		if (dateOrRange) {
 		if (dateOrRange) {
 
 
-			if (dateOrRange.start && dateOrRange.end) {
+			if (dateOrRange.start && dateOrRange.end) { // a range
 				this.recordOptionOverrides({ // will not rerender
 				this.recordOptionOverrides({ // will not rerender
 					visibleRange: dateOrRange
 					visibleRange: dateOrRange
 				});
 				});
 			}
 			}
-			else {
+			else { // a date
 				this.currentDate = this.moment(dateOrRange).stripZone(); // just like gotoDate
 				this.currentDate = this.moment(dateOrRange).stripZone(); // just like gotoDate
 			}
 			}
 		}
 		}
@@ -363,16 +365,17 @@ var Calendar = FC.Calendar = Class.extend({
 	},
 	},
 
 
 
 
+	// will return `null` if invalid range
 	parseRange: function(rangeInput) {
 	parseRange: function(rangeInput) {
 		var start = null;
 		var start = null;
 		var end = null;
 		var end = null;
 
 
 		if (rangeInput.start) {
 		if (rangeInput.start) {
-			start = this.moment(rangeInput.start);
+			start = this.moment(rangeInput.start).stripZone();
 		}
 		}
 
 
 		if (rangeInput.end) {
 		if (rangeInput.end) {
-			end = this.moment(rangeInput.end);
+			end = this.moment(rangeInput.end).stripZone();
 		}
 		}
 
 
 		if (!start && !end) {
 		if (!start && !end) {
@@ -1146,6 +1149,7 @@ function Calendar_constructor(element, overrides) {
 	}
 	}
 
 
 
 
+	// stores the new options internally, but does not rerender anything.
 	function recordOptionOverrides(newOptionHash) {
 	function recordOptionOverrides(newOptionHash) {
 		var optionName;
 		var optionName;
 
 

+ 2 - 2
src/basic/BasicView.js

@@ -42,11 +42,11 @@ var BasicView = FC.BasicView = View.extend({
 
 
 
 
 	// Computes the date range that will be rendered.
 	// Computes the date range that will be rendered.
-	buildRenderRange: function(currentRange, unit) {
+	buildRenderRange: function(currentRange, currentRangeUnit) {
 		var renderRange = View.prototype.buildRenderRange.apply(this, arguments);
 		var renderRange = View.prototype.buildRenderRange.apply(this, arguments);
 
 
 		// year and month views should be aligned with weeks. this is already done for week
 		// year and month views should be aligned with weeks. this is already done for week
-		if (/^(year|month)$/.test(unit)) {
+		if (/^(year|month)$/.test(currentRangeUnit)) {
 			renderRange.start.startOf('week');
 			renderRange.start.startOf('week');
 
 
 			// make end-of-week if not already
 			// make end-of-week if not already

+ 2 - 1
src/common/Grid.events.js

@@ -1158,7 +1158,8 @@ Grid.mixin({
 	},
 	},
 
 
 
 
-	// always returns a result
+	// Ensures the given range is within the view's activeRange and is correctly localized.
+	// Always returns a result
 	refineRawEventRange: function(rawRange) {
 	refineRawEventRange: function(rawRange) {
 		var view = this.view;
 		var view = this.view;
 		var calendar = view.calendar;
 		var calendar = view.calendar;

+ 2 - 2
src/common/View.date-range.js

@@ -1,5 +1,5 @@
 
 
-View.mixin({å
+View.mixin({
 
 
 	// range the view is formally responsible for.
 	// range the view is formally responsible for.
 	// for example, a month view might have 1st-31st, excluding padded dates
 	// for example, a month view might have 1st-31st, excluding padded dates
@@ -243,7 +243,7 @@ View.mixin({å
 
 
 	// Computes the range that will represent the element/cells for *rendering*,
 	// Computes the range that will represent the element/cells for *rendering*,
 	// but which may have voided days/times.
 	// but which may have voided days/times.
-	buildRenderRange: function(currentRange) {
+	buildRenderRange: function(currentRange, currentRangeUnit) {
 		// cut off days in the currentRange that are hidden
 		// cut off days in the currentRange that are hidden
 		return this.trimHiddenDays(currentRange);
 		return this.trimHiddenDays(currentRange);
 	},
 	},

+ 8 - 8
src/util.js

@@ -677,6 +677,8 @@ function cloneRange(range) {
 }
 }
 
 
 
 
+// Trims the beginning and end of inner range to be completely within outerRange.
+// Returns a new range object.
 function constrainRange(innerRange, outerRange) {
 function constrainRange(innerRange, outerRange) {
 	innerRange = cloneRange(innerRange);
 	innerRange = cloneRange(innerRange);
 
 
@@ -693,6 +695,8 @@ function constrainRange(innerRange, outerRange) {
 }
 }
 
 
 
 
+// If the given date is not within the given range, move it inside.
+// Always returns a new moment.
 function constrainDate(date, range) {
 function constrainDate(date, range) {
 	date = date.clone();
 	date = date.clone();
 
 
@@ -726,19 +730,15 @@ function isRangesEqual(range0, range1) {
 }
 }
 
 
 
 
+// Returns the moment that's earlier in time. Always a copy.
 function minMoment(mom1, mom2) {
 function minMoment(mom1, mom2) {
-	if (mom1.isBefore(mom2)) {
-		return mom1;
-	}
-	return mom2;
+	return (mom1.isBefore(mom2) ? mom1 : mom2).clone();
 }
 }
 
 
 
 
+// Returns the moment that's later in time. Always a copy.
 function maxMoment(mom1, mom2) {
 function maxMoment(mom1, mom2) {
-	if (mom1.isAfter(mom2)) {
-		return mom1;
-	}
-	return mom2;
+	return (mom1.isAfter(mom2) ? mom1 : mom2).clone();
 }
 }