Skip to content

Instantly share code, notes, and snippets.

@jasonbellamy
Last active October 10, 2015 21:57
Show Gist options
  • Save jasonbellamy/3756460 to your computer and use it in GitHub Desktop.
Save jasonbellamy/3756460 to your computer and use it in GitHub Desktop.
/**
* @name EventViewFactory
* @constructor
*/
var EventViewFactory = function() {
return {
/**
* @name create
* @description returns the instantiated view
* @param {String} type the event type
* @param {Object} options hash of options to be passed into the view before its instantiated
* @returns {Object} the instantiated view
*/
create: function( type, options ) {
var View = this.sort( type );
return new View( options );
},
/**
* @name sort
* @description sorts through the events and returns the corresponding view object
* @param {String} type the event type
* @returns {Object} Backbone view object
*/
sort: function( type ) {
var options = {
'profile.view' : FeedEventProfileView,
'favorite.send' : FeedEventFaveAddView,
'key.grant' : FeedEventGrantKeyView,
'key.request' : FeedEventRequestKeyView,
'enote.deliver' : FeedEventEnoteDeliverView,
'flirt.deliver' : FeedEventFlirtDeliverView,
'user.like' : FeedEventUserLikeView,
'fave.login' : FeedEventFaveLoginView,
'update_profile.nearby' : FeedEventUpdateProfileView,
'fave.image_upload' : FeedEventImageUploadView,
'registration.nearby' : FeedEventRegistrationView
};
return options[ type ] || FeedEventView;
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment