diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 880ee4132..5096cb7fe 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -11,12 +11,22 @@ class PostPresenter def to_json(options = {}) { :post => self.post.as_api_response(:backbone).update( - { :next_post => next_post_url, - :previous_post => previous_post_url}), + { + :user_like => self.user_like, + :next_post => self.next_post_url, + :previous_post => self.previous_post_url + }), :templateName => TemplatePicker.new(self.post).template_name } end + def user_like + return unless self.current_user.present? + if like = Like.where(:target_id => self.post.id, :target_type => "Post", :author_id => current_user.person.id).first + like.as_api_response(:backbone) + end + end + def next_post_url if n = next_post Rails.application.routes.url_helpers.post_path(n) diff --git a/public/javascripts/app/pages/post-viewer.js b/public/javascripts/app/pages/post-viewer.js index 6ae7947f2..c91e5e182 100644 --- a/public/javascripts/app/pages/post-viewer.js +++ b/public/javascripts/app/pages/post-viewer.js @@ -32,16 +32,15 @@ app.pages.PostViewer = app.views.Base.extend({ setKeyMappings : function() { var nextPostLocation = this.model.get("next_post"); var previousPostLocation = this.model.get("previous_post"); - var doc = $(document); /* focus modal */ - doc.keypress(function(){ - $('#text').focus(); - $('#comment').modal(); - }); + // doc.keypress(function(){ + // $('#text').focus(); + // $('#comment').modal(); + // }); /* navagation hooks */ - doc.keydown(function(e){ + $(document).keydown(function(e){ if (e.keyCode == 37 && nextPostLocation) { window.location = nextPostLocation diff --git a/public/javascripts/app/templates/post-viewer/feedback.handlebars b/public/javascripts/app/templates/post-viewer/feedback.handlebars index a84c287b1..fa98a8c48 100644 --- a/public/javascripts/app/templates/post-viewer/feedback.handlebars +++ b/public/javascripts/app/templates/post-viewer/feedback.handlebars @@ -1,17 +1,21 @@ -
+{{/if}} + + + + diff --git a/public/javascripts/app/views/feedback_view.js b/public/javascripts/app/views/feedback_view.js index ab9679619..7b5cfd56f 100644 --- a/public/javascripts/app/views/feedback_view.js +++ b/public/javascripts/app/views/feedback_view.js @@ -1,4 +1,4 @@ -app.views.Feedback = app.views.StreamObject.extend({ +app.views.Feedback = app.views.Base.extend({ templateName: "feedback", diff --git a/public/javascripts/app/views/post_feedback_view.js b/public/javascripts/app/views/post_feedback_view.js index a707e058a..9c564e01a 100644 --- a/public/javascripts/app/views/post_feedback_view.js +++ b/public/javascripts/app/views/post_feedback_view.js @@ -1,33 +1,21 @@ -app.views.PostViewerFeedback = app.views.Base.extend({ +app.views.PostViewerFeedback = app.views.Feedback.extend({ + + id : "user-controls", + className : "", templateName: "post-viewer/feedback", events : { "click .like" : "toggleLike", "click .follow" : "toggleFollow", - "click .reshare" : "reshare", + "click .reshare" : "resharePost", "click .comment" : "comment" }, tooltipSelector : ".label", - toggleLike : function(evt) { - if(evt) { evt.preventDefault(); } - this.model.toggleLike() - }, - - toggleFollow : function(evt) { - if(evt) { evt.preventDefault(); } - this.model.toggleFollow() - }, - - reshare : function(evt) { - if(evt) { evt.preventDefault(); } - this.model.reshare(); - }, - comment : function(){ - alert('comment') + console.log(this.model) } }) diff --git a/public/javascripts/app/views/post_view.js b/public/javascripts/app/views/post_view.js index c3e96e19d..c92403899 100644 --- a/public/javascripts/app/views/post_view.js +++ b/public/javascripts/app/views/post_view.js @@ -24,7 +24,6 @@ app.views.Post = app.views.StreamObject.extend({ tooltipSelector : ".delete, .block_user, .post_scope", initialize : function(options) { - console.log(this.model.attributes) // allow for a custom template name to be passed in via the options hash this.templateName = options.templateName || this.templateName