added as::photo view

This commit is contained in:
danielgrippi 2011-12-12 10:19:24 -08:00 committed by Dennis Collinson
parent 34e3403e2e
commit e6d4ec2dc8
5 changed files with 25 additions and 1 deletions

View file

@ -16,3 +16,6 @@
%script{:id => "reshare-template", :type => 'text/template'}
!= File.read("#{Rails.root}/app/views/templates/reshare.ujs")
%script{:id => "activity-streams-photo-template", :type => 'text/template'}
!= File.read("#{Rails.root}/app/views/templates/activity-streams-photo.ujs")

View file

@ -0,0 +1 @@
<img src="<%= image_url %>" />

View file

@ -22,3 +22,7 @@ App.Views.StatusMessage = App.Views.PostContent.extend({
App.Views.Reshare = App.Views.PostContent.extend({
template_name : "#reshare-template"
});
App.Views.ActivityStreams__Photo = App.Views.PostContent.extend({
template_name : "#activity-streams-photo-template"
});

View file

@ -25,7 +25,8 @@ App.Views.Post = Backbone.View.extend({
},
renderPostContent: function(){
var postClass = App.Views[this.model.get("post_type")] || App.Views.StatusMessage;
var normalizedClass = this.model.get("post_type").replace(/::/, "__");
var postClass = App.Views[normalizedClass] || App.Views.StatusMessage;
var postView = new postClass({ model : this.model });
this.$(".post-content").html(postView.render().el);

View file

@ -0,0 +1,15 @@
App.Views.Reshare = Backbone.View.extend({
initialize: function(options) {
this.model = options.model;
this.template = _.template($("#reshare-template").html());
},
render: function() {
this.el = $(this.template($.extend(
this.model.toJSON(),
App.user()
)));
return this;
}
});