pjax clicking on nav arrows; move author header into backbone land; comment out comment form for now

This commit is contained in:
danielgrippi 2012-02-19 22:08:33 -08:00
parent ca8e8ac0c2
commit f31418feb3
4 changed files with 56 additions and 37 deletions

View file

@ -23,7 +23,7 @@ class PostsController < ApplicationController
end
if @post
@commenting_disabled = can_not_comment_on_post?
# @commenting_disabled = can_not_comment_on_post?
# mark corresponding notification as read
if user_signed_in? && notification = Notification.where(:recipient_id => current_user.id, :target_id => @post.id).first
notification.unread = false

View file

@ -5,43 +5,27 @@
- content_for :page_title do
= post_page_title @post
- content_for :head do
= javascript_include_tag 'vendor/bootstrap/bootstrap-transition', 'vendor/bootstrap/bootstrap-modal'
.header
.header-container
#post-author.media
.img
= person_image_link @post.author
.bd
= person_link(@post.author, :class => 'author-name')
- if @post.is_a?(Reshare) && @post.root.present?
%i.icon-retweet
= person_link(@post.root.author, :class => "author-name")
.post-time
%i.icon-time
= time_ago_in_words(@post.created_at) + ' ago'
/- content_for :head do
/ = javascript_include_tag 'vendor/bootstrap/bootstrap-transition', 'vendor/bootstrap/bootstrap-modal'
#container
#comment.modal.fade
.modal-header
%h3
Responses
-# #comment.modal.fade
-# .modal-header
-# %h3
-# Responses
.modal-body
- @post.comments.each do |c|
.media
.img
= person_image_link c.author
.bd
%strong= person_link(c.author)
%br
= c.text
.modal-footer
= form_tag comments_path, :remote => true do
= text_area_tag :text, '', :class => 'span6'
= hidden_field_tag :post_id, @post.id
= submit_tag 'submit', :onclick => "$('#comment').modal('hide'); $('#text').text('')"
-# .modal-body
-# - @post.comments.each do |c|
-# .media
-# .img
-# = person_image_link c.author
-# .bd
-# %strong= person_link(c.author)
-# %br
-# = c.text
-# .modal-footer
-# = form_tag comments_path, :remote => true do
-# = text_area_tag :text, '', :class => 'span6'
-# = hidden_field_tag :post_id, @post.id
-# = submit_tag 'submit', :onclick => "$('#comment').modal('hide'); $('#text').text('')"

View file

@ -1,3 +1,29 @@
<!-- header to be extracted -->
<div class="header">
<div class="header-container">
<div id="post-author" class="media">
<div class="img">
<a href="/people/{{author.guid}}" class="author-name">
<img src="{{author.avatar.small}}" class="avatar"/>
</a>
</div>
<div class="bd">
<a href="/people/{{author.guid}}" class="author-name">
{{author.name}}
</a>
<div class="post-time">
<i class="icon-time"></i>
{{created_at}}
</div>
</div>
</div>
</div>
</div>
<div id="post-content"></div>
<div id="post-nav"></div>
<div id="post-feedback"></div>

View file

@ -2,6 +2,10 @@ app.views.PostViewerNav = app.views.Base.extend({
templateName: "post-viewer/nav",
events : {
"click a" : "pjax"
},
postRenderTemplate : function() {
var mappings = {"#forward" : "next_post",
"#back" : "previous_post"};
@ -13,6 +17,11 @@ app.views.PostViewerNav = app.views.Base.extend({
setArrow : function(arrow, loc) {
loc ? arrow.attr('href', loc) : arrow.remove()
},
pjax : function(evt) {
if(evt) { evt.preventDefault(); }
app.router.navigate($(evt.target).attr("href").substring(1), true)
}
})