red-arch/r/static/js/archive-comments.js
libertysoft3 d9d000055b initial
2018-10-28 05:08:54 -07:00

37 lines
No EOL
1.2 KiB
JavaScript

$(document).ready(function() {
$('a.score').click(function(){
var $comment = $(this).closest('.comment');
var depth = parseInt($comment.data('depth'));
if ($comment.hasClass('collapsed')) {
$comment.removeClass('collapsed');
$check_comment = $comment.next('.comment');
depth_sibling = false;
while (!depth_sibling) {
if ($check_comment.length == 0) {
depth_sibling = true;
}
if ($check_comment.data('depth') == '' || parseInt($check_comment.data('depth')) <= depth) {
depth_sibling = true;
} else {
$check_comment.removeClass('hidden');
}
$check_comment = $check_comment.next('.comment');
}
} else {
$comment.addClass('collapsed');
$check_comment = $comment.next('.comment');
depth_sibling = false;
while (!depth_sibling) {
if ($check_comment.length == 0) {
depth_sibling = true;
}
if ($check_comment.data('depth') == '' || parseInt($check_comment.data('depth')) <= depth) {
depth_sibling = true;
} else {
$check_comment.addClass('hidden');
}
$check_comment = $check_comment.next('.comment');
}
}
});
});