Moved post/comment text collapsing into respective widgets; removed from stream.js. Removed an unused function in stream.js (image hotlinking).
This commit is contained in:
parent
a618b261f3
commit
b7f9400a9f
4 changed files with 25 additions and 65 deletions
|
|
@ -7,33 +7,13 @@ var Stream = {
|
|||
selector: "#main_stream",
|
||||
|
||||
initialize: function() {
|
||||
Diaspora.page.timeAgo.updateTimeAgo();
|
||||
//Diaspora.page.timeAgo.updateTimeAgo(); // this is not needed because
|
||||
// we do this in both streamelement
|
||||
// and comment widgets
|
||||
Diaspora.page.directionDetector.updateBinds();
|
||||
|
||||
//audio links
|
||||
Stream.setUpAudioLinks();
|
||||
//Stream.setUpImageLinks();
|
||||
|
||||
Diaspora.page.subscribe("stream/scrolled", Stream.collapseText);
|
||||
Stream.collapseText('eventID', $(Stream.selector)[0]);
|
||||
},
|
||||
collapseText: function(){
|
||||
elements = $(Array.prototype.slice.call(arguments,1));
|
||||
// collapse long posts
|
||||
$(".content p", elements).expander({
|
||||
slicePoint: 400,
|
||||
widow: 12,
|
||||
expandText: Diaspora.I18n.t("show_more"),
|
||||
userCollapse: false
|
||||
});
|
||||
|
||||
// collapse long comments
|
||||
$(".comment .content span", elements).expander({
|
||||
slicePoint: 200,
|
||||
widow: 18,
|
||||
expandText: Diaspora.I18n.t("show_more"),
|
||||
userCollapse: false
|
||||
});
|
||||
},
|
||||
|
||||
initializeLives: function(){
|
||||
|
|
@ -101,19 +81,6 @@ var Stream = {
|
|||
});
|
||||
},
|
||||
|
||||
setUpImageLinks: function() {
|
||||
$(".stream a[target='_blank']").each(function() {
|
||||
var link = $(this);
|
||||
if(this.href.match(/\.gif$|\.jpg$|\.png$|\.jpeg$/)) {
|
||||
$("<img/>", {
|
||||
src: this.href
|
||||
}).appendTo(link.parent());
|
||||
|
||||
link.remove();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
focusNewComment: function(toggle, evt) {
|
||||
evt.preventDefault();
|
||||
var post = toggle.closest(".stream_element");
|
||||
|
|
|
|||
|
|
@ -6,11 +6,21 @@
|
|||
$.extend(self, {
|
||||
comment: comment,
|
||||
deleteCommentLink: comment.find("a.comment_delete"),
|
||||
timeAgo: self.instantiate("TimeAgo", comment)
|
||||
timeAgo: self.instantiate("TimeAgo", comment),
|
||||
content: comment.find(".content span")
|
||||
});
|
||||
|
||||
self.deleteCommentLink.click(self.removeComment);
|
||||
self.deleteCommentLink.tipsy({ trigger: "hover" });
|
||||
|
||||
// collapse long comments
|
||||
self.content.expander({
|
||||
slicePoint: 200,
|
||||
widow: 18,
|
||||
expandText: Diaspora.I18n.t("show_more"),
|
||||
userCollapse: false
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
this.removeComment = function(evt) {
|
||||
|
|
|
|||
|
|
@ -12,12 +12,22 @@
|
|||
likes: self.instantiate("Likes", element.find("div.likes_container")),
|
||||
lightBox: self.instantiate("Lightbox", element),
|
||||
deletePostLink: element.find("a.stream_element_delete"),
|
||||
postScope: element.find("span.post_scope")
|
||||
postScope: element.find("span.post_scope"),
|
||||
content: element.find(".content p")
|
||||
});
|
||||
|
||||
// tipsy tooltips
|
||||
self.deletePostLink.tipsy({ trigger: "hover" });
|
||||
self.postScope.tipsy({ trigger: "hover" });
|
||||
|
||||
// collapse long posts
|
||||
self.content.expander({
|
||||
slicePoint: 400,
|
||||
widow: 12,
|
||||
expandText: Diaspora.I18n.t("show_more"),
|
||||
userCollapse: false
|
||||
});
|
||||
|
||||
self.globalSubscribe("post/" + self.postGuid + "/comment/added", function(evt, comment) {
|
||||
self.commentStream.publish("comment/added", comment);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,24 +10,6 @@ describe("Stream", function() {
|
|||
Diaspora.I18n.locale = { };
|
||||
});
|
||||
|
||||
describe("collapseText", function() {
|
||||
it("adds a 'show more' links to long posts", function() {
|
||||
Diaspora.I18n.loadLocale({show_more: 'Placeholder'}, 'en');
|
||||
|
||||
var stream_element = $('#main_stream .stream_element:first');
|
||||
Stream.collapseText('eventID', stream_element[0]);
|
||||
|
||||
expect(stream_element.find("p .details").css('display')).toEqual('none');
|
||||
expect(stream_element.find(".read-more a").css('display')).toEqual('inline');
|
||||
|
||||
stream_element.find(".read-more a").click();
|
||||
jasmine.Clock.tick(200);
|
||||
|
||||
expect(stream_element.find(".read-more").css('display')).toEqual('none');
|
||||
expect(stream_element.find(".details").css('display')).toEqual('inline');
|
||||
});
|
||||
});
|
||||
|
||||
describe("streamElement", function() {
|
||||
it("makes sure that ajax spinner appears when hiding a post", function() {
|
||||
Stream.initializeLives();
|
||||
|
|
@ -42,13 +24,4 @@ describe("Stream", function() {
|
|||
expect(spinner).not.toHaveClass("hidden");
|
||||
});
|
||||
});
|
||||
|
||||
describe("initialize", function() {
|
||||
it("calls collapseText",function(){
|
||||
spyOn(Stream, "collapseText");
|
||||
Stream.initialize();
|
||||
expect(Stream.collapseText).toHaveBeenCalled();
|
||||
})
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue