Merge pull request #1741 from ticho/hide-post-button-ajaxification
Show ajax spinner when hiding or unhiding a post in stream.
This commit is contained in:
commit
c39e8bb64f
5 changed files with 43 additions and 9 deletions
|
|
@ -1,3 +1,9 @@
|
|||
var target = $("#<%= @post.guid %>")
|
||||
target.find(".sm_body").toggleClass("hidden");
|
||||
target.find(".undo_text").toggleClass("hidden");
|
||||
target.find(".hide_loader").toggleClass("hidden");
|
||||
|
||||
var hide_icon = target.find(".stream_element_delete")
|
||||
if (target.find(".undo_text").hasClass("hidden")) {
|
||||
hide_icon.toggleClass("hidden");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@
|
|||
|
||||
|
||||
.stream_element{:id => post.guid}
|
||||
- if user_signed_in?
|
||||
- if post.author.owner_id == current_user.id
|
||||
.right.controls
|
||||
= link_to image_tag('deletelabel.png'), post_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete')
|
||||
.right.controls
|
||||
- if current_user && post.author.owner_id == current_user.id
|
||||
= link_to image_tag('deletelabel.png'), post_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete')
|
||||
- else
|
||||
.right.controls
|
||||
= link_to image_tag('deletelabel.png'), post_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete stream_element_delete", :title => t('hide')
|
||||
= link_to image_tag('deletelabel.png'), post_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete stream_element_delete vis_hide", :title => t('hide')
|
||||
= image_tag 'ajax-loader.gif', :class => "hide_loader hidden"
|
||||
|
||||
.undo_text.hidden
|
||||
= t('post_visibilites.update.post_hidden', :name => post.author.name)
|
||||
= link_to t('undo'), post_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete stream_element_delete"
|
||||
= link_to t('undo'), post_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete stream_element_hide_undo"
|
||||
|
||||
.sm_body
|
||||
= person_image_link(post.author, :size => :thumb_small)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ var Stream = {
|
|||
|
||||
Diaspora.widgets.subscribe("stream/scrolled", Stream.collapseText);
|
||||
Stream.collapseText('eventID', $(Stream.selector)[0]);
|
||||
Stream.bindHideIcon();
|
||||
},
|
||||
collapseText: function(){
|
||||
elements = $(Array.prototype.slice.call(arguments,1));
|
||||
|
|
@ -188,6 +189,16 @@ var Stream = {
|
|||
textarea.focus();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
bindHideIcon: function(){
|
||||
$("a.stream_element_delete.vis_hide").live("click", function(evt){
|
||||
$(this).toggleClass("hidden");
|
||||
$(this).next("img.hide_loader").toggleClass("hidden");
|
||||
});
|
||||
$("a.stream_element_hide_undo").live("click", function(evt){
|
||||
$(this).closest('.stream_element').find("img.hide_loader").toggleClass("hidden");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ describe AspectsController do
|
|||
end
|
||||
|
||||
it 'generates a jasmine fixture with posts', :fixture => true do
|
||||
bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.first.id)
|
||||
message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id)
|
||||
3.times { bob.comment("what", :post => message) }
|
||||
get :index
|
||||
|
|
|
|||
|
|
@ -40,6 +40,21 @@ describe("Stream", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("streamElement", function() {
|
||||
it("makes sure that ajax spinner appears when hiding a post", function() {
|
||||
Stream.bindHideIcon();
|
||||
link = $("a.stream_element_delete.vis_hide");
|
||||
spinner = link.next("img.hide_loader");
|
||||
expect(link).not.toHaveClass("hidden");
|
||||
expect(spinner).toHaveClass("hidden");
|
||||
spyOn($, "ajax");
|
||||
link.click();
|
||||
expect($.ajax).toHaveBeenCalled();
|
||||
expect(link).toHaveClass("hidden");
|
||||
expect(spinner).not.toHaveClass("hidden");
|
||||
});
|
||||
});
|
||||
|
||||
describe("initialize", function() {
|
||||
it("calls collapseText",function(){
|
||||
spyOn(Stream, "collapseText");
|
||||
|
|
@ -50,7 +65,7 @@ describe("Stream", function() {
|
|||
|
||||
describe("toggleComments", function() {
|
||||
it("toggles class hidden on the comments ul", function () {
|
||||
link = $("a.toggle_post_comments");
|
||||
link = $("a.toggle_post_comments").first();
|
||||
expect(jQuery('ul.comments')).not.toHaveClass("hidden");
|
||||
Stream.toggleComments.call(
|
||||
link, {preventDefault: function(){} }
|
||||
|
|
@ -60,7 +75,7 @@ describe("Stream", function() {
|
|||
});
|
||||
|
||||
it("changes the text on the show comments link", function() {
|
||||
link = $("a.toggle_post_comments");
|
||||
link = $("a.toggle_post_comments").first();
|
||||
Diaspora.widgets.i18n.loadLocale(
|
||||
{'comments' : {'show': 'comments.show pl'}}, 'en');
|
||||
expect(link.text()).toEqual("Hide all comments");
|
||||
|
|
@ -71,4 +86,5 @@ describe("Stream", function() {
|
|||
expect(link.text()).toEqual("comments.show pl");
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue