Skip to content

Add button to expand new comments, closes #492

Wes Cook requested to merge (removed):master into master

Adds a new button to the Topics page to expand new comments. The button will only appear if the setting to mark new comments is enabled. It will be disabled (grayed out) if there are no new comments. A count of new comments is also visible on the button, with a span for any desired styling.

The Javascript was originally based on the Tildes Focus script I wrote, but I adapted it to match the jQuery code used in neighboring script files. I also took care to preserve the +/- button states (which the vanilla JS did not do).

Essentially it should act like an on-demand version of the "Collapse old comments" feature. Useful for those who do not want to collapse comments by default.


I know the commentExpand/Collapse/Individual functions looks a little heavy-handed. Simply editing the classes would not correctly preserve the +/- buttons, so I followed the method used in comment-collapse-all-button.js to emulate toggling them instead.

Toggling however only lets you enter collapsed or expanded state, but not collapsed-individual. In that instance I needed to manually edit the classes there. Toggling also required carefully checking the state beforehand, so I created these helper functions to simplify things. If they're useful they could be moved to a different scope to make them available elsewhere.

Hope you like!

Merge request reports