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 ...@@ -6,7 +6,7 @@ class CommentsController < ApplicationController
include ApplicationHelper include ApplicationHelper
before_filter :authenticate_user! before_filter :authenticate_user!
respond_to :html, :mobile, :only => [:new, :create, :destroy, :index] respond_to :html, :mobile, :except => :show
respond_to :js, :only => [:index] respond_to :js, :only => [:index]
rescue_from ActiveRecord::RecordNotFound do rescue_from ActiveRecord::RecordNotFound do
...@@ -28,7 +28,7 @@ class CommentsController < ApplicationController ...@@ -28,7 +28,7 @@ class CommentsController < ApplicationController
respond_to do |format| respond_to do |format|
format.js{ render(:create, :status => 201)} format.js{ render(:create, :status => 201)}
format.html{ render :nothing => true, :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 end
else else
render :nothing => true, :status => 422 render :nothing => true, :status => 422
...@@ -65,7 +65,6 @@ class CommentsController < ApplicationController ...@@ -65,7 +65,6 @@ class CommentsController < ApplicationController
end end
def new def new
puts params.inspect
render :layout => false render :layout => false
end end
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# 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}" = 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}" = text_area_tag :text, nil, :rows => 2, :class => "comment_box",:id => "comment_text_on_#{post_id}"
......
%ul.comments .comment_container
= render :partial => 'comments/comment', :collection => @comments, :locals => {:post => @post} .post_stats
%span.comment_count
= @post.comments.size
%li.comment.add_comment_bottom_link_container %span.like_count
= link_to "Add a comment", new_post_comment_path(@post), :class => 'add_comment_bottom_link btn comment_action inactive' = @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 @@ ...@@ -2,9 +2,10 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
= render :partial => 'shared/stream_element', .stream
:locals => {:post => @post, :commenting_disabled => defined?(@commenting_disabled), = render :partial => 'shared/stream_element',
:expanded_info => true} :locals => {:post => @post, :commenting_disabled => defined?(@commenting_disabled),
:expanded_info => true}
/.stream.show{:data=>{:guid=>@post.id}} /.stream.show{:data=>{:guid=>@post.id}}
/ = render "comments/comments", :post => @post, :comments => @post.comments, :comments_expanded => true / = render "comments/comments", :post => @post, :comments => @post.comments, :comments_expanded => true
...@@ -10,17 +10,18 @@ ...@@ -10,17 +10,18 @@
= hidden_field_tag 'aspect_ids[]', aspect_id.to_s = hidden_field_tag 'aspect_ids[]', aspect_id.to_s
%fieldset %fieldset
- unless aspect == :all %div{:style => 'float:right;'}
%input{:type => 'checkbox', :name => 'status_message[public]', :id => 'public', :class => 'custom', :value => 'true'} = select_tag 'aspect_ids[]', options_from_collection_for_select(current_user.aspects, "id", "name")
%label{:for => 'public'} /%input{:type => 'checkbox', :name => 'status_message[public]', :id => 'public', :class => 'custom', :value => 'true'}
= t('.make_public') /%label{:for => 'public'}
- unless current_user.services.empty? / = t('.make_public')
%div{:data => {:role => 'fieldcontain'}} - unless current_user.services.empty?
%label{:for => 'services', :class => 'select'} %div{:data => {:role => 'fieldcontain'}}
- current_user.services.each do |service| %label{:for => 'services', :class => 'select'}
%input{:type => 'checkbox', :name => "services[]", :id => "#{service.provider}", :class => 'custom', :value => "#{service.provider}"} - current_user.services.each do |service|
%label{:for => "#{service.provider}"} %input{:type => 'checkbox', :name => "services[]", :id => "#{service.provider}", :class => 'custom', :value => "#{service.provider}"}
= "#{service.provider}" %label{:for => "#{service.provider}"}
= "#{service.provider}"
= status.submit t('.share') = status.submit t('.share'), :class => 'action'
...@@ -43,3 +43,18 @@ ...@@ -43,3 +43,18 @@
%span.show_comments %span.show_comments
= "#{t('reactions', :count => (post.comments.length + post.likes_count))}" = "#{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(){ $(document).ready(function(){
$(".like_action.inactive").live('tap click', function(evt){ $(".like_action.inactive").live('tap click', function(evt){
evt.preventDefault(); 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({ $.ajax({
url: link.attr("href"), url: link.attr("href"),
...@@ -13,9 +15,13 @@ $(document).ready(function(){ ...@@ -13,9 +15,13 @@ $(document).ready(function(){
}, },
complete: function(data){ complete: function(data){
link.removeClass('loading') link.removeClass('loading')
.removeClass('inactive') .removeClass('inactive')
.addClass('active') .addClass('active')
.data('post-id', postId); .data('post-id', postId);
if(likeCounter){
likeCounter.text(parseInt(likeCounter.text) + 1);
}
} }
}); });
}); });
...@@ -23,6 +29,7 @@ $(document).ready(function(){ ...@@ -23,6 +29,7 @@ $(document).ready(function(){
$(".like_action.active").live('tap click', function(evt){ $(".like_action.active").live('tap click', function(evt){
evt.preventDefault(); evt.preventDefault();
var link = $(this); var link = $(this);
likeCounter = $(this).closest(".stream_element").find("like_count");
$.ajax({ $.ajax({
url: link.attr("href"), url: link.attr("href"),
...@@ -37,6 +44,10 @@ $(document).ready(function(){ ...@@ -37,6 +44,10 @@ $(document).ready(function(){
.removeClass('active') .removeClass('active')
.addClass('inactive') .addClass('inactive')
.data('like-id', ''); .data('like-id', '');
if(likeCounter){
likeCounter.text(parseInt(likeCounter.text) - 1);
}
} }
}); });
}); });
...@@ -45,7 +56,7 @@ $(document).ready(function(){ ...@@ -45,7 +56,7 @@ $(document).ready(function(){
evt.preventDefault(); evt.preventDefault();
var link = $(this), var link = $(this),
parent = link.closest(".bottom_bar").first(), parent = link.closest(".bottom_bar").first(),
commentsContainer = parent.find(".comments"); commentsContainer = parent.find(".comment_container");
if( link.hasClass('active') ) { if( link.hasClass('active') ) {
commentsContainer.first().hide(); commentsContainer.first().hide();
...@@ -80,13 +91,18 @@ $(document).ready(function(){ ...@@ -80,13 +91,18 @@ $(document).ready(function(){
link.addClass('loading'); link.addClass('loading');
}, },
success: function(data){ success: function(data){
var textarea = parent.find('textarea').first();
lineHeight = 14;
link.removeClass('loading') link.removeClass('loading')
.removeClass('inactive'); .removeClass('inactive');
container.first().hide(); container.first().hide();
parent.append(data); parent.append(data);
parent.find('textarea').first().focus();
textarea.focus();
new MBP.autogrow(textarea, lineHeight);
} }
}); });
} }
...@@ -106,4 +122,19 @@ $(document).ready(function(){ ...@@ -106,4 +122,19 @@ $(document).ready(function(){
commentActionLink.addClass("inactive"); commentActionLink.addClass("inactive");
form.remove(); 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 { ...@@ -84,7 +84,7 @@ body {
.stream_element .comments { .stream_element .comments {
padding: 0; padding: 0;
margin: 0; margin: 0;
margin-top: 18px; top: 8px;
width: 100%; width: 100%;
.content { .content {
padding: 0; padding: 0;
...@@ -278,6 +278,7 @@ footer { ...@@ -278,6 +278,7 @@ footer {
.bottom_bar { .bottom_bar {
@include border-radius(0, 0, 3px, 3px); @include border-radius(0, 0, 3px, 3px);
display: block; display: block;
position: relative;
padding: 10px; padding: 10px;
background: #eeeeee; background: #eeeeee;
margin: { margin: {
...@@ -306,6 +307,14 @@ footer { ...@@ -306,6 +307,14 @@ footer {
&.active { &.active {
color: #444; 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 { ...@@ -436,6 +445,7 @@ form {
} }
.btn, .btn,
select,
input[type=submit] { input[type=submit] {
@include border-radius(3px); @include border-radius(3px);
background-color: #ddd; background-color: #ddd;
...@@ -469,6 +479,22 @@ input[type=submit] { ...@@ -469,6 +479,22 @@ input[type=submit] {
.comment.add_comment_bottom_link_container { .comment.add_comment_bottom_link_container {
text-align: center; text-align: center;
padding: 15px !important; padding: 25px !important;
padding-top: 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