Browse Source

rename some stuff

Adam Shaw 8 years ago
parent
commit
ed7a20c4c5

+ 10 - 10
src/common/ParsableModelMixin.js

@@ -1,45 +1,45 @@
 
 var ParsableModelMixin = {
 
-	standardPropMap: {}, // will be cloned by allowRawProps
+	standardPropMap: {}, // will be cloned by defineStandardProps
 
 
 	/*
 	Returns true/false for success
 	*/
-	applyRawProps: function(rawProps) {
+	applyProps: function(rawProps) {
 		var standardPropMap = this.standardPropMap;
 		var manualProps = {};
-		var otherProps = {};
+		var miscProps = {};
 		var propName;
 
 		for (propName in rawProps) {
-			if (standardPropMap[propName] === true) { // copy automatically
+			if (standardPropMap[propName] === true) { // copy verbatim
 				this[propName] = rawProps[propName];
 			}
 			else if (standardPropMap[propName] === false) {
 				manualProps[propName] = rawProps[propName];
 			}
 			else {
-				otherProps[propName] = rawProps[propName];
+				miscProps[propName] = rawProps[propName];
 			}
 		}
 
-		this.applyOtherRawProps(otherProps);
+		this.applyMiscProps(miscProps);
 
-		return this.applyManualRawProps(manualProps);
+		return this.applyManualStandardProps(manualProps);
 	},
 
 
 	/*
 	If subclasses override, they must call this supermethod and return the boolean response.
 	*/
-	applyManualRawProps: function(rawProps) {
+	applyManualStandardProps: function(rawProps) {
 		return true;
 	},
 
 
-	applyOtherRawProps: function(rawProps) {
+	applyMiscProps: function(rawProps) {
 		// subclasses can implement
 	}
 
@@ -49,7 +49,7 @@ var ParsableModelMixin = {
 /*
 TODO: devise a better system
 */
-var ParsableModelMixin_allowRawProps = function(propDefs) {
+var ParsableModelMixin_defineStandardProps = function(propDefs) {
 	var proto = this.prototype;
 
 	proto.standardPropMap = Object.create(proto.standardPropMap);

+ 12 - 6
src/gcal/GcalEventSource.js

@@ -8,6 +8,12 @@ var GcalEventSource = EventSource.extend({
 	ajaxSettings: null,
 
 
+	constructor: function() {
+		EventSource.apply(this, arguments);
+		this.ajaxSettings = {};
+	},
+
+
 	fetch: function(start, end, timezone) {
 		var _this = this;
 		var url = this.buildUrl();
@@ -160,8 +166,8 @@ var GcalEventSource = EventSource.extend({
 	},
 
 
-	applyManualRawProps: function(rawProps) {
-		var superSuccess = EventSource.prototype.applyManualRawProps.apply(this, arguments);
+	applyManualStandardProps: function(rawProps) {
+		var superSuccess = EventSource.prototype.applyManualStandardProps.apply(this, arguments);
 		var googleCalendarId = rawProps.googleCalendarId;
 
 		if (googleCalendarId == null && rawProps.url) {
@@ -178,8 +184,8 @@ var GcalEventSource = EventSource.extend({
 	},
 
 
-	applyOtherRawProps: function(rawProps) {
-		this.ajaxSettings = rawProps;
+	applyMiscProps: function(rawProps) {
+		$.extend(this.ajaxSettings, rawProps);
 	}
 
 });
@@ -188,7 +194,7 @@ var GcalEventSource = EventSource.extend({
 GcalEventSource.API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
 
 
-GcalEventSource.allowRawProps({
+GcalEventSource.defineStandardProps({
 	// manually process...
 	url: false,
 	googleCalendarId: false,
@@ -202,7 +208,7 @@ GcalEventSource.allowRawProps({
 GcalEventSource.parse = function(rawInput, calendar) {
 	var rawProps;
 
-	if (typeof rawInput === 'object') { // long form. might fail in applyManualRawProps
+	if (typeof rawInput === 'object') { // long form. might fail in applyManualStandardProps
 		rawProps = rawInput;
 	}
 	else if (typeof rawInput === 'string') { // short form

+ 3 - 3
src/models/event-source/ArrayEventSource.js

@@ -64,8 +64,8 @@ var ArrayEventSource = EventSource.extend({
 	},
 
 
-	applyManualRawProps: function(rawProps) {
-		var superSuccess = EventSource.prototype.applyManualRawProps.apply(this, arguments);
+	applyManualStandardProps: function(rawProps) {
+		var superSuccess = EventSource.prototype.applyManualStandardProps.apply(this, arguments);
 
 		this.setRawEventDefs(rawProps.events);
 
@@ -75,7 +75,7 @@ var ArrayEventSource = EventSource.extend({
 });
 
 
-ArrayEventSource.allowRawProps({
+ArrayEventSource.defineStandardProps({
 	events: false // don't automatically transfer
 });
 

+ 4 - 4
src/models/event-source/EventSource.js

@@ -72,7 +72,7 @@ var EventSource = Class.extend(ParsableModelMixin, {
 	},
 
 
-	applyManualRawProps: function(rawProps) {
+	applyManualStandardProps: function(rawProps) {
 
 		if (rawProps.id != null) {
 			this.id = EventSource.normalizeId(rawProps.id);
@@ -93,7 +93,7 @@ var EventSource = Class.extend(ParsableModelMixin, {
 
 
 // finish initializing the mixin
-EventSource.allowRawProps = ParsableModelMixin_allowRawProps;
+EventSource.defineStandardProps = ParsableModelMixin_defineStandardProps;
 
 
 // IDs
@@ -117,7 +117,7 @@ EventSource.normalizeId = function(id) {
 // ---------------------------------------------------------------------------------------------------------------------
 
 
-EventSource.allowRawProps({
+EventSource.defineStandardProps({
 	// manually process...
 	id: false,
 	className: false,
@@ -145,7 +145,7 @@ EventSource.parse = function(rawInput, calendar) {
 	var source = new this(calendar);
 
 	if (typeof rawInput === 'object') {
-		if (source.applyRawProps(rawInput)) {
+		if (source.applyProps(rawInput)) {
 			return source;
 		}
 	}

+ 3 - 3
src/models/event-source/FuncEventSource.js

@@ -30,8 +30,8 @@ var FuncEventSource = EventSource.extend({
 	},
 
 
-	applyManualRawProps: function(rawProps) {
-		var superSuccess = EventSource.prototype.applyManualRawProps.apply(this, arguments);
+	applyManualStandardProps: function(rawProps) {
+		var superSuccess = EventSource.prototype.applyManualStandardProps.apply(this, arguments);
 
 		this.func = rawProps.events;
 
@@ -41,7 +41,7 @@ var FuncEventSource = EventSource.extend({
 });
 
 
-FuncEventSource.allowRawProps({
+FuncEventSource.defineStandardProps({
 	events: false // don't automatically transfer
 });
 

+ 3 - 3
src/models/event-source/JsonFeedEventSource.js

@@ -109,8 +109,8 @@ var JsonFeedEventSource = EventSource.extend({
 	},
 
 
-	applyOtherRawProps: function(rawProps) {
-		EventSource.prototype.applyOtherRawProps.apply(this, arguments);
+	applyMiscProps: function(rawProps) {
+		EventSource.prototype.applyMiscProps.apply(this, arguments);
 
 		this.ajaxSettings = rawProps;
 	}
@@ -124,7 +124,7 @@ JsonFeedEventSource.AJAX_DEFAULTS = {
 };
 
 
-JsonFeedEventSource.allowRawProps({
+JsonFeedEventSource.defineStandardProps({
 	// automatically transfer (true)...
 	url: true,
 	startParam: true,

+ 6 - 6
src/models/event/EventDef.js

@@ -150,7 +150,7 @@ var EventDef = FC.EventDef = Class.extend(ParsableModelMixin, {
 	},
 
 
-	applyManualRawProps: function(rawProps) {
+	applyManualStandardProps: function(rawProps) {
 
 		if (rawProps.id != null) {
 			this.id = EventDef.normalizeId((this.rawId = rawProps.id));
@@ -178,14 +178,14 @@ var EventDef = FC.EventDef = Class.extend(ParsableModelMixin, {
 	},
 
 
-	applyOtherRawProps: function(rawProps) {
-		this.miscProps = rawProps;
+	applyMiscProps: function(rawProps) {
+		$.extend(this.miscProps, rawProps);
 	}
 
 });
 
 // finish initializing the mixin
-EventDef.allowRawProps = ParsableModelMixin_allowRawProps;
+EventDef.defineStandardProps = ParsableModelMixin_defineStandardProps;
 EventDef.copyVerbatimStandardProps = ParsableModelMixin_copyVerbatimStandardProps;
 
 
@@ -211,7 +211,7 @@ EventDef.generateId = function() {
 // ---------------------------------------------------------------------------------------------------------------------
 
 
-EventDef.allowRawProps({
+EventDef.defineStandardProps({
 	// not automatically assigned (`false`)
 	_id: false,
 	id: false,
@@ -246,7 +246,7 @@ EventDef.parse = function(rawInput, source) {
 		rawInput = sourceTransform(rawInput);
 	}
 
-	if (def.applyRawProps(rawInput)) {
+	if (def.applyProps(rawInput)) {
 		return def;
 	}
 

+ 1 - 1
src/models/event/EventDefMutation.js

@@ -28,7 +28,7 @@ var EventDefMutation = FC.EventDefMutation = Class.extend({
 
 		// can't undo
 		if (this.rawProps) {
-			eventDef.applyRawProps(this.rawProps);
+			eventDef.applyProps(this.rawProps);
 		}
 
 		if (origDateProfile) {

+ 3 - 3
src/models/event/RecurringEventDef.js

@@ -88,8 +88,8 @@ var RecurringEventDef = EventDef.extend({
 	/*
 	NOTE: if super-method fails, should still attempt to apply
 	*/
-	applyRawProps: function(rawProps) {
-		var superSuccess = EventDef.prototype.applyRawProps.apply(this, arguments);
+	applyProps: function(rawProps) {
+		var superSuccess = EventDef.prototype.applyProps.apply(this, arguments);
 
 		if (rawProps.start) {
 			this.startTime = moment.duration(rawProps.start);
@@ -113,7 +113,7 @@ var RecurringEventDef = EventDef.extend({
 // ---------------------------------------------------------------------------------------------------------------------
 
 
-RecurringEventDef.allowRawProps({ // false = manually process
+RecurringEventDef.defineStandardProps({ // false = manually process
 	start: false,
 	end: false,
 	dow: false

+ 3 - 3
src/models/event/SingleEventDef.js

@@ -49,8 +49,8 @@ var SingleEventDef = EventDef.extend({
 	/*
 	NOTE: if super-method fails, should still attempt to apply
 	*/
-	applyManualRawProps: function(rawProps) {
-		var superSuccess = EventDef.prototype.applyManualRawProps.apply(this, arguments);
+	applyManualStandardProps: function(rawProps) {
+		var superSuccess = EventDef.prototype.applyManualStandardProps.apply(this, arguments);
 		var dateProfile = EventDateProfile.parse(rawProps, this.source); // returns null on failure
 
 		if (dateProfile) {
@@ -75,7 +75,7 @@ var SingleEventDef = EventDef.extend({
 // ---------------------------------------------------------------------------------------------------------------------
 
 
-SingleEventDef.allowRawProps({ // false = manually process
+SingleEventDef.defineStandardProps({ // false = manually process
 	start: false,
 	date: false, // alias for 'start'
 	end: false,