diaspora/public/javascripts/app/views/post_view.js
Dennis Collinson 6288eff599 day mood for a post responds to content
extract creating a post with templates to a static post view method.

Legacy templates extracted, day view

day mood shows photos and has variable text size
2012-03-27 14:54:27 -07:00

44 lines
No EOL
1.2 KiB
JavaScript

app.views.Post = app.views.StreamObject.extend({
presenter : function() {
return _.extend(this.defaultPresenter(), {
authorIsCurrentUser : this.authorIsCurrentUser(),
showPost : this.showPost(),
text : app.helpers.textFormatter(this.model)
})
},
authorIsCurrentUser : function() {
return app.currentUser.authenticated() && this.model.get("author").id == app.user().id
},
showPost : function() {
return (app.currentUser.get("showNsfw")) || !this.model.get("nsfw")
}
}, { //static methods below
showFactory : function(model) {
var frameName = model.get("frame_name");
if(_.include(app.models.Post.legacyTemplateNames, frameName)){
return legacyShow(model)
} else {
return new app.views.Post[frameName]({
model : model
})
}
function legacyShow(model) {
return new app.views.Post.Legacy({
model : model,
className : frameName + " post loaded",
templateName : "post-viewer/content/" + frameName
});
}
}
});
app.views.Post.Legacy = app.views.Post.extend({
initialize : function(options) {
this.templateName = options.templateName || this.templateName
}
})