added reshare to mobile site
This commit is contained in:
parent
56f5efc373
commit
1d818fdc23
8 changed files with 109 additions and 50 deletions
|
|
@ -1,6 +1,6 @@
|
|||
class ResharesController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
respond_to :js
|
||||
respond_to :js, :json
|
||||
|
||||
def create
|
||||
@reshare = current_user.build_post(:reshare, :root_guid => params[:root_guid])
|
||||
|
|
|
|||
|
|
@ -17,6 +17,17 @@
|
|||
|
||||
.bottom_bar
|
||||
.floater
|
||||
|
||||
- if (post.public? || reshare?(post)) && post.author != current_user.person
|
||||
|
||||
- if reshare?(post)
|
||||
- root = post.root
|
||||
- else
|
||||
- root = post
|
||||
|
||||
- reshare = Reshare.where(:author_id => current_user.person.id, :root_guid => root.guid).first ? "active" : "inactive"
|
||||
= link_to '', reshares_path(:root_guid => root.guid), :title => t('reshares.reshare.reshare_confirmation', :author => root.author.name), :class => "image_link reshare_action #{reshare}"
|
||||
|
||||
= link_to '', new_post_comment_path(post), :class => "image_link comment_action inactive"
|
||||
|
||||
- if current_user && current_user.liked?(post)
|
||||
|
|
@ -33,6 +44,10 @@
|
|||
- if defined?(expanded_info) && expanded_info
|
||||
.comment_container
|
||||
.post_stats
|
||||
- if @post.public?
|
||||
%span.comment_count
|
||||
= @post.reshares.size
|
||||
|
||||
%span.comment_count
|
||||
= @post.comments.size
|
||||
|
||||
|
|
|
|||
9
db/migrate/20111003232053_add_index_for_reshares.rb
Normal file
9
db/migrate/20111003232053_add_index_for_reshares.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class AddIndexForReshares < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_index :posts, [:author_id, :root_guid], :unique => true
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :posts, :column => [:author_id, :root_guid]
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20111002013921) do
|
||||
ActiveRecord::Schema.define(:version => 20111003232053) do
|
||||
|
||||
create_table "aspect_memberships", :force => true do |t|
|
||||
t.integer "aspect_id", :null => false
|
||||
|
|
@ -285,6 +285,7 @@ ActiveRecord::Schema.define(:version => 20111002013921) do
|
|||
t.integer "comments_count", :default => 0
|
||||
end
|
||||
|
||||
add_index "posts", ["author_id", "root_guid"], :name => "index_posts_on_author_id_and_root_guid", :unique => true
|
||||
add_index "posts", ["author_id"], :name => "index_posts_on_person_id"
|
||||
add_index "posts", ["guid"], :name => "index_posts_on_guid", :unique => true
|
||||
add_index "posts", ["root_guid"], :name => "index_posts_on_root_guid"
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 764 B |
BIN
public/images/icons/reshare_mobile_active.png
Normal file
BIN
public/images/icons/reshare_mobile_active.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 761 B |
|
|
@ -1,5 +1,15 @@
|
|||
$(document).ready(function(){
|
||||
|
||||
var showLoader = function(link){
|
||||
link.addClass('loading');
|
||||
};
|
||||
|
||||
var removeLoader = function(link){
|
||||
link.removeClass('loading')
|
||||
.toggleClass('active')
|
||||
.toggleClass('inactive');
|
||||
};
|
||||
|
||||
/* Heart toggle */
|
||||
$(".like_action", ".stream").bind("tap click", function(evt){
|
||||
evt.preventDefault();
|
||||
|
|
@ -7,48 +17,68 @@ $(document).ready(function(){
|
|||
likeCounter = $(this).closest(".stream_element").find("like_count"),
|
||||
href = link.attr("href");
|
||||
|
||||
var showLoader = function(link){
|
||||
link.addClass('loading');
|
||||
};
|
||||
if(!link.hasClass("loading")){
|
||||
if(link.hasClass('inactive')) {
|
||||
$.ajax({
|
||||
url: href,
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
beforeSend: showLoader(link),
|
||||
success: function(data){
|
||||
removeLoader(link);
|
||||
link.attr("href", href + "/" + data["id"]);
|
||||
|
||||
var removeLoader = function(link){
|
||||
link.removeClass('loading')
|
||||
.toggleClass('active')
|
||||
.toggleClass('inactive');
|
||||
};
|
||||
|
||||
if(!link.hasClass("loading") && link.hasClass('inactive')) {
|
||||
|
||||
$.ajax({
|
||||
url: href,
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
beforeSend: showLoader(link),
|
||||
success: function(data){
|
||||
removeLoader(link);
|
||||
link.attr("href", href + "/" + data["id"]);
|
||||
|
||||
if(likeCounter){
|
||||
likeCounter.text(parseInt(likeCounter.text) + 1);
|
||||
if(likeCounter){
|
||||
likeCounter.text(parseInt(likeCounter.text) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else if(link.hasClass("active")){
|
||||
$.ajax({
|
||||
url: link.attr("href"),
|
||||
dataType: 'json',
|
||||
type: 'DELETE',
|
||||
beforeSend: showLoader(link),
|
||||
complete: function(data){
|
||||
removeLoader(link);
|
||||
link.attr("href", href.replace(/\/\d+$/, ''));
|
||||
|
||||
if(likeCounter){
|
||||
likeCounter.text(parseInt(likeCounter.text) - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if(!link.hasClass("loading") && link.hasClass("active")){
|
||||
$.ajax({
|
||||
url: link.attr("href"),
|
||||
dataType: 'json',
|
||||
type: 'DELETE',
|
||||
beforeSend: showLoader(link),
|
||||
complete: function(data){
|
||||
removeLoader(link);
|
||||
link.attr("href", href.replace(/\/\d+$/, ''));
|
||||
});
|
||||
|
||||
if(likeCounter){
|
||||
likeCounter.text(parseInt(likeCounter.text) - 1);
|
||||
}
|
||||
/* Reshare */
|
||||
$(".reshare_action", ".stream").bind("tap click", function(evt){
|
||||
evt.preventDefault();
|
||||
|
||||
var link = $(this),
|
||||
href = link.attr("href"),
|
||||
confirmText = link.attr('title');
|
||||
|
||||
if(!link.hasClass("loading")) {
|
||||
if(link.hasClass('inactive')) {
|
||||
if(confirm(confirmText)) {
|
||||
$.ajax({
|
||||
url: href + "&provider_display_name=mobile",
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
beforeSend: showLoader(link),
|
||||
success: function(data){
|
||||
removeLoader(link);
|
||||
},
|
||||
error: function(data){
|
||||
removeLoader(link);
|
||||
alert("Failed to reshare!");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -614,28 +614,32 @@ footer {
|
|||
width: 24px;
|
||||
padding: 5px;
|
||||
margin: {
|
||||
left: 5px; }; }
|
||||
left: 5px; };
|
||||
|
||||
.like_action {
|
||||
&.inactive{
|
||||
background-image: url("/images/icons/heart_mobile_grey.png");
|
||||
}
|
||||
&.active {
|
||||
background-image: url("/images/icons/heart_mobile_red.png");
|
||||
}
|
||||
&.loading {
|
||||
background-image: url("/images/mobile-spinner.gif");
|
||||
}
|
||||
}
|
||||
|
||||
.reshare_action {
|
||||
background-image: url("/images/icons/reshare_mobile.png");
|
||||
&.active {
|
||||
background-image: url("/images/icons/reshare_mobile_active.png");
|
||||
}
|
||||
}
|
||||
|
||||
.like_action {
|
||||
background-image: url("/images/icons/heart_mobile_grey.png");
|
||||
&.active {
|
||||
background-image: url("/images/icons/heart_mobile_red.png");
|
||||
}
|
||||
}
|
||||
|
||||
.comment_action.image_link {
|
||||
background-image: url("/images/icons/pencil_mobile_grey_active.png");
|
||||
&.inactive {
|
||||
background-image: url("/images/icons/pencil_mobile_grey.png");
|
||||
}
|
||||
&.loading {
|
||||
background-image: url("/images/mobile-spinner.gif");
|
||||
}
|
||||
}
|
||||
|
||||
.compose_icon {
|
||||
|
|
|
|||
Loading…
Reference in a new issue