Skip to content
Extraits de code Groupes Projets
Valider 0770d6e8 rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

Most of the stream.js stuff needs to be live, unfortunately.

parent 62977e1d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -14,53 +14,57 @@ var Stream = { ...@@ -14,53 +14,57 @@ var Stream = {
trigger: "hover", trigger: "hover",
gravity: "n" gravity: "n"
}); });
$("a.show_post_comments:not(.show)", this.selector).click(Stream.toggleComments);
//audio links //audio links
Stream.setUpAudioLinks(); Stream.setUpAudioLinks();
//Stream.setUpImageLinks(); //Stream.setUpImageLinks();
// comment link form focus // collapse long comments
$(".focus_comment_textarea", this.selector).click(function(evt) { $(".content p", this.selector).expander({
Stream.focusNewComment($(this), evt); slicePoint: 400,
widow: 12,
expandText: Diaspora.widgets.i18n.t("show_more"),
userCollapse: false
}); });
},
$("textarea.comment_box", this.selector).bind("focus blur", function(evt) { initializeLives: function(){
var commentBox = $(this); // reshare button action
commentBox $(".reshare_button", this.selector).live("click", function(evt) {
.attr("rows", (evt.type === "focus") ? 2 : 1) evt.preventDefault();
.parent().parent() var button = $(this),
.toggleClass("open"); box = button.siblings(".reshare_box");
if (box.length > 0) {
button.toggleClass("active");
box.toggle();
}
}); });
$("a.expand_likes", this.selector).click(function(evt) { this.setUpComments();
$("a.expand_likes", this.selector).live('click',function(evt) {
evt.preventDefault(); evt.preventDefault();
$(this).siblings(".likes_list").fadeToggle("fast"); $(this).siblings(".likes_list").fadeToggle("fast");
}); });
$("a.expand_dislikes", this.selector).click(function(evt) { $("a.expand_dislikes", this.selector).live('click',function(evt) {
evt.preventDefault(); evt.preventDefault();
$(this).siblings(".dislikes_list").fadeToggle("fast"); $(this).siblings(".dislikes_list").fadeToggle("fast");
}); });
},
// reshare button action setUpComments: function(){
$(".reshare_button", this.selector).click(function(evt) { $("a.show_post_comments:not(.show)", this.selector).live('click', Stream.toggleComments);
evt.preventDefault(); // comment link form focus
var button = $(this), $(".focus_comment_textarea", this.selector).live('click', function(evt) {
box = button.siblings(".reshare_box"); Stream.focusNewComment($(this), evt);
if (box.length > 0) {
button.toggleClass("active");
box.toggle();
}
}); });
$(".new_comment", this.selector).bind("ajax:failure", function() { $(".new_comment", this.selector).live("ajax:failure", function() {
Diaspora.widgets.alert.alert(Diaspora.widgets.i18n.t("failed_to_post_message")); Diaspora.widgets.alert.alert(Diaspora.widgets.i18n.t("failed_to_post_message"));
}); });
$(".comment .comment_delete", this.selector).bind("ajax:success", function() { $(".comment .comment_delete", this.selector).live("ajax:success", function() {
var element = $(this), var element = $(this),
target = element.parents(".comment"), target = element.parents(".comment"),
post = element.closest(".stream_element"), post = element.closest(".stream_element"),
...@@ -75,23 +79,23 @@ var Stream = { ...@@ -75,23 +79,23 @@ var Stream = {
}); });
// collapse long comments $("textarea.comment_box", this.selector).live("focus blur", function(evt) {
$(".content p", this.selector).expander({ var commentBox = $(this);
slicePoint: 400, commentBox
widow: 12, .attr("rows", (evt.type === "focus") ? 2 : 1)
expandText: Diaspora.widgets.i18n.t("show_more"), .parent().parent()
userCollapse: false .toggleClass("open");
}); });
}, },
setUpLikes: function() { setUpLikes: function() {
var likes = $(".like_it, .dislike_it", this.selector); var likes = $(".like_it, .dislike_it", this.selector);
likes.bind("ajax:loading", function() { likes.live("ajax:loading", function() {
$(this).parent().fadeOut("fast"); $(this).parent().fadeOut("fast");
}); });
likes.bind("ajax:failure", function() { likes.live("ajax:failure", function() {
Diaspora.widgets.alert.alert(Diaspora.widgets.i18n.t("failed_to_like")); Diaspora.widgets.alert.alert(Diaspora.widgets.i18n.t("failed_to_like"));
$(this).parent().fadeIn("fast"); $(this).parent().fadeIn("fast");
}); });
...@@ -170,6 +174,7 @@ var Stream = { ...@@ -170,6 +174,7 @@ var Stream = {
$(document).ready(function() { $(document).ready(function() {
if( $(Stream.selector).length == 0 ) { return } if( $(Stream.selector).length == 0 ) { return }
Stream.initializeLives();
Diaspora.widgets.subscribe("stream/reloaded", Stream.initialize, Stream); Diaspora.widgets.subscribe("stream/reloaded", Stream.initialize, Stream);
Diaspora.widgets.publish("stream/reloaded"); Diaspora.widgets.publish("stream/reloaded");
}); });
...@@ -10,14 +10,18 @@ describe("Stream", function() { ...@@ -10,14 +10,18 @@ describe("Stream", function() {
Diaspora.widgets.i18n.locale = { }; Diaspora.widgets.i18n.locale = { };
}); });
describe("initialize", function() { describe("setUpLives", function() {
it("attaches a click event to show_post_comments links", function() { it("attaches a click event to show_post_comments links", function() {
spyOn(Stream, "toggleComments"); spyOn(Stream, "toggleComments");
Stream.initialize(); Stream.initializeLives();
$('.stream a.show_post_comments').click(); $('.stream a.show_post_comments').click();
expect(Stream.toggleComments).toHaveBeenCalled(); expect(Stream.toggleComments).toHaveBeenCalled();
}); });
});
describe("initialize", function() {
it("adds a 'show more' links to long posts", function() { it("adds a 'show more' links to long posts", function() {
Diaspora.widgets.i18n.loadLocale( Diaspora.widgets.i18n.loadLocale(
{show_more: 'Placeholder'}, 'en'); {show_more: 'Placeholder'}, 'en');
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter