replies.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <style>
  2. .like-active {
  3. color:#a40004;
  4. }
  5. .like-no-active {
  6. color:#ccc;
  7. }
  8. </style>
  9. <script type="text/javascript">
  10. $(document).ready(function(){
  11. $('.like-reply').click(function() {
  12. var _$this = $(this);
  13. var replyId = _$this.attr('data-id');
  14. var data = JSON.stringify({
  15. uid:replyId
  16. });
  17. if(_$this.hasClass('like-active')){
  18. $.ajax ({
  19. type : "DELETE",
  20. url : "{{ url_for('mine.like') }}",
  21. data:data,
  22. contentType: 'application/json;charset=UTF-8',
  23. success: function(result) {
  24. if (result.judge === true)
  25. {
  26. _$this.attr("title","赞");
  27. _$this.removeClass("like-active");
  28. _$this.addClass("like-no-active");
  29. } else
  30. {
  31. window.location.href = result.url;
  32. }
  33. }});
  34. }else {
  35. $.ajax ({
  36. type : "POST",
  37. url : "{{ url_for('mine.like') }}",
  38. data:data,
  39. contentType: 'application/json;charset=UTF-8',
  40. success: function(result) {
  41. if (result.judge === true)
  42. {
  43. _$this.attr("title","取消赞");
  44. _$this.removeClass("like-no-active");
  45. _$this.addClass("like-active");
  46. } else
  47. {
  48. window.location.href = result.url;
  49. }
  50. }});
  51. }});
  52. $('.reply-author').click(function() {
  53. var _$this = $(this);
  54. var author = _$this.attr('data-id');
  55. $('#content').focus();
  56. $('#content').val('@' + author + ' ');
  57. })
  58. });
  59. </script>
  60. <div class="panel panel-default" id="replies-content">
  61. <div class="panel-heading">
  62. 共收到{{ replies.total }}条回复
  63. </div>
  64. {% if replies.items %}
  65. {% set num = 1 %}
  66. {% for reply in replies.items %}
  67. <div class="panel-body media" style="border-bottom:1px solid #eee;margin:0">
  68. <div class="media-left">
  69. <a href="#">
  70. <img class="media-object img-circle" src="{{ url_for('static',filename='images/Moo.png')}}" alt="..." style="width:48px;height:48px">
  71. </a>
  72. </div>
  73. <div class="media-body">
  74. <small class="media-heading" style="color:#999">
  75. <span>{{ link_base.user(reply.author.username)}}</span>
  76. <span>{{ reply.publish | timesince }}</span>
  77. <a name="reply{{ num }}" class="anchor" href="#reply{{ num }}" aria-hidden="true">#{{ num }}</a>
  78. </small>
  79. <div>
  80. {{ reply.content}}
  81. </div>
  82. </div>
  83. <div class="media-right">
  84. {% if reply in current_user.likes and g.user.is_authenticated %}
  85. <a href="javascript:void(0);" style="padding:0" class="like-reply btn btn-sm like-active" data-id="{{ reply.id}}" title="取消赞">
  86. <i class="icon-thumbs-up"></i>
  87. </a>
  88. {% else %}
  89. <a href="javascript:void(0);" style="padding:0" class="like-reply btn btn-sm like-no-active" data-id="{{ reply.id}}" title="赞">
  90. <i class="icon-thumbs-up"></i>
  91. </a>
  92. {% endif %}
  93. </div>
  94. <div class="media-right">
  95. <a href="javascript:void(0);" style="color:#ccc;padding:0" class="reply-author btn btn-sm" data-id="{{ reply.author.username }}" title="回复">
  96. <i class="icon-reply"></i>
  97. </a>
  98. </div>
  99. </div>
  100. {% set num = num + 1 %}
  101. {% endfor %}
  102. {{ p_footer(replies,'topic.topic',dict(uid=topic.uid))}}
  103. {% else %}
  104. <div class="panel-body">
  105. <span class="text-center" style="display:block;width:100%;color:#999">
  106. 暂无回复
  107. </span>
  108. </div>
  109. {% endif %}
  110. </div>
  111. <div class="panel panel-default">
  112. {% if g.user.is_authenticated %}
  113. <div class="panel-heading"> 回帖 </div>
  114. <div class="panel-body">
  115. <form action="{{ url_for('topic.reply',uid=topic.id)}}" method="POST">
  116. {{ form.hidden_tag() }}
  117. {{ form.content(class='form-control')}}
  118. <button class="btn btn-sm btn-primary" type="submit">提交问题</button>
  119. </form>
  120. </div>
  121. {% else %}
  122. <div class="panel-body" style="border:1px dashed #337ab7;margin:5px;">
  123. <span class="text-center" style="display:block;width:100%;color:#999">
  124. <span class="glyphicon glyphicon-lock" aria-hidden="true" style="font-size:16px;"></span>
  125. 你需要<a href="{{ url_for('auth.login') }}">登陆</a>后才能发表回复
  126. </span>
  127. </div>
  128. {% endif %}
  129. </div>