Skip to content
Extraits de code Groupes Projets
Valider 744ab579 rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

adding comments work for one of two comment add buttons; added info on

posts; post show page.
parent 3b08fc84
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -6,7 +6,7 @@ class CommentsController < ApplicationController
include ApplicationHelper
before_filter :authenticate_user!
respond_to :html, :mobile, :only => [:new, :create, :destroy, :index]
respond_to :html, :mobile, :except => :show
respond_to :js, :only => [:index]
rescue_from ActiveRecord::RecordNotFound do
......@@ -28,7 +28,7 @@ class CommentsController < ApplicationController
respond_to do |format|
format.js{ render(:create, :status => 201)}
format.html{ render :nothing => true, :status => 201 }
format.mobile{ redirect_to post_url(@comment.post) }
format.mobile{ render :partial => 'comment', :locals => {:post => @comment.post, :comment => @comment} }
end
else
render :nothing => true, :status => 422
......@@ -65,7 +65,6 @@ class CommentsController < ApplicationController
end
def new
puts params.inspect
render :layout => false
end
end
......@@ -2,7 +2,7 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
= form_tag( post_comments_path(post_id), :id => "new_comment_on_#{post_id}", :class => 'new_comment', :remote => true) do
= form_tag( post_comments_path(post_id), :id => "new_comment_on_#{post_id}", :class => 'new_comment') do
= hidden_field_tag :post_id, post_id, :id => "post_id_on_#{post_id}"
= text_area_tag :text, nil, :rows => 2, :class => "comment_box",:id => "comment_text_on_#{post_id}"
......
%ul.comments
= render :partial => 'comments/comment', :collection => @comments, :locals => {:post => @post}
.comment_container
.post_stats
%span.comment_count
= @post.comments.size
%li.comment.add_comment_bottom_link_container
= link_to "Add a comment", new_post_comment_path(@post), :class => 'add_comment_bottom_link btn comment_action inactive'
%span.like_count
= @post.likes.size
%ul.comments
= render :partial => 'comments/comment', :collection => @comments, :locals => {:post => @post}
%li.comment.add_comment_bottom_link_container
= link_to "Add a comment", new_post_comment_path(@post), :class => 'add_comment_bottom_link btn comment_action inactive'
......@@ -2,9 +2,10 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
= render :partial => 'shared/stream_element',
:locals => {:post => @post, :commenting_disabled => defined?(@commenting_disabled),
:expanded_info => true}
.stream
= render :partial => 'shared/stream_element',
:locals => {:post => @post, :commenting_disabled => defined?(@commenting_disabled),
:expanded_info => true}
/.stream.show{:data=>{:guid=>@post.id}}
/ = render "comments/comments", :post => @post, :comments => @post.comments, :comments_expanded => true
......@@ -10,17 +10,18 @@
= hidden_field_tag 'aspect_ids[]', aspect_id.to_s
%fieldset
- unless aspect == :all
%input{:type => 'checkbox', :name => 'status_message[public]', :id => 'public', :class => 'custom', :value => 'true'}
%label{:for => 'public'}
= t('.make_public')
- unless current_user.services.empty?
%div{:data => {:role => 'fieldcontain'}}
%label{:for => 'services', :class => 'select'}
- current_user.services.each do |service|
%input{:type => 'checkbox', :name => "services[]", :id => "#{service.provider}", :class => 'custom', :value => "#{service.provider}"}
%label{:for => "#{service.provider}"}
= "#{service.provider}"
%div{:style => 'float:right;'}
= select_tag 'aspect_ids[]', options_from_collection_for_select(current_user.aspects, "id", "name")
/%input{:type => 'checkbox', :name => 'status_message[public]', :id => 'public', :class => 'custom', :value => 'true'}
/%label{:for => 'public'}
/ = t('.make_public')
- unless current_user.services.empty?
%div{:data => {:role => 'fieldcontain'}}
%label{:for => 'services', :class => 'select'}
- current_user.services.each do |service|
%input{:type => 'checkbox', :name => "services[]", :id => "#{service.provider}", :class => 'custom', :value => "#{service.provider}"}
%label{:for => "#{service.provider}"}
= "#{service.provider}"
= status.submit t('.share')
= status.submit t('.share'), :class => 'action'
......@@ -43,3 +43,18 @@
%span.show_comments
= "#{t('reactions', :count => (post.comments.length + post.likes_count))}"
- if defined?(expanded_info) && expanded_info
.comment_container
.post_stats
%span.comment_count
= @post.comments.size
%span.like_count
= @post.likes.size
%ul.comments
= render :partial => 'comments/comment', :collection => @comments, :locals => {:post => @post}
%li.comment.add_comment_bottom_link_container
= link_to "Add a comment", new_post_comment_path(@post), :class => 'add_comment_bottom_link btn comment_action inactive'
public/images/icons/arrow_down.png

