Browse Source

slight API change for mouse-grid system

Adam Shaw 10 years ago
parent
commit
017c69632c
3 changed files with 26 additions and 22 deletions
  1. 1 5
      src/common/DayGrid.js
  2. 24 12
      src/common/Grid.js
  3. 1 5
      src/common/TimeGrid.js

+ 1 - 5
src/common/DayGrid.js

@@ -136,16 +136,12 @@ var DayGrid = Grid.extend({
 	------------------------------------------------------------------------------------------------------------------*/
 
 
-	// Tells the grid about what period of time to display.
-	// Any date-related cell system internal data should be generated.
-	setRange: function() {
+	rangeUpdated: function() {
 		var cellDates;
 		var firstDay;
 		var rowCnt;
 		var colCnt;
 
-		Grid.prototype.setRange.apply(this, arguments); // call the super-method
-
 		this.updateCellDates(); // populates cellDates and dayToCellOffsets
 		cellDates = this.cellDates;
 

+ 24 - 12
src/common/Grid.js

@@ -74,28 +74,28 @@ var Grid = fc.Grid = RowRenderer.extend({
 	------------------------------------------------------------------------------------------------------------------*/
 
 
-	// Called before the grid will need to be queried for cells.
-	// Any non-date-related cell system internal data should be built.
-	build: function() {
+	// Tells the grid about what period of time to display.
+	// Any date-related cell system internal data should be generated.
+	setRange: function(range) {
+		this.start = range.start.clone();
+		this.end = range.end.clone();
+
+		this.rangeUpdated();
+		this.processRangeOptions();
 	},
 
 
-	// Called after the grid is done being relied upon.
-	// Any non-date-related cell system internal data should be cleared.
-	clear: function() {
+	// Called when internal variables that rely on the range should be updated
+	rangeUpdated: function() {
 	},
 
 
-	// Tells the grid about what period of time to display.
-	// Any date-related cell system internal data should be generated.
-	setRange: function(range) {
+	// Updates values that rely on options and also relate to range
+	processRangeOptions: function() {
 		var view = this.view;
 		var displayEventTime;
 		var displayEventEnd;
 
-		this.start = range.start.clone();
-		this.end = range.end.clone();
-
 		// Populate option-derived settings. Look for override first, then compute if necessary.
 		this.colHeadFormat = view.opt('columnFormat') || this.computeColHeadFormat();
 
@@ -119,6 +119,18 @@ var Grid = fc.Grid = RowRenderer.extend({
 	},
 
 
+	// Called before the grid's coordinates will need to be queried for cells.
+	// Any non-date-related cell system internal data should be built.
+	build: function() {
+	},
+
+
+	// Called after the grid's coordinates are done being relied upon.
+	// Any non-date-related cell system internal data should be cleared.
+	clear: function() {
+	},
+
+
 	// Converts a range with an inclusive `start` and an exclusive `end` into an array of segment objects
 	rangeToSegs: function(range) {
 		// subclasses must implement

+ 1 - 5
src/common/TimeGrid.js

@@ -156,15 +156,11 @@ var TimeGrid = Grid.extend({
 	------------------------------------------------------------------------------------------------------------------*/
 
 
-	// Tells the grid about what period of time to display.
-	// Any date-related cell system internal data should be generated.
-	setRange: function() {
+	rangeUpdated: function() {
 		var view = this.view;
 		var colDates = [];
 		var date;
 
-		Grid.prototype.setRange.apply(this, arguments); // call the super-method
-
 		date = this.start.clone();
 		while (date.isBefore(this.end)) {
 			colDates.push(date.clone());