You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
967 B

  1. // Copyright (c) 2018 Tildes contributors <code@tildes.net>
  2. // SPDX-License-Identifier: AGPL-3.0-or-later
  3. $.onmount('[data-js-comment-parent-button]', function() {
  4. $(this).click(function(event) {
  5. var $comment = $(this).parents('.comment').first();
  6. var $parentComment = $comment.parents('.comment').first();
  7. var backButton = document.createElement('a');
  8. backButton.setAttribute('href', '#comment-' + $comment.attr('data-comment-id36'));
  9. backButton.setAttribute('class', 'comment-nav-link');
  10. backButton.setAttribute('data-js-comment-back-button', '');
  11. backButton.setAttribute('data-js-remove-on-click', '');
  12. backButton.innerHTML = '[Back]';
  13. var $parentHeader = $parentComment.find('header').first();
  14. // remove any existing back button
  15. $parentHeader.find('[data-js-comment-back-button]').remove();
  16. $parentHeader.append(backButton);
  17. $.onmount();
  18. });
  19. });