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

businessHours, render on whole-days

Adam Shaw 11 лет назад
Родитель
Сommit
3bdca2f860
4 измененных файлов с 31 добавлено и 10 удалено
  1. 14 10
      src/EventManager.js
  2. 4 0
      src/agenda/AgendaView.js
  3. 5 0
      src/basic/BasicView.js
  4. 8 0
      src/common/DayGrid.js

+ 14 - 10
src/EventManager.js

@@ -870,7 +870,7 @@ function EventManager(options) { // assumed to be a calendar
 
 
 	// Returns an array of events as to when the business hours occur in the given view.
 	// Returns an array of events as to when the business hours occur in the given view.
 	// Abuse of our event system :(
 	// Abuse of our event system :(
-	function getBusinessHoursEvents() {
+	function getBusinessHoursEvents(wholeDay) {
 		var optionVal = options.businessHours;
 		var optionVal = options.businessHours;
 		var defaultVal = {
 		var defaultVal = {
 			className: 'fc-nonbusiness',
 			className: 'fc-nonbusiness',
@@ -882,18 +882,22 @@ function EventManager(options) { // assumed to be a calendar
 		var view = t.getView();
 		var view = t.getView();
 		var eventInput;
 		var eventInput;
 
 
-		if (optionVal) {
-			if (typeof optionVal === 'object') {
-				// option value is an object that can override the default business hours
-				eventInput = $.extend({}, defaultVal, optionVal);
-			}
-			else {
-				// option value is `true`. use default business hours
-				eventInput = defaultVal;
-			}
+		if (optionVal) { // `true` (which means "use the defaults") or an override object
+			eventInput = $.extend(
+				{}, // copy to a new object in either case
+				defaultVal,
+				typeof optionVal === 'object' ? optionVal : {} // override the defaults
+			);
 		}
 		}
 
 
 		if (eventInput) {
 		if (eventInput) {
+
+			// if a whole-day series is requested, clear the start/end times
+			if (wholeDay) {
+				eventInput.start = null;
+				eventInput.end = null;
+			}
+
 			return expandEvent(
 			return expandEvent(
 				buildEventFromInput(eventInput),
 				buildEventFromInput(eventInput),
 				view.start,
 				view.start,

+ 4 - 0
src/agenda/AgendaView.js

@@ -106,6 +106,10 @@ var AgendaView = fcViews.agenda = View.extend({
 
 
 	renderBusinessHours: function() {
 	renderBusinessHours: function() {
 		this.timeGrid.renderBusinessHours();
 		this.timeGrid.renderBusinessHours();
+
+		if (this.dayGrid) {
+			this.dayGrid.renderBusinessHours();
+		}
 	},
 	},
 
 
 
 

+ 5 - 0
src/basic/BasicView.js

@@ -78,6 +78,11 @@ var BasicView = fcViews.basic = View.extend({
 	},
 	},
 
 
 
 
+	renderBusinessHours: function() {
+		this.dayGrid.renderBusinessHours();
+	},
+
+
 	// Builds the HTML skeleton for the view.
 	// Builds the HTML skeleton for the view.
 	// The day-grid component will render inside of a container defined by this HTML.
 	// The day-grid component will render inside of a container defined by this HTML.
 	renderHtml: function() {
 	renderHtml: function() {

+ 8 - 0
src/common/DayGrid.js

@@ -49,6 +49,14 @@ var DayGrid = Grid.extend({
 	},
 	},
 
 
 
 
+	renderBusinessHours: function() {
+		var events = this.view.calendar.getBusinessHoursEvents(true); // wholeDay=true
+		var segs = this.eventsToSegs(events);
+
+		this.renderFill('businessHours', segs, 'bgevent');
+	},
+
+
 	// Generates the HTML for a single row. `row` is the row number.
 	// Generates the HTML for a single row. `row` is the row number.
 	dayRowHtml: function(row, isRigid) {
 	dayRowHtml: function(row, isRigid) {
 		var view = this.view;
 		var view = this.view;