Ver Fonte

separate handleDateProfileSet from renderDates

Adam Shaw há 8 anos atrás
pai
commit
09c9e75fb2
2 ficheiros alterados com 26 adições e 9 exclusões
  1. 20 5
      src/basic/BasicView.js
  2. 6 4
      src/basic/DayGrid.js

+ 20 - 5
src/basic/BasicView.js

@@ -64,12 +64,15 @@ var BasicView = FC.BasicView = View.extend({
 	},
 
 
-	// Renders the view into `this.el`, which should already be assigned
-	renderDates: function(dateProfile) {
+	handleDateProfileSet: function(dateProfile) {
 
 		this.dayGrid.breakOnWeeks = /year|month|week/.test(dateProfile.currentRangeUnit);
 
+		// will populate dayGrid.rowCnt :(
+		View.prototype.handleDateProfileSet.apply(this, arguments);
+
 		this.dayNumbersVisible = this.dayGrid.rowCnt > 1; // TODO: make grid responsible
+
 		if (this.opt('weekNumbers')) {
 			if (this.opt('weekNumbersWithinDays')) {
 				this.cellWeekNumbersVisible = true;
@@ -80,19 +83,30 @@ var BasicView = FC.BasicView = View.extend({
 				this.colWeekNumbersVisible = true;
 			};
 		}
-		this.dayGrid.numbersVisible = this.dayNumbersVisible ||
-			this.cellWeekNumbersVisible || this.colWeekNumbersVisible;
+
+		this.dayGrid.numbersVisible =
+			this.dayNumbersVisible ||
+			this.cellWeekNumbersVisible ||
+			this.colWeekNumbersVisible;
+
+		this.dayGrid.isRigid = this.hasRigidRows();
+	},
+
+
+	// Renders the view into `this.el`, which should already be assigned
+	renderDates: function(dateProfile) {
 
 		this.el.addClass('fc-basic-view').html(this.renderSkeletonHtml());
 		this.renderHead();
 
 		this.scroller.render();
+
 		var dayGridContainerEl = this.scroller.el.addClass('fc-day-grid-container');
 		var dayGridEl = $('<div class="fc-day-grid" />').appendTo(dayGridContainerEl);
+
 		this.el.find('.fc-body > tr > td').append(dayGridContainerEl);
 
 		this.dayGrid.setElement(dayGridEl);
-		this.dayGrid.renderDates(this.hasRigidRows());
 	},
 
 
@@ -147,6 +161,7 @@ var BasicView = FC.BasicView = View.extend({
 	// Determines whether each row should have a constant height
 	hasRigidRows: function() {
 		var eventLimit = this.opt('eventLimit');
+
 		return eventLimit && typeof eventLimit !== 'number';
 	},
 

+ 6 - 4
src/basic/DayGrid.js

@@ -20,6 +20,10 @@ var DayGrid = FC.DayGrid = InteractiveDateComponent.extend(StandardInteractionsM
 	rowCoordCache: null,
 	colCoordCache: null,
 
+	// isRigid determines whether the individual rows should ignore the contents and be a constant height.
+	// Relies on the view's colCnt and rowCnt. In the future, this component should probably be self-sufficient.
+	isRigid: false,
+
 
 	constructor: function(view) {
 		this.view = view; // do first, for opt calls during initialization
@@ -71,9 +75,7 @@ var DayGrid = FC.DayGrid = InteractiveDateComponent.extend(StandardInteractionsM
 
 
 	// Renders the rows and columns into the component's `this.el`, which should already be assigned.
-	// isRigid determins whether the individual rows should ignore the contents and be a constant height.
-	// Relies on the view's colCnt and rowCnt. In the future, this component should probably be self-sufficient.
-	renderDates: function(isRigid) {
+	renderDates: function(dateProfile) {
 		var view = this.view;
 		var rowCnt = this.rowCnt;
 		var colCnt = this.colCnt;
@@ -82,7 +84,7 @@ var DayGrid = FC.DayGrid = InteractiveDateComponent.extend(StandardInteractionsM
 		var col;
 
 		for (row = 0; row < rowCnt; row++) {
-			html += this.renderDayRowHtml(row, isRigid);
+			html += this.renderDayRowHtml(row, this.isRigid);
 		}
 		this.el.html(html);