@ -1,6 +1,6 @@
'use strict' ;
'use strict' ;
/* globals define, app, translator, socket, bootbox */
/* globals define, app, translator, templates, socket, bootbox */
define ( [ 'forum/topic/fork' , 'forum/topic/move' ] , function ( fork , move ) {
define ( [ 'forum/topic/fork' , 'forum/topic/move' ] , function ( fork , move ) {
@ -8,6 +8,8 @@ define(['forum/topic/fork', 'forum/topic/move'], function(fork, move) {
ThreadTools . init = function ( tid , threadState ) {
ThreadTools . init = function ( tid , threadState ) {
if ( templates . get ( 'expose_tools' ) === '1' ) {
$ ( '.thread-tools' ) . removeClass ( 'hide' ) ;
$ ( '.thread-tools' ) . removeClass ( 'hide' ) ;
$ ( '.delete_thread' ) . on ( 'click' , function ( e ) {
$ ( '.delete_thread' ) . on ( 'click' , function ( e ) {
@ -46,8 +48,47 @@ define(['forum/topic/fork', 'forum/topic/move'], function(fork, move) {
move . init ( tid ) ;
move . init ( tid ) ;
fork . init ( ) ;
fork . init ( ) ;
}
socket . emit ( 'topics.followCheck' , tid , function ( err , state ) {
setFollowState ( state , false ) ;
} ) ;
$ ( '.posts' ) . on ( 'click' , '.follow' , function ( ) {
socket . emit ( 'topics.follow' , tid , function ( err , state ) {
if ( err ) {
return app . alert ( {
type : 'danger' ,
alert _id : 'topic_follow' ,
title : '[[global:please_log_in]]' ,
message : '[[topic:login_to_subscribe]]' ,
timeout : 5000
} ) ;
}
setFollowState ( state , true ) ;
} ) ;
return false ;
} ) ;
} ;
} ;
function setFollowState ( state , alert ) {
$ ( '.posts .follow' ) . toggleClass ( 'btn-success' , state ) . attr ( 'title' , state ? 'You are currently receiving updates to this topic' : 'Be notified of new replies in this topic' ) ;
if ( alert ) {
app . alert ( {
alert _id : 'topic_follow' ,
timeout : 2500 ,
title : state ? '[[topic:following_topic.title]]' : '[[topic:not_following_topic.title]]' ,
message : state ? '[[topic:following_topic.message]]' : '[[topic:not_following_topic.message]]' ,
type : 'success'
} ) ;
}
}
return ThreadTools ;
return ThreadTools ;
} ) ;
} ) ;