fixed ajax for likes
This commit is contained in:
parent
6deb924c32
commit
f2f14c2894
7 changed files with 87 additions and 21 deletions
|
|
@ -45,8 +45,9 @@
|
|||
|
||||
%body
|
||||
%header
|
||||
= link_to(image_tag('icons/compose_mobile2.png', :height => 28, :width => 28), new_status_message_path, :class => 'compose_icon')
|
||||
= link_to(image_tag('white@2x.png', :height => 20, :width => 127, :id => 'header_title'), aspects_path)
|
||||
- if user_signed_in?
|
||||
= link_to(image_tag('icons/compose_mobile2.png', :height => 28, :width => 28), new_status_message_path, :class => 'compose_icon')
|
||||
|
||||
- if flash.present?
|
||||
%p
|
||||
|
|
|
|||
|
|
@ -7,16 +7,11 @@
|
|||
- if post
|
||||
.content
|
||||
.from
|
||||
= person_link(post.author, :class => "hovercardable")
|
||||
= person_link(post.author)
|
||||
|
||||
- if post.activity_streams?
|
||||
= link_to image_tag(post.image_url, 'data-small-photo' => post.image_url, 'data-full-photo' => post.image_url, :class => 'stream-photo'), post.object_url, :class => "stream-photo-link"
|
||||
- else
|
||||
= render 'status_messages/status_message', :post => post, :photos => post.photos
|
||||
- if defined?(current_user) && current_user && (post.author_id != current_user.person.id) && (post.public?) && !reshare?(post)
|
||||
.reshare_action
|
||||
= reshare_link(post)
|
||||
= link_to t(".show_original"), post_path(post)
|
||||
|
||||
- else
|
||||
= t('.deleted')
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
= form_for StatusMessage.new, {:data => {:ajax => false}} do |status|
|
||||
= form_for StatusMessage.new, {:data => {:ajax => false}} do |status|
|
||||
= status.text_area :text, :placeholder => t('.whats_on_your_mind'), :style => "width:300px", :rows => 4
|
||||
|
||||
- for aspect_id in aspect_ids
|
||||
|
|
|
|||
|
|
@ -49,8 +49,9 @@ javascripts:
|
|||
#- public/javascripts/diaspora.js
|
||||
#- public/javascripts/helpers/i18n.js
|
||||
#- public/javascripts/widgets/infinite-scroll.js
|
||||
#- public/javascripts/rails.js
|
||||
- public/javascripts/rails.js
|
||||
- public/javascripts/vendor/mbp-helper.js
|
||||
- public/javascripts/mobile.js
|
||||
|
||||
mailchimp:
|
||||
- public/javascripts/vendor/mailchimp/jquery.form.js
|
||||
|
|
|
|||
BIN
public/images/mobile-spinner.gif
Normal file
BIN
public/images/mobile-spinner.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
46
public/javascripts/mobile.js
Normal file
46
public/javascripts/mobile.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
$(document).ready(function(){
|
||||
$(".like_action.inactive").live('tap click', function(evt){
|
||||
evt.preventDefault();
|
||||
var target = $(this),
|
||||
postId = target.data('post-id');
|
||||
|
||||
$.ajax({
|
||||
url: '/posts/'+postId+'/likes.json',
|
||||
type: 'POST',
|
||||
beforeSend: function(){
|
||||
target.removeClass('inactive')
|
||||
.addClass('loading');
|
||||
},
|
||||
complete: function(data){
|
||||
target.removeClass('loading')
|
||||
.removeClass('inactive')
|
||||
.addClass('active')
|
||||
.data('post-id', postId);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".like_action.active").live('tap click', function(evt){
|
||||
evt.preventDefault();
|
||||
var target = $(this),
|
||||
postId = $(this).data('post-id'),
|
||||
likeId = $(this).data('like-id');
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: '/posts/'+postId+'/likes/'+likeId+'.json',
|
||||
type: 'DELETE',
|
||||
beforeSend: function(){
|
||||
target.removeClass('active')
|
||||
.addClass('loading')
|
||||
.fadeIn(50);
|
||||
},
|
||||
complete: function(data){
|
||||
target.removeClass('loading')
|
||||
.removeClass('active')
|
||||
.addClass('inactive')
|
||||
.data('like-id', '');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -40,6 +40,16 @@ body {
|
|||
left: 2px; };
|
||||
}
|
||||
|
||||
#main {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stream {
|
||||
text-align: left;
|
||||
max-width: 700px;
|
||||
}
|
||||
|
||||
|
||||
.stream_element,
|
||||
.comments {
|
||||
overflow: auto;
|
||||
|
|
@ -106,12 +116,9 @@ body {
|
|||
@include border-radius(3px);
|
||||
@include box-shadow(0, 1px, 5px, rgba(0, 0, 0, 1));
|
||||
background: {
|
||||
color: white; };
|
||||
color: #fff; };
|
||||
border: {
|
||||
top: 1px solid black;
|
||||
bottom: 1px solid black; };
|
||||
|
||||
max-width: 700px;
|
||||
}
|
||||
|
||||
.photo_attachments {
|
||||
|
|
@ -129,12 +136,8 @@ body {
|
|||
padding: {
|
||||
left: 15px;
|
||||
top: 10px; };
|
||||
.from {
|
||||
font: {
|
||||
style: italic; }; } }
|
||||
.reshare_action {
|
||||
font: {
|
||||
size: 0.8em; }; } }
|
||||
}
|
||||
}
|
||||
|
||||
#main_stream {
|
||||
font: {
|
||||
|
|
@ -310,9 +313,17 @@ footer {
|
|||
left: 5px; }; }
|
||||
|
||||
.like_action {
|
||||
background-image: url("/images/icons/heart_mobile_grey.png");
|
||||
&.inactive{
|
||||
background-image: url("/images/icons/heart_mobile_grey.png");
|
||||
}
|
||||
&.active {
|
||||
background-image: url("/images/icons/heart_mobile_red.png"); } }
|
||||
background-image: url("/images/icons/heart_mobile_red.png");
|
||||
}
|
||||
|
||||
&.loading {
|
||||
background-image: url("/images/mobile-spinner.gif");
|
||||
}
|
||||
}
|
||||
|
||||
.comment_action {
|
||||
background-image: url("/images/icons/pencil_mobile_grey.png"); }
|
||||
|
|
@ -329,3 +340,15 @@ form {
|
|||
top: 6px;
|
||||
right: 15px;
|
||||
}
|
||||
|
||||
#new_status_message {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 45px;
|
||||
width:100%;
|
||||
|
||||
textarea {
|
||||
@include border-radius(0);
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue