topic watching

This commit is contained in:
barisusakli
2016-05-18 19:02:43 +03:00
parent ef4a94857d
commit bf2133ed7c
17 changed files with 362 additions and 49 deletions

View File

@@ -83,12 +83,18 @@ define('forum/topic/threadTools', [
deletePosts.init();
fork.init();
components.get('topic').on('click', '[component="topic/follow"], [component="topic/unfollow"]', follow);
components.get('topic/follow').off('click').on('click', follow);
components.get('topic/unfollow').off('click').on('click', follow);
$('.topic').on('click', '[component="topic/following"]', function() {
setFollow('follow');
});
$('.topic').on('click', '[component="topic/reading"]', function() {
setFollow('unfollow');
});
$('.topic').on('click', '[component="topic/ignoring"]', function() {
setFollow('ignore');
});
function follow() {
socket.emit('topics.toggleFollow', tid, function(err, state) {
function setFollow(type) {
socket.emit('topics.changeWatching', {tid: tid, type: type}, function(err) {
if (err) {
return app.alert({
type: 'danger',
@@ -98,12 +104,19 @@ define('forum/topic/threadTools', [
timeout: 5000
});
}
setFollowState(state);
var message = '';
if (type === 'follow') {
message = '[[topic:following_topic.message]]';
} else if (type === 'unfollow') {
message = '[[topic:not_following_topic.message]]';
} else if (type === 'ignore') {
message = '[[topic:ignoring_topic.message]]';
}
setFollowState(type);
app.alert({
alert_id: 'follow_thread',
message: state ? '[[topic:following_topic.message]]' : '[[topic:not_following_topic.message]]',
message: message,
type: 'success',
timeout: 5000
});
@@ -195,8 +208,17 @@ define('forum/topic/threadTools', [
};
function setFollowState(state) {
components.get('topic/follow').toggleClass('hidden', state);
components.get('topic/unfollow').toggleClass('hidden', !state);
var menu = components.get('topic/following/menu');
menu.toggleClass('hidden', state !== 'follow');
components.get('topic/following/check').toggleClass('fa-check', state === 'follow');
menu = components.get('topic/reading/menu');
menu.toggleClass('hidden', state !== 'unfollow');
components.get('topic/reading/check').toggleClass('fa-check', state === 'unfollow');
menu = components.get('topic/ignoring/menu');
menu.toggleClass('hidden', state !== 'ignore' );
components.get('topic/ignoring/check').toggleClass('fa-check', state === 'ignore');
}