837 octets

public/images/icons/arrow_down_small.png

455 octets

$(document).ready(function(){
$(".like_action.inactive").live('tap click', function(evt){
evt.preventDefault();
var link = $(this);
var link = $(this),
likeCounter = $(this).closest(".stream_element").find("like_count"),
postId = link.closest(".stream_element").data("post-guid");
$.ajax({
url: link.attr("href"),
......@@ -13,9 +15,13 @@ $(document).ready(function(){
},
complete: function(data){
link.removeClass('loading')
.removeClass('inactive')
.addClass('active')
.data('post-id', postId);
.removeClass('inactive')
.addClass('active')
.data('post-id', postId);
if(likeCounter){
likeCounter.text(parseInt(likeCounter.text) + 1);
}
}
});
});
......@@ -23,6 +29,7 @@ $(document).ready(function(){
$(".like_action.active").live('tap click', function(evt){
evt.preventDefault();
var link = $(this);
likeCounter = $(this).closest(".stream_element").find("like_count");
$.ajax({
url: link.attr("href"),
......@@ -37,6 +44,10 @@ $(document).ready(function(){
.removeClass('active')
.addClass('inactive')
.data('like-id', '');
if(likeCounter){
likeCounter.text(parseInt(likeCounter.text) - 1);
}
}
});
});
......@@ -45,7 +56,7 @@ $(document).ready(function(){
evt.preventDefault();
var link = $(this),
parent = link.closest(".bottom_bar").first(),
commentsContainer = parent.find(".comments");
commentsContainer = parent.find(".comment_container");
if( link.hasClass('active') ) {
commentsContainer.first().hide();
......@@ -80,13 +91,18 @@ $(document).ready(function(){
link.addClass('loading');
},
success: function(data){
var textarea = parent.find('textarea').first();
lineHeight = 14;
link.removeClass('loading')
.removeClass('inactive');
container.first().hide();
parent.append(data);
parent.find('textarea').first().focus();
textarea.focus();
new MBP.autogrow(textarea, lineHeight);
}
});
}
......@@ -106,4 +122,19 @@ $(document).ready(function(){
commentActionLink.addClass("inactive");
form.remove();
});
$(".new_comment").live("submit", function(evt){
evt.preventDefault();
var form = $(this);
$.post(form.attr('action')+"?format=mobile", form.serialize(), function(data){
var container = form.closest('.bottom_bar').find('.add_comment_bottom_link_container');
container.before(data);
form.remove();
container.show();
}, 'html');
});
});
......@@ -84,7 +84,7 @@ body {
.stream_element .comments {
padding: 0;
margin: 0;
margin-top: 18px;
top: 8px;
width: 100%;
.content {
padding: 0;
......@@ -278,6 +278,7 @@ footer {
.bottom_bar {
@include border-radius(0, 0, 3px, 3px);
display: block;
position: relative;
padding: 10px;
background: #eeeeee;
margin: {
......@@ -306,6 +307,14 @@ footer {
&.active {
color: #444;
padding: {
right: 14px;
}
background: {
image: url("/images/icons/arrow_down_small.png");
position: center right;
repeat: no-repeat;
}
}
}
......@@ -436,6 +445,7 @@ form {
}
.btn,
select,
input[type=submit] {
@include border-radius(3px);
background-color: #ddd;
......@@ -469,6 +479,22 @@ input[type=submit] {
.comment.add_comment_bottom_link_container {
text-align: center;
padding: 15px !important;
padding-top: 25px !important;
padding: 25px !important;
}
.post_stats {
position: absolute;
font-size: larger;
right: 11px;
top: 38px;
z-index: 2;
span {
color: #666;
font-weight: bold;
padding: 2px 7px;
margin: 5px 5px;
background: {
color: #eee;
}
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter