Explorar o código

relocate/rename getBusinessHoursEvents

Adam Shaw %!s(int64=9) %!d(string=hai) anos
pai
achega
51de84f6c5
Modificáronse 3 ficheiros con 52 adicións e 50 borrados
  1. 50 48
      src/EventManager.js
  2. 1 1
      src/common/DayGrid.js
  3. 1 1
      src/common/TimeGrid.js

+ 50 - 48
src/EventManager.js

@@ -1035,53 +1035,6 @@ function EventManager() { // assumed to be a calendar
 	}
 
 
-	/* Business Hours
-	-----------------------------------------------------------------------------------------*/
-
-	t.getBusinessHoursEvents = getBusinessHoursEvents;
-
-
-	// Returns an array of events as to when the business hours occur in the given view.
-	// Abuse of our event system :(
-	function getBusinessHoursEvents(wholeDay) {
-		var optionVal = t.options.businessHours;
-		var defaultVal = {
-			className: 'fc-nonbusiness',
-			start: '09:00',
-			end: '17:00',
-			dow: [ 1, 2, 3, 4, 5 ], // monday - friday
-			rendering: 'inverse-background'
-		};
-		var view = t.getView();
-		var eventInput;
-
-		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 a whole-day series is requested, clear the start/end times
-			if (wholeDay) {
-				eventInput.start = null;
-				eventInput.end = null;
-			}
-
-			return expandEvent(
-				buildEventFromInput(eventInput),
-				view.start,
-				view.end
-			);
-		}
-
-		return [];
-	}
-
-
 	/* Overlapping / Constraining
 	-----------------------------------------------------------------------------------------*/
 
@@ -1211,7 +1164,7 @@ function EventManager() { // assumed to be a calendar
 	function constraintToEvents(constraintInput) {
 
 		if (constraintInput === 'businessHours') {
-			return getBusinessHoursEvents();
+			return t.getCurrentBusinessHourEvents();
 		}
 
 		if (typeof constraintInput === 'object') {
@@ -1282,3 +1235,52 @@ function backupEventDates(event) {
 	event._start = event.start.clone();
 	event._end = event.end ? event.end.clone() : null;
 }
+
+
+/* Business Hours
+-----------------------------------------------------------------------------------------*/
+
+// Return events objects for business hours within the current view.
+// Abuse of our event system :(
+Calendar.prototype.getCurrentBusinessHourEvents = function(wholeDay) {
+	return this.computeBusinessHourEvents(wholeDay, this.options.businessHours);
+};
+
+
+// Given a raw input value from options, return events objects for business hours within the current view.
+Calendar.prototype.computeBusinessHourEvents = function(wholeDay, optionVal) {
+	var defaultVal = {
+		className: 'fc-nonbusiness',
+		start: '09:00',
+		end: '17:00',
+		dow: [ 1, 2, 3, 4, 5 ], // monday - friday
+		rendering: 'inverse-background'
+	};
+	var view = this.getView();
+	var eventInput;
+
+	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 a whole-day series is requested, clear the start/end times
+		if (wholeDay) {
+			eventInput.start = null;
+			eventInput.end = null;
+		}
+
+		return this.expandEvent(
+			this.buildEventFromInput(eventInput),
+			view.start,
+			view.end
+		);
+	}
+
+	return [];
+};

+ 1 - 1
src/common/DayGrid.js

@@ -63,7 +63,7 @@ var DayGrid = FC.DayGrid = Grid.extend(DayTableMixin, {
 
 
 	renderBusinessHours: function() {
-		var events = this.view.calendar.getBusinessHoursEvents(true); // wholeDay=true
+		var events = this.view.calendar.getCurrentBusinessHourEvents(true); // wholeDay=true
 		var segs = this.eventsToSegs(events);
 
 		this.renderFill('businessHours', segs, 'bgevent');

+ 1 - 1
src/common/TimeGrid.js

@@ -423,7 +423,7 @@ var TimeGrid = FC.TimeGrid = Grid.extend(DayTableMixin, {
 
 
 	renderBusinessHours: function() {
-		var events = this.view.calendar.getBusinessHoursEvents();
+		var events = this.view.calendar.getCurrentBusinessHourEvents();
 		var segs = this.eventsToSegs(events);
 
 		this.renderBusinessSegs(segs);