Browse Source

rename to isDateWithinContentRange / isRangeWithinContentRange

Adam Shaw 9 năm trước cách đây
mục cha
commit
5bb0752e14
4 tập tin đã thay đổi với 14 bổ sung14 xóa
  1. 7 6
      src/common/DayGrid.js
  2. 2 2
      src/common/Grid.events.js
  3. 1 1
      src/common/Grid.js
  4. 4 5
      src/common/View.js

+ 7 - 6
src/common/DayGrid.js

@@ -139,12 +139,13 @@ var DayGrid = FC.DayGrid = Grid.extend(DayTableMixin, {
 	// Generates the HTML for the <td>s of the "number" row in the DayGrid's content skeleton.
 	// The number row will only exist if either day numbers or week numbers are turned on.
 	renderNumberCellHtml: function(date) {
+		var view = this.view;
 		var html = '';
-		var isDayNumberVisible = this.view.dayNumbersVisible && !this.view.isDisabledDate(date);
+		var isDayNumberVisible = view.dayNumbersVisible && view.isDateWithinContentRange(date);
 		var classes;
 		var weekCalcFirstDoW;
 
-		if (!isDayNumberVisible && !this.view.cellWeekNumbersVisible) {
+		if (!isDayNumberVisible && !view.cellWeekNumbersVisible) {
 			// no numbers in day cell (week number must be along the side)
 			return '<td/>'; //  will create an empty space above events :(
 		}
@@ -152,7 +153,7 @@ var DayGrid = FC.DayGrid = Grid.extend(DayTableMixin, {
 		classes = this.getDayClasses(date);
 		classes.unshift('fc-day-top');
 
-		if (this.view.cellWeekNumbersVisible) {
+		if (view.cellWeekNumbersVisible) {
 			// To determine the day of week number change under ISO, we cannot
 			// rely on moment.js methods such as firstDayOfWeek() or weekday(),
 			// because they rely on the locale's dow (possibly overridden by
@@ -168,8 +169,8 @@ var DayGrid = FC.DayGrid = Grid.extend(DayTableMixin, {
 
 		html += '<td class="' + classes.join(' ') + '" data-date="' + date.format() + '">';
 
-		if (this.view.cellWeekNumbersVisible && (date.day() == weekCalcFirstDoW)) {
-			html += this.view.buildGotoAnchorHtml(
+		if (view.cellWeekNumbersVisible && (date.day() == weekCalcFirstDoW)) {
+			html += view.buildGotoAnchorHtml(
 				{ date: date, type: 'week' },
 				{ 'class': 'fc-week-number' },
 				date.format('w') // inner HTML
@@ -177,7 +178,7 @@ var DayGrid = FC.DayGrid = Grid.extend(DayTableMixin, {
 		}
 
 		if (isDayNumberVisible) {
-			html += this.view.buildGotoAnchorHtml(
+			html += view.buildGotoAnchorHtml(
 				date,
 				{ 'class': 'fc-day-number' },
 				date.date() // inner HTML

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

@@ -379,7 +379,7 @@ Grid.mixin({
 		var calendar = this.view.calendar;
 		var rawEventRange = this.eventToRawEventRange(eventLocation); // always returns some value
 
-		if (!this.view.isValidRange(rawEventRange)) {
+		if (!this.view.isRangeWithinContentRange(rawEventRange)) {
 			return false;
 		}
 
@@ -405,7 +405,7 @@ Grid.mixin({
 		var calendar = this.view.calendar;
 		var rawEventRange = this.eventToRawEventRange(eventLocation); // always returns some value
 
-		if (!this.view.isValidRange(rawEventRange)) {
+		if (!this.view.isRangeWithinContentRange(rawEventRange)) {
 			return false;
 		}
 

+ 1 - 1
src/common/Grid.js

@@ -673,7 +673,7 @@ var Grid = FC.Grid = Class.extend(ListenerMixin, {
 		var classes = [];
 		var today;
 
-		if (view.isDisabledDate(date)) {
+		if (!view.isDateWithinContentRange(date)) {
 			classes.push('fc-disabled-day'); // TODO: jQuery UI theme?
 		}
 		else {

+ 4 - 5
src/common/View.js

@@ -1519,14 +1519,13 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
 	},
 
 
-	// Computes if a renderable date should be displayed as disabled because it's out of range
-	isDisabledDate: function(date) { // TODO: rename
-		return date < this.contentStart || date >= this.contentEnd;
+	isDateWithinContentRange: function(date) { // best place?
+		return date >= this.contentStart && date < this.contentEnd;
 	},
 
 
-	isValidRange: function(range) {
-		return range.start >= this.contentStart && range.end <= this.contentEnd; // TODO: date util. also, what about timezone?
+	isRangeWithinContentRange: function(range) { // best place?
+		return range.start >= this.contentStart && range.end <= this.contentEnd;
 	},