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 %>")
|
var target = $("#<%= @post.guid %>")
|
||||||
target.find(".sm_body").toggleClass("hidden");
|
target.find(".sm_body").toggleClass("hidden");
|
||||||
target.find(".undo_text").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}
|
.stream_element{:id => post.guid}
|
||||||
- if user_signed_in?
|
.right.controls
|
||||||
- if post.author.owner_id == current_user.id
|
- if current_user && 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')
|
||||||
= 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
|
- 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 vis_hide", :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", :title => t('hide')
|
= image_tag 'ajax-loader.gif', :class => "hide_loader hidden"
|
||||||
|
|
||||||
.undo_text.hidden
|
.undo_text.hidden
|
||||||
= t('post_visibilites.update.post_hidden', :name => post.author.name)
|
= 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
|
.sm_body
|
||||||
= person_image_link(post.author, :size => :thumb_small)
|
= person_image_link(post.author, :size => :thumb_small)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ var Stream = {
|
||||||
|
|
||||||
Diaspora.widgets.subscribe("stream/scrolled", Stream.collapseText);
|
Diaspora.widgets.subscribe("stream/scrolled", Stream.collapseText);
|
||||||
Stream.collapseText('eventID', $(Stream.selector)[0]);
|
Stream.collapseText('eventID', $(Stream.selector)[0]);
|
||||||
|
Stream.bindHideIcon();
|
||||||
},
|
},
|
||||||
collapseText: function(){
|
collapseText: function(){
|
||||||
elements = $(Array.prototype.slice.call(arguments,1));
|
elements = $(Array.prototype.slice.call(arguments,1));
|
||||||
|
|
@ -188,6 +189,16 @@ var Stream = {
|
||||||
textarea.focus();
|
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
|
end
|
||||||
|
|
||||||
it 'generates a jasmine fixture with posts', :fixture => true do
|
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)
|
message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id)
|
||||||
3.times { bob.comment("what", :post => message) }
|
3.times { bob.comment("what", :post => message) }
|
||||||
get :index
|
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() {
|
describe("initialize", function() {
|
||||||
it("calls collapseText",function(){
|
it("calls collapseText",function(){
|
||||||
spyOn(Stream, "collapseText");
|
spyOn(Stream, "collapseText");
|
||||||
|
|
@ -50,7 +65,7 @@ describe("Stream", function() {
|
||||||
|
|
||||||
describe("toggleComments", function() {
|
describe("toggleComments", function() {
|
||||||
it("toggles class hidden on the comments ul", 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");
|
expect(jQuery('ul.comments')).not.toHaveClass("hidden");
|
||||||
Stream.toggleComments.call(
|
Stream.toggleComments.call(
|
||||||
link, {preventDefault: function(){} }
|
link, {preventDefault: function(){} }
|
||||||
|
|
@ -60,7 +75,7 @@ describe("Stream", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("changes the text on the show comments link", 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(
|
Diaspora.widgets.i18n.loadLocale(
|
||||||
{'comments' : {'show': 'comments.show pl'}}, 'en');
|
{'comments' : {'show': 'comments.show pl'}}, 'en');
|
||||||
expect(link.text()).toEqual("Hide all comments");
|
expect(link.text()).toEqual("Hide all comments");
|
||||||
|
|
@ -71,4 +86,5 @@ describe("Stream", function() {
|
||||||
expect(link.text()).toEqual("comments.show pl");
|
expect(link.text()).toEqual("comments.show pl");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue