Adam Shaw 8 лет назад
Родитель
Сommit
05e893460c
4 измененных файлов с 21 добавлено и 194 удалено
  1. 0 1
      src.json
  2. 17 137
      src/View.js
  3. 0 45
      src/common/MessageAggregator.js
  4. 4 11
      src/component/DateComponent.js

+ 0 - 1
src.json

@@ -22,7 +22,6 @@
     "common/MouseFollower.js",
     "common/Scroller.js",
     "common/Iterator.js",
-    "common/MessageAggregator.js",
     "component/interactions/Interaction.js",
     "component/interactions/DateClicking.js",
     "component/interactions/DateSelecting.js",

+ 17 - 137
src/View.js

@@ -52,11 +52,6 @@ var View = FC.View = InteractiveDateComponent.extend({
 		if (this.initialize) {
 			this.initialize();
 		}
-
-		this.on('all:dateRender', this.onAllDateRender);
-		this.on('before:all:dateUnrender', this.onBeforeAllDateUnrender);
-		this.on('all:eventRender', this.onAllEventRender);
-		this.on('before:all:eventUnrender', this.onBeforeAllEventUnrender);
 	},
 
 
@@ -231,8 +226,8 @@ var View = FC.View = InteractiveDateComponent.extend({
 		this.addScroll({ isDateInit: true });
 		this.startNowIndicator(); // shouldn't render yet because updateSize will be called soon
 
-		this.trigger('dateRender');
 		this.isDatesRendered = true;
+		this.trigger('after:date:render');
 	},
 
 
@@ -241,7 +236,7 @@ var View = FC.View = InteractiveDateComponent.extend({
 		this.unselect();
 		this.stopNowIndicator();
 
-		this.trigger('before:dateUnrender');
+		this.trigger('before:date:unrender');
 		this.unrenderDates();
 
 		if (this.destroy) {
@@ -254,37 +249,32 @@ var View = FC.View = InteractiveDateComponent.extend({
 
 	// Determing when the "meat" of the view is rendered (aka the base)
 	// -----------------------------------------------------------------------------------------------------------------
+	// not hooked up anymore
 
 
-	onAllDateRender: function() {
-		this.onBaseRender();
+	triggerAfterDateRender: function() {
+		this.triggerAfterBaseRender();
 	},
 
 
-	onBeforeAllDateUnrender: function() {
-		this.onBeforeBaseUnrender();
+	triggerBeforeDateUnrender: function() {
+		this.triggerBeforeBaseUnrender();
 	},
 
 
-	onBaseRender: function() {
-		if (this.hasPublicHandlers('viewRender')) {
-			this.applyScreenState();
-			this.publiclyTrigger('viewRender', {
-				context: this,
-				args: [ this, this.el ]
-			});
-		}
+	triggerAfterBaseRender: function() {
+		this.publiclyTrigger('viewRender', {
+			context: this,
+			args: [ this, this.el ]
+		});
 	},
 
 
-	onBeforeBaseUnrender: function() {
-		if (this.hasPublicHandlers('viewDestroy')) {
-			this.applyScreenState();
-			this.publiclyTrigger('viewDestroy', {
-				context: this,
-				args: [ this, this.el ]
-			});
-		}
+	triggerBeforeBaseUnrender: function() {
+		this.publiclyTrigger('viewDestroy', {
+			context: this,
+			args: [ this, this.el ]
+		});
 	},
 
 
@@ -461,116 +451,6 @@ var View = FC.View = InteractiveDateComponent.extend({
 	},
 
 
-	// Event High-level Rendering
-	// -----------------------------------------------------------------------------------------------------------------
-
-
-	executeEventsRender: function(eventsPayload) {
-		if (this.renderEvents) { // for legacy custom views
-			this.renderEvents(convertEventsPayloadToLegacyArray(eventsPayload));
-		}
-		else {
-			this.renderEventsPayload(eventsPayload);
-		}
-
-		this.trigger('eventRender');
-	},
-
-
-	executeEventsUnrender: function() {
-		this.trigger('before:eventUnrender');
-
-		if (this.destroyEvents) {
-			this.destroyEvents(); // TODO: deprecate
-		}
-
-		this.unrenderEvents();
-	},
-
-
-	rerenderEvents: function() {
-		if (this.has('currentEvents')) {
-			// re-transmit events to this DateComponent, which will forward on the events to children as well.
-			this.resetEvents(this.get('currentEvents'));
-		}
-	},
-
-
-	// Event Rendering Triggers
-	// -----------------------------------------------------------------------------------------------------------------
-
-
-	// Signals that all events have been rendered
-	onAllEventRender: function() {
-		var _this = this;
-		var hasSingleHandlers = this.hasPublicHandlers('eventAfterRender');
-
-		if (hasSingleHandlers || this.hasPublicHandlers('eventAfterAllRender')) {
-			this.applyScreenState();
-		}
-
-		if (hasSingleHandlers) {
-			this.getEventSegs().forEach(function(seg) {
-				var legacy;
-
-				if (seg.el) { // necessary?
-					legacy = seg.footprint.getEventLegacy();
-
-					_this.publiclyTrigger('eventAfterRender', {
-						context: legacy,
-						args: [ legacy, seg.el, _this ]
-					});
-				}
-			});
-		}
-
-		this.publiclyTrigger('eventAfterAllRender', {
-			context: this,
-			args: [ this ]
-		});
-	},
-
-
-	// Signals that all event elements are about to be removed
-	onBeforeAllEventUnrender: function() {
-		var _this = this;
-
-		if (this.hasPublicHandlers('eventDestroy')) {
-
-			this.applyScreenState();
-
-			this.getEventSegs().forEach(function(seg) {
-				var legacy;
-
-				if (seg.el) { // necessary?
-					legacy = seg.footprint.getEventLegacy();
-
-					_this.publiclyTrigger('eventDestroy', {
-						context: legacy,
-						args: [ legacy, seg.el, _this ]
-					});
-				}
-			});
-		}
-	},
-
-
-	// TODO: move this to Calendar, as well as scroll system
-	applyScreenState: function() {
-
-		this.calendar.updateViewSize(
-			false, // isResize
-			this // view (because Calendar::view might have changed)
-		);
-
-		// bring to natural height, then freeze again
-		this.calendar.thawContentHeight();
-		this.calendar.freezeContentHeight();
-
-		this.applyQueuedScroll();
-	},
-
-
 	// Event Rendering Utils
 	// -----------------------------------------------------------------------------------------------------------------
 	// TODO: move this to DateComponent

+ 0 - 45
src/common/MessageAggregator.js

@@ -1,45 +0,0 @@
-
-function buildMessageAggregator(parent, initName, destroyName) {
-	var childUpEvent = 'all:' + initName;
-	var childDownEvent = 'before:all:' + destroyName;
-	var childCnt = 0;
-	var reportCnt = 0;
-
-
-	parent.on(initName, up);
-	parent.on('before:' + destroyName, down);
-
-
-	function addChild(child) {
-		child.on(childUpEvent, up);
-		child.on(childDownEvent, down);
-		childCnt++;
-	}
-
-
-	// does not check to verify that it was a past child
-	function removeChild(child) {
-		child.off(childUpEvent, up);
-		child.off(childDownEvent, down);
-		childCnt--;
-	}
-
-
-	function up() {
-		if (++reportCnt === childCnt + 1) {
-			parent.trigger('all:' + initName);
-		}
-	}
-
-
-	function down() {
-		if (--reportCnt === childCnt) {
-			parent.trigger('before:all:' + destroyName);
-		}
-	}
-
-
-	return { addChild: addChild, removeChild: removeChild };
-}
-
-FC.buildMessageAggregator = buildMessageAggregator;

+ 4 - 11
src/component/DateComponent.js

@@ -48,18 +48,12 @@ var DateComponent = FC.DateComponent = Component.extend({
 		if (this.businessHourRendererClass && this.fillRenderer) {
 			this.businessHourRenderer = new this.businessHourRendererClass(this, this.fillRenderer);
 		}
-
-		this.dateMessageAggregator = buildMessageAggregator(this, 'dateRender', 'dateUnrender');
-		this.eventMessageAggregator = buildMessageAggregator(this, 'eventRender', 'eventUnrender');
 	},
 
 
 	addChild: function(child) {
 		if (!this.childrenByUid[child.uid]) {
 			this.childrenByUid[child.uid] = child;
-
-			this.dateMessageAggregator.addChild(child);
-			this.eventMessageAggregator.addChild(child);
 		}
 	},
 
@@ -67,9 +61,6 @@ var DateComponent = FC.DateComponent = Component.extend({
 	removeChild: function(child) {
 		if (this.childrenByUid[child.uid]) {
 			delete this.childrenByUid[child.uid];
-
-			this.dateMessageAggregator.removeChild(child);
-			this.eventMessageAggregator.removeChild(child);
 		}
 	},
 
@@ -158,13 +149,15 @@ var DateComponent = FC.DateComponent = Component.extend({
 
 	executeDateRender: function(dateProfile, skipScroll) { // wrapper
 		this.renderDates(dateProfile);
-		this.trigger('dateRender');
+		this.trigger('after:date:render');
+		this.isDatesRendered = true;
 	},
 
 
 	executeDateUnrender: function() { // wrapper
-		this.trigger('before:dateUnrender');
+		this.trigger('before:date:unrender');
 		this.unrenderDates();
+		this.isDatesRendered = false;
 	},