Adam Shaw 8 лет назад
Родитель
Сommit
d44b7396d8
3 измененных файлов с 96 добавлено и 99 удалено
  1. 1 0
      src.json
  2. 71 0
      src/Calendar.business.js
  3. 24 99
      src/EventManager.js

+ 1 - 0
src.json

@@ -40,6 +40,7 @@
     "Calendar.view-spec.js",
     "Calendar.render.js",
     "Calendar.toolbar.js",
+    "Calendar.business.js",
     "defaults.js",
     "locale.js",
     "Header.js",

+ 71 - 0
src/Calendar.business.js

@@ -0,0 +1,71 @@
+
+var BUSINESS_HOUR_EVENT_DEFAULTS = {
+	id: '_fcBusinessHours', // will relate events from different calls to expandEvent
+	start: '09:00',
+	end: '17:00',
+	dow: [ 1, 2, 3, 4, 5 ], // monday - friday
+	rendering: 'inverse-background'
+	// classNames are defined in businessHoursSegClasses
+};
+
+
+// Return events objects for business hours within the current view.
+// Abuse of our event system :(
+Calendar.prototype.buildCurrentBusinessGroup = function(wholeDay) {
+	var activeRange = this.getView().activeRange;
+
+	return this.buildBusinessGroup(
+		wholeDay,
+		this.opt('businessHours'),
+		activeRange.start,
+		activeRange.end
+	);
+};
+
+
+// Given a raw input value from options, return events objects for business hours within the current view.
+Calendar.prototype.buildBusinessGroup = function(wholeDay, input, rangeStart, rangeEnd) {
+	if (input === true) {
+		return this._buildBusinessGroup(wholeDay, [ {} ], false, rangeStart, rangeEnd);
+	}
+	else if ($.isPlainObject(input)) {
+		return this._buildBusinessGroup(wholeDay, [ input ], false, rangeStart, rangeEnd);
+	}
+	else if ($.isArray(input)) {
+		return this._buildBusinessGroup(wholeDay, input, true, rangeStart, rangeEnd);
+	}
+	else {
+		return new EventInstanceGroup([]);
+	}
+};
+
+
+Calendar.prototype._buildBusinessGroup = function(wholeDay, rawDefs, ignoreNoDow, rangeStart, rangeEnd) {
+	var rawDef;
+	var fullRawDef;
+	var eventDef;
+	var eventInstances = [];
+
+	for (i = 0; i < rawDefs.length; i++) {
+		rawDef = rawDefs[i];
+
+		if (ignoreNoDow && !rawDef.dow) {
+			continue;
+		}
+
+		fullRawDef = $.extend({}, BUSINESS_HOUR_EVENT_DEFAULTS, rawDefs[i]);
+
+		if (wholeDay) {
+			fullRawDef.start = null;
+			fullRawDef.end = null;
+		}
+
+		eventDef = RecurringEventDefinition.parse(fullRawDef);
+
+		eventInstances.push.apply(eventInstances, // append
+			eventDef.buildInstances(rangeStart, rangeEnd)
+		);
+	}
+
+	return new EventInstanceGroup(eventInstances);
+};

+ 24 - 99
src/EventManager.js

@@ -1225,6 +1225,30 @@ function backupEventDates(event) {
 }
 
 
+Calendar.prototype.buildMutatedEventInstanceGroup = function(eventId, eventMutation) {
+	var viewRange = this.getView().activeRange;
+	var defs = this.eventDefCollection.getById(eventId);
+	var i;
+	var allInstances = [];
+
+	for (i = 0; i < defs.length; i++) {
+		defCopy = defs[i].clone();
+
+		if (defCopy instanceof SingleEventDefinition) {
+
+			eventMutation.mutateSingleEventDefinition(defCopy, this); // calendar=this
+			eventInstances = defCopy.buildInstances(viewRange.start, viewRange.end);
+
+			allInstances.push.apply(allInstances,
+				eventInstances
+			);
+		}
+	}
+
+	return new EventInstanceGroup(allInstances);
+};
+
+
 /* Overlapping / Constraining
 -----------------------------------------------------------------------------------------*/
 
@@ -1386,102 +1410,3 @@ Calendar.prototype.eventIntersectsRange = function(event, range) {
 
 	return range.start < eventEnd && range.end > eventStart;
 };
-
-
-/* Business Hours
------------------------------------------------------------------------------------------*/
-
-var BUSINESS_HOUR_EVENT_DEFAULTS = {
-	id: '_fcBusinessHours', // will relate events from different calls to expandEvent
-	start: '09:00',
-	end: '17:00',
-	dow: [ 1, 2, 3, 4, 5 ], // monday - friday
-	rendering: 'inverse-background'
-	// classNames are defined in businessHoursSegClasses
-};
-
-
-// Return events objects for business hours within the current view.
-// Abuse of our event system :(
-Calendar.prototype.buildCurrentBusinessGroup = function(wholeDay) {
-	var activeRange = this.getView().activeRange;
-
-	return this.buildBusinessGroup(
-		wholeDay,
-		this.opt('businessHours'),
-		activeRange.start,
-		activeRange.end
-	);
-};
-
-
-// Given a raw input value from options, return events objects for business hours within the current view.
-Calendar.prototype.buildBusinessGroup = function(wholeDay, input, rangeStart, rangeEnd) {
-	if (input === true) {
-		return this._buildBusinessGroup(wholeDay, [ {} ], false, rangeStart, rangeEnd);
-	}
-	else if ($.isPlainObject(input)) {
-		return this._buildBusinessGroup(wholeDay, [ input ], false, rangeStart, rangeEnd);
-	}
-	else if ($.isArray(input)) {
-		return this._buildBusinessGroup(wholeDay, input, true, rangeStart, rangeEnd);
-	}
-	else {
-		return new EventInstanceGroup([]);
-	}
-};
-
-
-Calendar.prototype._buildBusinessGroup = function(wholeDay, rawDefs, ignoreNoDow, rangeStart, rangeEnd) {
-	var rawDef;
-	var fullRawDef;
-	var eventDef;
-	var eventInstances = [];
-
-	for (i = 0; i < rawDefs.length; i++) {
-		rawDef = rawDefs[i];
-
-		if (ignoreNoDow && !rawDef.dow) {
-			continue;
-		}
-
-		fullRawDef = $.extend({}, BUSINESS_HOUR_EVENT_DEFAULTS, rawDefs[i]);
-
-		if (wholeDay) {
-			fullRawDef.start = null;
-			fullRawDef.end = null;
-		}
-
-		eventDef = RecurringEventDefinition.parse(fullRawDef);
-
-		eventInstances.push.apply(eventInstances, // append
-			eventDef.buildInstances(rangeStart, rangeEnd)
-		);
-	}
-
-	return new EventInstanceGroup(eventInstances);
-};
-
-
-Calendar.prototype.buildMutatedEventInstanceGroup = function(eventId, eventMutation) {
-	var viewRange = this.getView().activeRange;
-	var defs = this.eventDefCollection.getById(eventId);
-	var i;
-	var allInstances = [];
-
-	for (i = 0; i < defs.length; i++) {
-		defCopy = defs[i].clone();
-
-		if (defCopy instanceof SingleEventDefinition) {
-
-			eventMutation.mutateSingleEventDefinition(defCopy, this); // calendar=this
-			eventInstances = defCopy.buildInstances(viewRange.start, viewRange.end);
-
-			allInstances.push.apply(allInstances,
-				eventInstances
-			);
-		}
-	}
-
-	return new EventInstanceGroup(allInstances);
-};