diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index f865993289..4ee458b501 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -32,12 +32,10 @@ define(function() { app.addCommasToNumbers(); + app.enter_room('topic_' + tid); - var room = 'topic_' + tid, - adminTools = document.getElementById('thread-tools'); - - app.enter_room(room); - + if($('#post-container .sub-posts').length) + $('.topic-main-buttons').removeClass('hide'); $('.twitter-share').on('click', function () { window.open(twitter_url, '_blank', 'width=550,height=420,scrollbars=no,status=no'); @@ -61,11 +59,10 @@ define(function() { if (expose_tools === '1') { var moveThreadModal = $('#move_thread_modal'); - - adminTools.style.visibility = 'inherit'; + $('.thread-tools').removeClass('hide'); // Add events to the thread tools - $('#delete_thread').on('click', function(e) { + $('.delete_thread').on('click', function(e) { if (thread_state.deleted !== '1') { bootbox.confirm('Are you sure you want to delete this thread?', function(confirm) { if (confirm) { @@ -84,7 +81,7 @@ define(function() { return false; }); - $('#lock_thread').on('click', function(e) { + $('.lock_thread').on('click', function(e) { if (thread_state.locked !== '1') { socket.emit('api:topic.lock', { tid: tid @@ -97,7 +94,7 @@ define(function() { return false; }); - $('#pin_thread').on('click', function(e) { + $('.pin_thread').on('click', function(e) { if (thread_state.pinned !== '1') { socket.emit('api:topic.pin', { tid: tid @@ -110,7 +107,7 @@ define(function() { return false; }); - $('#move_thread').on('click', function(e) { + $('.move_thread').on('click', function(e) { moveThreadModal.modal('show'); return false; }); @@ -289,7 +286,7 @@ define(function() { } }; $('#post-container').on('click', '.post_reply', reply_fn); - $('#post_reply').on('click', reply_fn); + $('.topic-main-buttons').on('click', '.post_reply', reply_fn); $('#post-container').on('click', '.quote', function() { if (thread_state.locked !== '1') { @@ -390,12 +387,15 @@ define(function() { var userLink = $('').append(userIcon); userLink.attr('data-uid', uid); + var div = $('
'); + div.append(userLink); + userLink.tooltip({ - placement: 'left', + placement: 'top', title: username }); - return userLink; + return div; } } @@ -437,7 +437,7 @@ define(function() { activeEl.find('.anonymous-box').remove(); if(anonymousCount || remainingUsers) { - var anonLink = $(''); + var anonLink = $('
'); activeEl.append(anonLink); var title = ''; @@ -449,7 +449,7 @@ define(function() { title = anonymousCount + ' guest(s)'; anonLink.tooltip({ - placement: 'left', + placement: 'top', title: title }); } @@ -575,19 +575,19 @@ define(function() { } function set_locked_state(locked, alert) { - var threadReplyBtn = document.getElementById('post_reply'), + var threadReplyBtn = $('.topic-main-buttons .post_reply'), postReplyBtns = document.querySelectorAll('#post-container .post_reply'), quoteBtns = document.querySelectorAll('#post-container .quote'), editBtns = document.querySelectorAll('#post-container .edit'), deleteBtns = document.querySelectorAll('#post-container .delete'), numPosts = document.querySelectorAll('#post_container li[data-pid]').length, - lockThreadEl = document.getElementById('lock_thread'), + lockThreadEl = $('.lock_thread'), x; if (locked === true) { - lockThreadEl.innerHTML = ' Unlock Thread'; - threadReplyBtn.disabled = true; - threadReplyBtn.innerHTML = 'Locked '; + lockThreadEl.html(' Unlock Thread'); + threadReplyBtn.attr('disabled', true); + threadReplyBtn.html('Locked '); for (x = 0; x < numPosts; x++) { postReplyBtns[x].innerHTML = 'Locked '; quoteBtns[x].style.display = 'none'; @@ -607,9 +607,9 @@ define(function() { thread_state.locked = '1'; } else { - lockThreadEl.innerHTML = ' Lock Thread'; - threadReplyBtn.disabled = false; - threadReplyBtn.innerHTML = 'Reply'; + lockThreadEl.html(' Lock Thread'); + threadReplyBtn.attr('disabled', false); + threadReplyBtn.html('Reply'); for (x = 0; x < numPosts; x++) { postReplyBtns[x].innerHTML = 'Reply '; quoteBtns[x].style.display = 'inline-block'; @@ -632,13 +632,14 @@ define(function() { } function set_delete_state(deleted) { - var deleteThreadEl = document.getElementById('delete_thread'), - deleteTextEl = deleteThreadEl.getElementsByTagName('span')[0], + var deleteThreadEl = $('.delete_thread'), + deleteTextEl = $('.delete_thread span'), + //deleteThreadEl.getElementsByTagName('span')[0], threadEl = $('#post-container'), deleteNotice = document.getElementById('thread-deleted') || document.createElement('div'); if (deleted) { - deleteTextEl.innerHTML = ' Restore Thread'; + deleteTextEl.html(' Restore Thread'); threadEl.addClass('deleted'); // Spawn a 'deleted' notice at the top of the page @@ -649,7 +650,7 @@ define(function() { thread_state.deleted = '1'; } else { - deleteTextEl.innerHTML = ' Delete Thread'; + deleteTextEl.html(' Delete Thread'); threadEl.removeClass('deleted'); deleteNotice.parentNode.removeChild(deleteNotice); @@ -658,10 +659,10 @@ define(function() { } function set_pinned_state(pinned, alert) { - var pinEl = document.getElementById('pin_thread'); + var pinEl = $('.pin_thread'); if (pinned) { - pinEl.innerHTML = ' Unpin Thread'; + pinEl.html(' Unpin Thread'); if (alert) { app.alert({ 'alert_id': 'thread_pin', @@ -674,7 +675,7 @@ define(function() { thread_state.pinned = '1'; } else { - pinEl.innerHTML = ' Pin Thread'; + pinEl.html(' Pin Thread'); if (alert) { app.alert({ 'alert_id': 'thread_pin', diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 76240725f3..060fe11f7e 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -20,7 +20,7 @@
  • {topic_name}
  • - +