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

move CoordChronoComponent to a mixin

Adam Shaw 8 лет назад
Родитель
Сommit
b6341d3efe

+ 6 - 6
src.json

@@ -21,12 +21,12 @@
     "common/GlobalEmitter.js",
     "common/MouseFollower.js",
     "common/ChronoComponent.js",
-    "common/CoordChronoComponent.js",
-    "common/CoordChronoComponent.day-click.js",
-    "common/CoordChronoComponent.day-selection.js",
-    "common/CoordChronoComponent.event-dragging.js",
-    "common/CoordChronoComponent.event-resizing.js",
-    "common/CoordChronoComponent.external-dropping.js",
+    "common/CoordChronoComponentMixin.js",
+    "common/CoordChronoComponentMixin.day-click.js",
+    "common/CoordChronoComponentMixin.day-selection.js",
+    "common/CoordChronoComponentMixin.event-dragging.js",
+    "common/CoordChronoComponentMixin.event-resizing.js",
+    "common/CoordChronoComponentMixin.external-dropping.js",
     "common/FillSystemMixin.js",
     "common/EventRenderingUtilsMixin.js",
     "common/SegChronoComponentMixin.js",

+ 1 - 1
src/common/CoordChronoComponent.day-click.js → src/common/CoordChronoComponentMixin.day-click.js

@@ -1,5 +1,5 @@
 
