thread.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {% extends "misago/thread/replies.html" %}
  2. {% load i18n %}
  3. {% block page-details %}
  4. {{ block.super }}
  5. <li>
  6. <button type="button" class="btn-show-participants" data-participants-url="{% url 'misago:private_thread_participants' thread_slug=thread.slug thread_id=thread.id %}">
  7. <span class="fa fa-users"></span> <span class="participants-message">{% blocktrans trimmed count users=thread.participants_list|length %}
  8. {{ users }} participant
  9. {% plural %}
  10. {{ users }} participants
  11. {% endblocktrans %}</span>
  12. </button>
  13. <li>
  14. {% endblock page-details %}
  15. {% block thread-actions %}
  16. {{ block.super }}
  17. {% if 'participants' in thread_actions %}
  18. <button class="btn action-participants btn-default pull-right" type="button">
  19. <span class="fa fa-users"></span>
  20. {% trans "Edit participants" %}
  21. </button>
  22. {% endif %}
  23. {% endblock thread-actions %}
  24. {% block post-actions %}
  25. {{ block.super }}
  26. {% if thread.participant %}
  27. <form action="{% url 'misago:private_thread_leave' thread_slug=thread.slug thread_id=thread.id %}" method="POST" class="leave-thread-form pull-right">
  28. {% csrf_token %}
  29. <button class="btn btn-default" type="submit">
  30. <span class="fa fa-sign-out"></span>
  31. {% trans "Leave thread" %}
  32. </button>
  33. </form>
  34. {% endif %}
  35. {% endblock post-actions %}
  36. {% block javascripts %}
  37. {{ block.super }}
  38. <script lang="JavaScript">
  39. var lang_give_ownership = "{% trans "Are you sure you want to pass thread ownership to this user?" %}";
  40. $(function() {
  41. var participants_cache = {};
  42. function enable_participants_popover($e, data) {
  43. $e.popover({
  44. html: true,
  45. content: data,
  46. placement: 'bottom',
  47. trigger: 'focus',
  48. template: '<div class="popover" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>'
  49. });
  50. }
  51. $('.btn-show-participants').click(function() {
  52. var $btn = $(this);
  53. var api_url = $btn.data('participants-url');
  54. if (participants_cache[api_url] == undefined) {
  55. $.get(api_url, function(data) {
  56. participants_cache[api_url] = data;
  57. enable_participants_popover($btn, participants_cache[api_url]);
  58. $btn.popover('show');
  59. })
  60. }
  61. });
  62. {% if thread.participant %}
  63. $('.leave-thread-form').submit(function() {
  64. {% if thread.participants_list|length == 1 %}
  65. var prompt = confirm("{% trans "Are you sure you want to leave this thread? It will be deleted after you leave it." %}");
  66. {% else %}
  67. var prompt = confirm("{% trans "Are you sure you want to leave this thread?" %}");
  68. {% endif %}
  69. return prompt
  70. });
  71. {% endif %}
  72. {% if 'participants' in thread_actions %}
  73. var lang_give_ownership = "{% trans "Are you sure you want to give thread ownership to this user?" %}";
  74. $('.action-participants').click(function() {
  75. Misago.ParticipantsEditor.open({
  76. api_url: '{% url "misago:private_thread_edit_participants" thread_id=thread.id thread_slug=thread.slug %}'
  77. })
  78. });
  79. {% endif %}
  80. });
  81. </script>
  82. {% endblock %}