mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 08:20:36 +01:00
if a thread is locked, the reply buttons all now say "locked", and the
post reply window will not pop up
This commit is contained in:
@@ -37,16 +37,21 @@
|
|||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
(function() {
|
||||||
|
var locked = '{locked}';
|
||||||
|
|
||||||
jQuery('document').ready(function() {
|
jQuery('document').ready(function() {
|
||||||
var room = 'topic_' + '{topic_id}';
|
var room = 'topic_' + '{topic_id}';
|
||||||
|
|
||||||
app.enter_room(room);
|
app.enter_room(room);
|
||||||
set_up_posts();
|
set_up_posts();
|
||||||
});
|
|
||||||
|
if (locked === '1') set_locked_state(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
ajaxify.register_events(['event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room']);
|
ajaxify.register_events(['event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room']);
|
||||||
socket.on('api:get_users_in_room', function(users) {
|
socket.on('api:get_users_in_room', function(users) {
|
||||||
var anonymous = users.anonymous,
|
var anonymous = users.anonymous,
|
||||||
usernames = users.usernames,
|
usernames = users.usernames,
|
||||||
usercount = usernames.length;
|
usercount = usernames.length;
|
||||||
@@ -65,28 +70,28 @@ socket.on('api:get_users_in_room', function(users) {
|
|||||||
+ (anonymous === 0 ? (usercount > 1 ? ' are' : ' is') : '') + ' browsing this thread';
|
+ (anonymous === 0 ? (usercount > 1 ? ' are' : ' is') : '') + ' browsing this thread';
|
||||||
|
|
||||||
document.getElementById('thread_active_users').innerHTML = active;
|
document.getElementById('thread_active_users').innerHTML = active;
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('event:rep_up', function(data) {
|
socket.on('event:rep_up', function(data) {
|
||||||
adjust_rep(1, data.pid, data.uid);
|
adjust_rep(1, data.pid, data.uid);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('event:rep_down', function(data) {
|
socket.on('event:rep_down', function(data) {
|
||||||
adjust_rep(-1, data.pid, data.uid);
|
adjust_rep(-1, data.pid, data.uid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
socket.on('event:new_post', function(data) {
|
socket.on('event:new_post', function(data) {
|
||||||
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data),
|
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data),
|
||||||
uniqueid = new Date().getTime();
|
uniqueid = new Date().getTime();
|
||||||
|
|
||||||
jQuery('<div id="' + uniqueid + '"></div>').appendTo("#post-container").hide().append(html).fadeIn('slow');
|
jQuery('<div id="' + uniqueid + '"></div>').appendTo("#post-container").hide().append(html).fadeIn('slow');
|
||||||
set_up_posts(uniqueid);
|
set_up_posts(uniqueid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function adjust_rep(value, pid, uid) {
|
function adjust_rep(value, pid, uid) {
|
||||||
var post_rep = jQuery('.post_rep_' + pid),
|
var post_rep = jQuery('.post_rep_' + pid),
|
||||||
user_rep = jQuery('.user_rep_' + uid);
|
user_rep = jQuery('.user_rep_' + uid);
|
||||||
|
|
||||||
@@ -98,19 +103,19 @@ function adjust_rep(value, pid, uid) {
|
|||||||
|
|
||||||
post_rep.html(ptotal);
|
post_rep.html(ptotal);
|
||||||
user_rep.html(utotal);
|
user_rep.html(utotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_up_posts(div) {
|
function set_up_posts(div) {
|
||||||
if (div == null) div = '';
|
if (div == null) div = '';
|
||||||
else div = '#' + div;
|
else div = '#' + div;
|
||||||
|
|
||||||
jQuery(div + ' .post_reply').click(function() {
|
jQuery(div + ' .post_reply').click(function() {
|
||||||
app.open_post_window('reply', "{topic_id}", "{topic_name}");
|
if (locked !== '1') app.open_post_window('reply', "{topic_id}", "{topic_name}");
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery(div + ' .quote').click(function() {
|
jQuery(div + ' .quote').click(function() {
|
||||||
app.open_post_window('quote', "{topic_id}", "{topic_name}");
|
if (locked !== '1') app.open_post_window('quote', "{topic_id}", "{topic_name}");
|
||||||
|
|
||||||
// this needs to be looked at, obviously. only single line quotes work well I think maybe replace all \r\n with > ?
|
// this needs to be looked at, obviously. only single line quotes work well I think maybe replace all \r\n with > ?
|
||||||
document.getElementById('post_content').innerHTML = '> ' + document.getElementById('content_' + this.id.replace('quote_', '')).innerHTML;
|
document.getElementById('post_content').innerHTML = '> ' + document.getElementById('content_' + this.id.replace('quote_', '')).innerHTML;
|
||||||
@@ -138,5 +143,29 @@ function set_up_posts(div) {
|
|||||||
socket.emit('api:posts.unfavourite', {pid: pid, room_id: app.current_room});
|
socket.emit('api:posts.unfavourite', {pid: pid, room_id: app.current_room});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_locked_state(locked) {
|
||||||
|
var threadReplyBtn = document.getElementById('post_reply'),
|
||||||
|
postReplyBtns = document.querySelectorAll('#post-container .post_reply'),
|
||||||
|
quoteBtns = document.querySelectorAll('#post-container .quote'),
|
||||||
|
numReplyBtns = postReplyBtns.length,
|
||||||
|
x;
|
||||||
|
if (locked === true) {
|
||||||
|
threadReplyBtn.disabled = true;
|
||||||
|
threadReplyBtn.innerHTML = 'Locked';
|
||||||
|
for(x=0;x<numReplyBtns;x++) {
|
||||||
|
postReplyBtns[x].innerHTML = 'Locked <i class="icon-lock"></i>';
|
||||||
|
quoteBtns[x].style.display = 'none';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
threadReplyBtn.disabled = false;
|
||||||
|
threadReplyBtn.innerHTML = 'Reply';
|
||||||
|
for(x=0;x<numReplyBtns;x++) {
|
||||||
|
postReplyBtns[x].innerHTML = 'Reply <i class="icon-reply"></i>';
|
||||||
|
quoteBtns[x].style.display = 'inline-block';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
@@ -340,7 +340,7 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
|
|
||||||
app.get('/test', function(req, res) {
|
app.get('/test', function(req, res) {
|
||||||
global.modules.posts.get(function(data) {
|
global.modules.posts.get(function(data) {
|
||||||
res.send('<pre>' + JSON.stringify(data) + '</pre>');
|
res.send('<pre>' + JSON.stringify(data, null, 4) + '</pre>');
|
||||||
}, 1, 1);
|
}, 1, 1);
|
||||||
});
|
});
|
||||||
}(WebServer));
|
}(WebServer));
|
||||||
|
|||||||
Reference in New Issue
Block a user