-CoordChronoComponent.mixin({
+$.extend(CoordChronoComponentMixin, {
 
 	// Creates a listener that tracks the user's drag across day elements, for day clicking.
 	buildDayClickListener: function() {

+ 1 - 1
src/common/CoordChronoComponent.day-selection.js → src/common/CoordChronoComponentMixin.day-selection.js

@@ -1,5 +1,5 @@
 
-CoordChronoComponent.mixin({
+$.extend(CoordChronoComponentMixin, {
 
 	// Creates a listener that tracks the user's drag across day elements, for day selecting.
 	buildDaySelectListener: function() {

+ 1 - 1
src/common/CoordChronoComponent.event-dragging.js → src/common/CoordChronoComponentMixin.event-dragging.js

@@ -3,7 +3,7 @@
 Wired up by calling
 buildSegDragListener
 */
-CoordChronoComponent.mixin({
+$.extend(CoordChronoComponentMixin, {
 
 	isDraggingSeg: false, // is a segment being dragged? boolean
 

+ 1 - 1
src/common/CoordChronoComponent.event-resizing.js → src/common/CoordChronoComponentMixin.event-resizing.js

@@ -3,7 +3,7 @@
 Wired up by calling
 startSegResize
 */
-CoordChronoComponent.mixin({
+$.extend(CoordChronoComponentMixin, {
 
 	isResizingSeg: false, // is a segment being resized? boolean
 

+ 1 - 1
src/common/CoordChronoComponent.external-dropping.js → src/common/CoordChronoComponentMixin.external-dropping.js

@@ -3,7 +3,7 @@
 Wired up by calling
 externalDragStart
 */
-CoordChronoComponent.mixin({
+$.extend(CoordChronoComponentMixin, {
 
 	isDraggingExternal: false, // jqui-dragging an external element? boolean
 

+ 3 - 5
src/common/CoordChronoComponent.js → src/common/CoordChronoComponentMixin.js

@@ -1,5 +1,5 @@
 
-var CoordChronoComponent = ChronoComponent.extend({
+var CoordChronoComponentMixin = {
 
 	// self-config, overridable by subclasses
 	segSelector: '.fc-event-container > *', // what constitutes an event element?
@@ -23,9 +23,7 @@ var CoordChronoComponent = ChronoComponent.extend({
 	hasDayInteractions: true, // can user click/select ranges of time?
 
 
-	constructor: function() {
-		ChronoComponent.apply(this, arguments);
-
+	initCoordChronoComponent: function() {
 		this.dayClickListener = this.buildDayClickListener();
 		this.daySelectListener = this.buildDaySelectListener();
 	},
@@ -452,4 +450,4 @@ var CoordChronoComponent = ChronoComponent.extend({
 	getHitEl: function(hit) {
 	}
 
-});
+};

+ 6 - 3
src/common/DayGrid.js

@@ -2,7 +2,7 @@
 /* A component that renders a grid of whole-days that runs horizontally. There can be multiple rows, one per week.
 ----------------------------------------------------------------------------------------------------------------------*/
 
-var DayGrid = FC.DayGrid = CoordChronoComponent.extend(SegChronoComponentMixin, DayTableMixin, {
+var DayGrid = FC.DayGrid = ChronoComponent.extend(CoordChronoComponentMixin, SegChronoComponentMixin, DayTableMixin, {
 
 	view: null, // TODO: make more general and/or remove
 
@@ -18,9 +18,12 @@ var DayGrid = FC.DayGrid = CoordChronoComponent.extend(SegChronoComponentMixin,
 
 
 	constructor: function(view) {
-		this.view = view; // do first, because CoordChronoComponent calls opt
+		this.view = view; // do first, for opt calls during initialization
 
-		CoordChronoComponent.apply(this, arguments);
+		ChronoComponent.apply(this, arguments);
+
+		// a requirement for CoordChronoComponentMixin
+		this.initCoordChronoComponent();
 
 		// a requirement for SegChronoComponentMixin. TODO: more elegant
 		this.initFillSystem();

+ 6 - 3
src/common/TimeGrid.js

@@ -3,7 +3,7 @@
 ----------------------------------------------------------------------------------------------------------------------*/
 // We mixin DayTable, even though there is only a single row of days
 
-var TimeGrid = FC.TimeGrid = CoordChronoComponent.extend(SegChronoComponentMixin, DayTableMixin, {
+var TimeGrid = FC.TimeGrid = ChronoComponent.extend(CoordChronoComponentMixin, SegChronoComponentMixin, DayTableMixin, {
 
 	view: null, // TODO: make more general and/or remove
 
@@ -24,9 +24,12 @@ var TimeGrid = FC.TimeGrid = CoordChronoComponent.extend(SegChronoComponentMixin
 
 
 	constructor: function(view) {
-		this.view = view; // do first, because CoordChronoComponent calls opt
+		this.view = view; // do first, for opt calls during initialization
 
-		CoordChronoComponent.apply(this, arguments); // call the super-constructor
+		ChronoComponent.apply(this, arguments); // call the super-constructor
+
+		// a requirement for CoordChronoComponentMixin
+		this.initCoordChronoComponent();
 
 		// a requirement for SegChronoComponentMixin. TODO: more elegant
 		this.initFillSystem();

+ 7 - 4
src/list/ListView.js

@@ -68,7 +68,7 @@ var ListView = View.extend({
 Responsible for event rendering and user-interaction.
 Its "el" is the inner-content of the above view's scroller.
 */
-var ListViewGrid = CoordChronoComponent.extend(SegChronoComponentMixin, { // TODO: just use ChonoComponent!!!
+var ListViewGrid = ChronoComponent.extend(CoordChronoComponentMixin, SegChronoComponentMixin, { // TODO: kill CoordChronoComponentMixin
 
 	view: null, // TODO: make more general and/or remove
 
@@ -79,9 +79,12 @@ var ListViewGrid = CoordChronoComponent.extend(SegChronoComponentMixin, { // TOD
 
 
 	constructor: function(view) {
-		this.view = view; // do first, because CoordChronoComponent calls opt
+		this.view = view; // do first, for opt calls during initialization
 
-		CoordChronoComponent.apply(this, arguments);
+		ChronoComponent.apply(this, arguments);
+
+		// a requirement for CoordChronoComponentMixin
+		this.initCoordChronoComponent();
 
 		// a requirement for SegChronoComponentMixin. TODO: more elegant
 		this.initFillSystem();
@@ -172,7 +175,7 @@ var ListViewGrid = CoordChronoComponent.extend(SegChronoComponentMixin, { // TOD
 	handleSegClick: function(seg, ev) {
 		var url;
 
-		CoordChronoComponent.prototype.handleSegClick.apply(this, arguments); // super. might prevent the default action
+		CoordChronoComponentMixin.handleSegClick.apply(this, arguments); // super. might prevent the default action
 
 		// not clicking on or within an <a> with an href
 		if (!$(ev.target).closest('a[href]').length) {