From 36ae56834978ef0b886248fb78d64a63a33f1597 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Thu, 30 Jan 2014 17:41:54 -0500 Subject: [PATCH] #656 --- public/language/en_GB/topic.json | 3 +++ public/src/forum/topic.js | 30 ++++++++++++++---------- public/templates/topic.tpl | 3 ++- src/socket.io/posts.js | 39 +++++++++++++++++++++++++++++++- 4 files changed, 61 insertions(+), 14 deletions(-) diff --git a/public/language/en_GB/topic.json b/public/language/en_GB/topic.json index 0b1d903019..09a9eda671 100644 --- a/public/language/en_GB/topic.json +++ b/public/language/en_GB/topic.json @@ -18,6 +18,9 @@ "link": "Link", "share": "Share", "tools": "Tools", + "flag": "Flag", + + "flag_title":"Flag this post for moderation", "thread_tools.title": "Thread Tools", "thread_tools.markAsUnreadForAll": "Mark Unread", diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 59d80041e8..2814f8342a 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -431,21 +431,27 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { $('#post-container').on('click', '.favourite', function() { var pid = $(this).parents('.post-row').attr('data-pid'); - var uid = $(this).parents('.post-row').attr('data-uid'); - if ($(this).attr('data-favourited') == 'false') { - socket.emit('posts.favourite', { - pid: pid, - room_id: app.currentRoom - }); - } else { - socket.emit('posts.unfavourite', { - pid: pid, - room_id: app.currentRoom - }); - } + var method = $(this).attr('data-favourited') == 'false' ? 'posts.favourite' : 'posts.unfavourite'; + + socket.emit(method, { + pid: pid, + room_id: app.currentRoom + }); }); + $('#post-container').on('click', '.flag', function() { + var pid = $(this).parents('.post-row').attr('data-pid'); + + socket.emit('posts.flag', pid, function(err) { + if(err) { + return app.alertError(err.message); + } + app.alertSuccess('This post has been flagged for moderation.'); + }); + }); + + $('#post-container').on('shown.bs.dropdown', '.share-dropdown', function() { var pid = $(this).parents('.post-row').attr('data-pid'); $('#post_' + pid + '_link').val(window.location.href + "#" + pid); diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 4feedc1c23..51a1d6da32 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -66,8 +66,9 @@
- + +