Last active
October 10, 2015 21:57
-
-
Save jasonbellamy/3756460 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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