Skip to content
Extraits de code Groupes Projets
Valider 661ad20a rédigé par danielvincent's avatar danielvincent
Parcourir les fichiers

added delegate, proper finders, and more chaining to stream.js. removed...

added delegate,  proper finders, and more chaining to stream.js.   removed div.comment_set from the DOM.
parent ff3dad2b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -2,10 +2,9 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
%div.comments
%ul.comment_set{:id => post.id}
- for comment in post.comments
= render 'comments/comment', :post => comment
%li.comment.show
= render 'comments/new_comment', :post => post
%ul.comments{:id => post.id}
- for comment in post.comments
= render 'comments/comment', :post => comment
%li.comment.show
= render 'comments/new_comment', :post => post
......@@ -45,14 +45,14 @@
function processComment(post_id, html){
post = $("*[data-guid='"+post_id+"']'");
$(' .comment_set li:last', post ).before(
$(' .comments li:last', post ).before(
$(html).fadeIn("fast", function(){})
);
toggler = $('.show_post_comments', post)
if(toggler.length > 0){
toggler.html(
toggler.html().replace(/\d+/,$('.comment_set', post)[0].childElementCount -1));
toggler.html().replace(/\d+/,$('.comments', post)[0].childElementCount -1));
if( !$(".comments", post).is(':visible') ){
toggler.click();
......
......@@ -12,7 +12,7 @@
%li
= link_to '+', '#add_aspect_pane', :class => "add_aspect_button", :title => "add a new aspect"
%ul{ :style => "position:absolute;right:0;bottom:0.01em;"}
%ul.right{:style=>"bottom:0;"}
%li{ :style => "margin-right:0;", :class => ("selected" if @aspect == :manage)}
= link_to ( (@request_count == 0)? t('.manage') : "#{t('.manage')} (#{@request_count})"), {:controller => :aspects, :action => :manage}, :class => "edit_aspect_button", :class => new_request(@request_count), :title => t('.manage_your_aspects')
......
......@@ -5,39 +5,64 @@
$(document).ready(function(){
$('.comment_set').each(function(index) {
var $this = $(this);
if($this.children().length > 1) {
var show_comments_toggle = $this.parent().prev().children(".show_post_comments");
show_comments_toggle.click();
// expand all comments on page load
$("#stream").find('.comments').each(function(index) {
var comments = $(this);
if(comments.children("li").length > 1) {
var show_comments_toggle = comments.closest("li").find(".show_post_comments");
expandComments(show_comments_toggle);
}
});
});//end document ready
$(".show_post_comments").live('click', function(event) {
event.preventDefault();
// comment toggle action
$("#stream").delegate("a.show_post_comments", "click", function(evt) {
evt.preventDefault();
expandComments($(this));
});
var $this = $(this);
// comment submit action
$("#stream").delegate("a.comment_submit", "click", function(evt){
$(this).closest("form").children(".comment_box").attr("rows", 1);
});
if( $this.hasClass( "visible")) {
$this.html($(this).html().replace("hide", "show"));
$this.closest("li").children(".content").children(".comments").slideUp(150);
} else {
$this.html($(this).html().replace("show", "hide"));
$this.closest("li").children(".content").children(".comments").slideDown(150);
}
$(this).toggleClass( "visible" );
});
$("#stream").delegate("textarea.comment_box", "focus", function(evt){
var commentBox = $(this);
commentBox.attr("rows", 2)
.closest("form").find(".comment_submit").fadeIn(200);
});
$("#stream").delegate("textarea.comment_box", "blur", function(evt){
var commentBox = $(this);
if( !commentBox.val() ) {
commentBox.attr("rows", 1)
.closest("form").find(".comment_submit").hide();
}
});
// reshare button action
$("#stream").delegate(".reshare_button", "click", function(evt){
evt.preventDefault();
var button = $(this);
button.closest(".reshare_pane").children(".reshare_box").show();
button.addClass("active");
});
});//end document ready
$(".comment_submit").live('click', function(evt){
$(this).closest("form").children("p .comment_box").attr("rows", 1);
});
$(".reshare_button").live("click", function(e){
e.preventDefault();
var button = $(this);
button.parent(".reshare_pane").children(".reshare_box").show();
button.addClass("active");
});
function expandComments(toggler){
var text = toggler.html();
commentBlock = toggler.closest("li").find("ul.comments", ".content");
if( toggler.hasClass("visible")) {
toggler.removeClass("visible")
.html(text.replace("hide", "show"));
commentBlock.slideUp(150);
} else {
toggler.addClass("visible")
.html(text.replace("show", "hide"));
commentBlock.slideDown(150);
}
}
......@@ -48,7 +48,13 @@ $(document).ready(function(){
}
);
$("#publisher textarea, .comment_box").keydown( function(e) {
$("#publisher").find("textarea").keydown( function(e) {
if (e.keyCode == 13) {
$(this).closest("form").submit();
}
});
$("#stream").delegate("textarea.comment_box", "keydown", function(e){
if (e.keyCode == 13) {
$(this).closest("form").submit();
}
......@@ -126,17 +132,3 @@ $(".make_profile_photo").live("click", function(){
});
});
$(".comment_box").live("focus",function(evt){
var $this = $(this);
$this.attr("rows", 2);
$this.parents("p").parents("form").children("p").children(".comment_submit").fadeIn(200);
});
$(".comment_box").live('blur', function(evt){
var $this = $(this);
if( $this.val() == '' ) {
$this.parents("p").parents("form").children("p").children(".comment_submit").fadeOut(0);
$this.attr("rows", 1);
}
});
......@@ -433,11 +433,10 @@ form
:right 1em
#stream.show
div.comments
ul.comments
:display block
ul.comment_set
:margin
:top 0
:margin
:top 0
> li
:border none
:padding 0
......@@ -447,7 +446,7 @@ form
:border none
#stream div.comments
#stream ul.comments
:display none
.avatar
......@@ -462,7 +461,7 @@ input.comment_submit
:right -10px
ul.comment_set
ul.comments
:margin 0
:top 1em
:padding 0
......@@ -794,7 +793,7 @@ h1.big_text
:top 1px solid #999
:bottom 2px solid #eee
.show_post_comments ul.comment_set
.show_post_comments ul.comments
:width 100%
.sub_header
......
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