mirror of
https://github.com/c0mmando/voat-conspiracy-archive.git
synced 2025-06-04 00:41:11 +05:30
1 line
1.3 KiB
JavaScript
1 line
1.3 KiB
JavaScript
if(typeof jQuery==='undefined'){console.error("jQuery is required for comments-toggle.js.")}jQuery(document).ready(function($){function setCommentDepths(){$('.commentarea .sitetable.nestedlisting > .comment, .commentarea .sitetable.nestedlisting > .child.comment').each(function(){traverseComment($(this),0)})}function traverseComment($comment,depth){$comment.attr('data-depth',depth);if($comment.find(".comment-toggle-arrow").length===0){var $arrow=$('<span class="comment-toggle-arrow" style="cursor:pointer; font-size:18px; margin-right:12px;">▼</span>');$comment.find('.tagline').first().prepend($arrow)}$comment.children('.child').each(function(){traverseComment($(this),depth+1)})}function toggleComment($comment){var depth=parseInt($comment.attr('data-depth'),10)||0;$comment.toggleClass('collapsed');$comment.nextAll().each(function(){var $next=$(this);var nextDepth=parseInt($next.attr('data-depth'),10);if(isNaN(nextDepth)){return true}if(nextDepth<=depth){return false}$next.toggleClass('hidden')})}setCommentDepths();$('.commentarea').on('click','.comment-toggle-arrow',function(e){e.preventDefault();var $comment=$(this).closest('.comment');toggleComment($comment);if($comment.hasClass('collapsed')){$(this).html('▲')}else{$(this).html('▼')}})}); |