using two less delegates in mobilejs; made some partials for mobile stream elements for sanity's sake
This commit is contained in:
parent
164b395f06
commit
9672c27232
7 changed files with 90 additions and 103 deletions
|
|
@ -21,7 +21,7 @@ class LikesController < ApplicationController
|
||||||
format.js { render 'likes/update', :status => 201 }
|
format.js { render 'likes/update', :status => 201 }
|
||||||
format.html { render :nothing => true, :status => 201 }
|
format.html { render :nothing => true, :status => 201 }
|
||||||
format.mobile { redirect_to post_path(@like.post_id) }
|
format.mobile { redirect_to post_path(@like.post_id) }
|
||||||
format.json { render :nothing => true, :status => 201 }
|
format.json { render :json => {"id" => @like.id}, :status => 201 }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :nothing => true, :status => 422
|
render :nothing => true, :status => 422
|
||||||
|
|
|
||||||
|
|
@ -4,33 +4,10 @@
|
||||||
|
|
||||||
.reshare
|
.reshare
|
||||||
- if post
|
- if post
|
||||||
.photo_area
|
= render 'shared/photo_area', :post => post
|
||||||
- if post.is_a?(StatusMessage)
|
|
||||||
-if post.photos.size > 0
|
|
||||||
.photo_attachments
|
|
||||||
- if post.photos.size > 1
|
|
||||||
.additional_photo_count
|
|
||||||
= "+ #{post.photos.size-1}"
|
|
||||||
= image_tag post.photos.first.url(:thumb_large), :class => "stream-photo big-stream-photo"
|
|
||||||
- elsif post.activity_streams?
|
|
||||||
= image_tag post.image_url
|
|
||||||
|
|
||||||
.content
|
.content
|
||||||
.from
|
= render 'shared/post_info', :post => post
|
||||||
= person_image_link(post.author, :size => :thumb_small)
|
|
||||||
= person_link(post.author)
|
|
||||||
.info
|
|
||||||
%span.time{:integer => post.created_at.to_i}
|
|
||||||
= t('ago', :time => time_ago_in_words(post.created_at))
|
|
||||||
%span.via
|
|
||||||
- if post.activity_streams?
|
|
||||||
= t('shared.stream_element.via', :link => link_to("#{post.provider_display_name}", post.actor_url)).html_safe
|
|
||||||
–
|
|
||||||
%span.scope_scope
|
|
||||||
- if post.public?
|
|
||||||
= t('public')
|
|
||||||
- else
|
|
||||||
= t('limited')
|
|
||||||
|
|
||||||
- if !post.activity_streams?
|
- if !post.activity_streams?
|
||||||
= render 'status_messages/status_message', :post => post, :photos => post.photos
|
= render 'status_messages/status_message', :post => post, :photos => post.photos
|
||||||
|
|
|
||||||
15
app/views/shared/_photo_area.mobile.haml
Normal file
15
app/views/shared/_photo_area.mobile.haml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
.photo_area
|
||||||
|
- if post.is_a?(StatusMessage)
|
||||||
|
-if post.photos.size > 0
|
||||||
|
.photo_attachments
|
||||||
|
- if post.photos.size > 1
|
||||||
|
.additional_photo_count
|
||||||
|
= "+ #{post.photos.size-1}"
|
||||||
|
= image_tag post.photos.first.url(:thumb_large), :class => "stream-photo big-stream-photo"
|
||||||
|
- elsif post.activity_streams?
|
||||||
|
= image_tag post.image_url
|
||||||
|
|
||||||
23
app/views/shared/_post_info.mobile.haml
Normal file
23
app/views/shared/_post_info.mobile.haml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
.from
|
||||||
|
= person_image_link(post.author, :size => :thumb_small)
|
||||||
|
= person_link(post.author)
|
||||||
|
.info
|
||||||
|
%span.time{:integer => post.created_at.to_i}
|
||||||
|
= t('ago', :time => time_ago_in_words(post.created_at))
|
||||||
|
%span.via
|
||||||
|
- if post.activity_streams?
|
||||||
|
= t('shared.stream_element.via', :link => link_to("#{post.provider_display_name}", post.actor_url)).html_safe
|
||||||
|
- elsif post.provider_display_name == 'mobile'
|
||||||
|
= t('shared.stream_element.via', :link => nil)
|
||||||
|
mobile
|
||||||
|
–
|
||||||
|
%span.scope_scope
|
||||||
|
- if post.public?
|
||||||
|
= t('public')
|
||||||
|
- else
|
||||||
|
= t('limited')
|
||||||
|
|
||||||
|
|
@ -7,38 +7,10 @@
|
||||||
- if post.is_a?(Reshare)
|
- if post.is_a?(Reshare)
|
||||||
= render 'reshares/reshare', :reshare => post, :post => post.root
|
= render 'reshares/reshare', :reshare => post, :post => post.root
|
||||||
|
|
||||||
.photo_area
|
= render 'shared/photo_area', :post => post
|
||||||
- if post.is_a?(StatusMessage)
|
|
||||||
-if post.photos.size > 0
|
|
||||||
.photo_attachments
|
|
||||||
- if post.photos.size > 1
|
|
||||||
.additional_photo_count
|
|
||||||
= "+ #{post.photos.size-1}"
|
|
||||||
= image_tag post.photos.first.url(:thumb_large), :class => "stream-photo big-stream-photo"
|
|
||||||
- elsif post.activity_streams?
|
|
||||||
= image_tag post.image_url
|
|
||||||
|
|
||||||
.content
|
.content
|
||||||
.from
|
= render 'shared/post_info', :post => post
|
||||||
= person_image_link(post.author, :size => :thumb_small)
|
|
||||||
= person_link(post.author)
|
|
||||||
.info
|
|
||||||
%span.time{:integer => post.created_at.to_i}
|
|
||||||
= t('ago', :time => time_ago_in_words(post.created_at))
|
|
||||||
%span.via
|
|
||||||
- if post.activity_streams?
|
|
||||||
= t('.via', :link => link_to("#{post.provider_display_name}", post.actor_url)).html_safe
|
|
||||||
- elsif post.provider_display_name == 'mobile'
|
|
||||||
= t('.via', :link => nil)
|
|
||||||
mobile
|
|
||||||
|
|
||||||
–
|
|
||||||
%span.scope_scope
|
|
||||||
- if post.public?
|
|
||||||
= t('public')
|
|
||||||
- else
|
|
||||||
= t('limited')
|
|
||||||
|
|
||||||
|
|
||||||
- if post.is_a?(StatusMessage)
|
- if post.is_a?(StatusMessage)
|
||||||
= render 'status_messages/status_message', :post => post, :photos => post.photos
|
= render 'status_messages/status_message', :post => post, :photos => post.photos
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,59 @@
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$(".stream").delegate(".like_action.inactive", "tap click", function(evt){
|
|
||||||
|
/* Heart toggle */
|
||||||
|
$(".like_action", ".stream").bind("tap click", function(evt){
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
var link = $(this),
|
var link = $(this),
|
||||||
likeCounter = $(this).closest(".stream_element").find("like_count"),
|
likeCounter = $(this).closest(".stream_element").find("like_count"),
|
||||||
postId = link.closest(".stream_element").data("post-guid");
|
href = link.attr("href");
|
||||||
|
|
||||||
|
var showLoader = function(link){
|
||||||
|
link.addClass('loading');
|
||||||
|
};
|
||||||
|
|
||||||
|
var removeLoader = function(link){
|
||||||
|
link.removeClass('loading')
|
||||||
|
.toggleClass('active')
|
||||||
|
.toggleClass('inactive');
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!link.hasClass("loading") && link.hasClass('inactive')) {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: link.attr("href"),
|
url: href,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
beforeSend: function(){
|
beforeSend: showLoader(link),
|
||||||
link.removeClass('inactive')
|
success: function(data){
|
||||||
.addClass('loading');
|
removeLoader(link);
|
||||||
},
|
link.attr("href", href + "/" + data["id"]);
|
||||||
complete: function(data){
|
|
||||||
link.removeClass('loading')
|
|
||||||
.removeClass('inactive')
|
|
||||||
.addClass('active')
|
|
||||||
.data('post-id', postId);
|
|
||||||
|
|
||||||
if(likeCounter){
|
if(likeCounter){
|
||||||
likeCounter.text(parseInt(likeCounter.text) + 1);
|
likeCounter.text(parseInt(likeCounter.text) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
else if(!link.hasClass("loading") && link.hasClass("active")){
|
||||||
$(".stream").delegate(".like_action.active", "tap click", function(evt){
|
|
||||||
evt.preventDefault();
|
|
||||||
var link = $(this);
|
|
||||||
likeCounter = $(this).closest(".stream_element").find("like_count");
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: link.attr("href"),
|
url: link.attr("href"),
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
beforeSend: function(){
|
beforeSend: showLoader(link),
|
||||||
link.removeClass('active')
|
|
||||||
.addClass('loading');
|
|
||||||
},
|
|
||||||
complete: function(data){
|
complete: function(data){
|
||||||
link.removeClass('loading')
|
removeLoader(link);
|
||||||
.removeClass('active')
|
link.attr("href", href.replace(/\/\d+$/, ''));
|
||||||
.addClass('inactive')
|
|
||||||
.data('like-id', '');
|
|
||||||
|
|
||||||
if(likeCounter){
|
if(likeCounter){
|
||||||
likeCounter.text(parseInt(likeCounter.text) - 1);
|
likeCounter.text(parseInt(likeCounter.text) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".stream").delegate(".show_comments", "tap click", function(evt){
|
/* Show comments */
|
||||||
|
$(".show_comments", ".stream").bind("tap click", function(evt){
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
var link = $(this),
|
var link = $(this),
|
||||||
parent = link.closest(".bottom_bar").first(),
|
parent = link.closest(".bottom_bar").first(),
|
||||||
|
|
|
||||||
|
|
@ -630,7 +630,6 @@ footer {
|
||||||
|
|
||||||
.comment_action.image_link {
|
.comment_action.image_link {
|
||||||
background-image: url("/images/icons/pencil_mobile_grey_active.png");
|
background-image: url("/images/icons/pencil_mobile_grey_active.png");
|
||||||
|
|
||||||
&.inactive {
|
&.inactive {
|
||||||
background-image: url("/images/icons/pencil_mobile_grey.png");
|
background-image: url("/images/icons/pencil_mobile_grey.png");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue