Browse Source

less magical business hours api

Adam Shaw 8 years ago
parent
commit
95bf8d25cf
2 changed files with 17 additions and 19 deletions
  1. 6 7
      src/Calendar.business.js
  2. 11 12
      src/common/Grid.events.js

+ 6 - 7
src/Calendar.business.js

@@ -12,17 +12,16 @@ var BUSINESS_HOUR_EVENT_DEFAULTS = {
 returns ComponentFootprint[]
 returns ComponentFootprint[]
 `businessHourDef` is optional. Use Calendar's setting if omitted.
 `businessHourDef` is optional. Use Calendar's setting if omitted.
 */
 */
-Calendar.prototype.buildCurrentBusinessFootprints = function(wholeDay, businessHourDef) {
+Calendar.prototype.buildCurrentBusinessFootprints = function(wholeDay) {
+	return this._buildCurrentBusinessFootprints(wholeDay, this.opt('businessHours'));
+};
+
+
+Calendar.prototype._buildCurrentBusinessFootprints = function(wholeDay, businessDefInput) {
 	var eventPeriod = this.eventManager.currentPeriod;
 	var eventPeriod = this.eventManager.currentPeriod;
-	var businessDefInput;
 	var businessInstanceGroup;
 	var businessInstanceGroup;
 
 
 	if (eventPeriod) {
 	if (eventPeriod) {
-
-		if (arguments.length < 2) {
-			businessDefInput = this.opt('businessHours');
-		}
-
 		businessInstanceGroup = this.buildBusinessInstanceGroup(
 		businessInstanceGroup = this.buildBusinessInstanceGroup(
 			wholeDay,
 			wholeDay,
 			businessDefInput,
 			businessDefInput,

+ 11 - 12
src/common/Grid.events.js

@@ -127,32 +127,31 @@ Grid.mixin({
 
 
 	// Compute business hour segs for the grid's current date range.
 	// Compute business hour segs for the grid's current date range.
 	// Caller must ask if whole-day business hours are needed.
 	// Caller must ask if whole-day business hours are needed.
-	// If no `businessHours` configuration value is specified, assumes the calendar default.
-	buildBusinessHourSegs: function(wholeDay, businessHours) {
+	buildBusinessHourSegs: function(wholeDay) {
 		return this.eventFootprintsToSegs(
 		return this.eventFootprintsToSegs(
-			this.buildBusinessHourEventFootprints(wholeDay, businessHours)
+			this.buildBusinessHourEventFootprints(wholeDay)
 		);
 		);
 	},
 	},
 
 
 
 
 	// Compute business hour *events* for the grid's current date range.
 	// Compute business hour *events* for the grid's current date range.
 	// Caller must ask if whole-day business hours are needed.
 	// Caller must ask if whole-day business hours are needed.
-	// If no `businessHours` configuration value is specified, assumes the calendar default.
 	// FOR RENDERING
 	// FOR RENDERING
-	buildBusinessHourEventFootprints: function(wholeDay, businessHours) {
+	buildBusinessHourEventFootprints: function(wholeDay) {
+		var calendar = this.view.calendar;
+
+		return this._buildBusinessHourEventFootprints(wholeDay, calendar.opt('businessHours'));
+	},
+
+
+	_buildBusinessHourEventFootprints: function(wholeDay, businessHourDef) {
 		var calendar = this.view.calendar;
 		var calendar = this.view.calendar;
 		var eventInstanceGroup;
 		var eventInstanceGroup;
 		var eventRanges;
 		var eventRanges;
 
 
-		if (businessHours == null) {
-			// fallback
-			// access from calendar. don't access from view. doesn't update with dynamic options.
-			businessHours = calendar.opt('businessHours');
-		}
-
 		eventInstanceGroup = calendar.buildBusinessInstanceGroup(
 		eventInstanceGroup = calendar.buildBusinessInstanceGroup(
 			wholeDay,
 			wholeDay,
-			businessHours,
+			businessHourDef,
 			this.start,
 			this.start,
 			this.end
 			this.end
 		);
 		);