Bubble.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. $(function()
  2. {
  3. // 同步个人签名操作
  4. $('.sign-submit').on('click', function()
  5. {
  6. if($(this).hasClass('am-primary'))
  7. {
  8. $(this).removeClass('am-primary');
  9. } else {
  10. $(this).addClass('am-primary');
  11. }
  12. });
  13. // 说说点赞
  14. $(document).on('click', '.praise-submit', function()
  15. {
  16. // 参数
  17. var id = $(this).attr('data-id');
  18. var uid = $(this).attr('data-uid');
  19. var url = $(this).data('url');
  20. var num = parseInt($(this).prev().text());
  21. var $this = $(this);
  22. // 不能点赞自己的说说
  23. if(uid == __user_id__)
  24. {
  25. Prompt($('#bubble-comments').data('mood-praise-msg'));
  26. return false;
  27. }
  28. // ajax请求
  29. $.ajax({
  30. url:url,
  31. type:'POST',
  32. dataType:"json",
  33. timeout:10000,
  34. data:{"id":id},
  35. success:function(result)
  36. {
  37. if(result.code == 0)
  38. {
  39. if($this.hasClass('cr-999'))
  40. {
  41. $this.prev().text(num+1);
  42. $this.removeClass('cr-999');
  43. $this.addClass('cr-blue');
  44. } else {
  45. $this.prev().text(num-1);
  46. $this.removeClass('cr-blue');
  47. $this.addClass('cr-999');
  48. }
  49. } else {
  50. Prompt(result.msg);
  51. }
  52. },
  53. error:function(xhr, type)
  54. {
  55. Prompt('网络异常错误');
  56. }
  57. });
  58. });
  59. // 说说评论
  60. $(document).on('click', '.comments-submit, .reply-submit', function()
  61. {
  62. // 不能点赞自己的说说
  63. if($(this).attr('data-uid') == __user_id__)
  64. {
  65. Prompt($('#bubble-comments').data('mood-comments-msg'));
  66. return false;
  67. }
  68. // 参数
  69. var $modal = $('#bubble-comments');
  70. $modal.attr('data-id', $(this).data('id'));
  71. $modal.attr('data-reply-id', $(this).data('reply-id') || 0);
  72. $modal.attr('data-parent-id', $(this).data('parent-id') || 0);
  73. // @用户
  74. var nickname = $(this).data('nickname');
  75. if(nickname != undefined)
  76. {
  77. $modal.find('.am-modal-hd').text('@'+nickname);
  78. } else {
  79. $modal.find('.am-modal-hd').text('');
  80. }
  81. $modal.modal(
  82. {
  83. relatedTarget: this,
  84. onConfirm: function(e)
  85. {
  86. // 内容是否能为空
  87. if($modal.find('textarea').val().length == 0)
  88. {
  89. Prompt($modal.find('textarea').data('validation-message'));
  90. return false;
  91. }
  92. // ajax请求
  93. $.ajax({
  94. url:$modal.data('url'),
  95. type:'POST',
  96. dataType:"json",
  97. timeout:10000,
  98. data:{"mood_id":$modal.attr('data-id'), "reply_id":$modal.attr('data-reply-id'), "parent_id":$modal.attr('data-parent-id'), "content":e.data},
  99. success:function(result)
  100. {
  101. if(result.code == 0)
  102. {
  103. $modal.find('textarea').val('');
  104. Prompt(result.msg, 'success');
  105. setTimeout(function()
  106. {
  107. window.location.reload();
  108. }, 1000);
  109. } else {
  110. Prompt(result.msg);
  111. }
  112. },
  113. error:function(xhr, type)
  114. {
  115. Prompt('网络异常错误');
  116. }
  117. });
  118. },
  119. onCancel: function(e){}
  120. });
  121. });
  122. });