auto-hiding mod tools on a new_post event, and showing them again if the user can edit that post

v1.18.x
Julian Lam 12 years ago
parent 42e40e62d3
commit 973eb713bf

@ -363,6 +363,7 @@
}); });
socket.on('event:new_post', function(data) { socket.on('event:new_post', function(data) {
data.posts[0].display_moderator_tools = 'none';
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();
@ -372,6 +373,11 @@
.append(html) .append(html)
.fadeIn('slow'); .fadeIn('slow');
socket.once('api:post.privileges', function(privileges) {
if (privileges.editable) toggle_mod_tools(data.posts[0].pid, true);
});
socket.emit('api:post.privileges', data.posts[0].pid);
set_up_posts(uniqueid); set_up_posts(uniqueid);
addCommasToNumbers(); addCommasToNumbers();
@ -671,4 +677,18 @@
replyEl.addClass('none'); replyEl.addClass('none');
} }
} }
function toggle_mod_tools(pid, state) {
var postEl = $(document.querySelector('#post-container li[data-pid="' + pid + '"]')),
editEl = postEl.find('.edit'),
deleteEl = postEl.find('.delete');
if (state) {
editEl.removeClass('none');
deleteEl.removeClass('none');
} else {
editEl.addClass('none');
deleteEl.addClass('none');
}
}
})(); })();
Loading…
Cancel
Save