Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I set my user's profiles with Heartbeat. At first moment they just look fine but when I open the web to the private beta I realized that when users started to comment nodes, the heartbeat logs of their profiles began to show too much information, they started to look overcrowded. So I have been asking to implement an option to the module core to show the log comments collapsed by default but none has replied.

There is another thread (Display a comment link instead of all the textareas.) on Drupal forums referring to something similar but I don't know how to use that information because I'm a rookie in Drupal hooking & custom modules writing.

Hint: maybe using this code (default option when clicking on Heartbeat comment count)

javascript:Drupal.heartbeat.comments.toggleComments(this, COMMENT_NUMBER); return false;
share|improve this question
add comment

1 Answer

In this case you can use Collapsible Comment module. This module will help you to collapse the threads of the comments.

Now if you want to collapse entire comment region in collapsible form then you can do this using javascript.

Create a js file and add below javascript in a js file and add it to your theme or module.

(function($) {$(function() {
      var $comments = $('#comments');
      if (!$comments.size()) return;
      var count = $comments.find('.comment').size();
      // if (!count) return; // Do nothing when there is no comment.
      var label = Drupal.formatPlural(count, '1 comment', '@count comments');
      var $legend = $(document.createElement('legend')).html('<span class="fieldset-legend">' + label + '</span>');
      var fsetclass = 'comments collapsible' + (location.href.search(/#(comment|new)/) == -1 ? ' collapsed' : '');
      var $fset = $(document.createElement('fieldset')).addClass(fsetclass);
      var $fsetwrap = $(document.createElement('div')).addClass('fieldset-wrapper');
      $fset.insertBefore($comments).append($legend).append($fsetwrap);
      $fsetwrap.append($comments);
      var attach = function() {Drupal.behaviors.collapse.attach($fset.parent(), Drupal.settings);};
      Drupal.behaviors.collapse ? attach() : $.getScript(Drupal.settings.basePath + 'misc/collapse.js', attach);
    });})(jQuery);

The above code will help you to collapse comments. Enjoy!!! :-)

share|improve this answer
    
Are you sure that module supports Heartbeat? –  warmth Nov 22 '12 at 12:35
    
I am not sure about this but the code which is written in js will help you to collapse comments. I am using it –  mohit_rocks Nov 22 '12 at 12:36
    
So you say this code will collapse all the comments of each logged activity? I will give it a try and let you know... thanks! –  warmth Nov 22 '12 at 12:47
    
Sorry @mohit_rocks but that code only works for node comments. –  warmth Nov 22 '12 at 12:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.