/** * Comment toggler * * Allows comments to be shown and hidden * On page load all toggled comments are hidden * * See: http://sonspring.com/journal/jquery-portlets */ // use this method if you dont want to use wrapping div's /* $(this).parent().next().toggle(); */ // this is for when you only want to use one link, instead of the 2 open and close methods // the 2 link system is used for when you want to the toggle between links/images, open/close (same as collapsible fieldsets arrows) // change your toggle link class to toggle /* $('a.toggle').click(function() { $(this).parent('div').next('div').toggle(); return false; }); */ Drupal.commenttoggle = function () { // attach the onclick handlers to show comments $('a.comment_open').click(function() { $(this).parent('div').next('div').toggle(); // 'a.spoiler_open:visible' $(this).hide(); // 'a.spoiler_close:hidden' $(this).next('a').show(); return false; } ); // attach the onclick handlers to hide comments $('a.comment_close').click(function() { $(this).parent('div').next('div').toggle(); // 'a.spoiler_close:visible' $(this).hide(); // 'a.spoiler_open:hidden' $(this).prev('a').show(); return false; } ); // hide all comments on page display $('a.comment_close').each(function() { $(this).parent('div').next('div').toggle(); }); // show the correct links once all comments have been hidden $('a.comment_open:hidden').show(); $('a.comment_close:visible').hide(); } // Global killswitch if (Drupal.jsEnabled) { $(document).ready(Drupal.commenttoggle); }