mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
feat: allow passing in container to threadTools
This commit is contained in:
@@ -46,7 +46,7 @@ define('forum/topic', [
|
|||||||
posts.onTopicPageLoad(components.get('post'));
|
posts.onTopicPageLoad(components.get('post'));
|
||||||
|
|
||||||
postTools.init(tid);
|
postTools.init(tid);
|
||||||
threadTools.init(tid);
|
threadTools.init(tid, $('.topic'));
|
||||||
events.init();
|
events.init();
|
||||||
|
|
||||||
sort.handleSort('topicPostSort', 'user.setTopicSort', 'topic/' + ajaxify.data.slug);
|
sort.handleSort('topicPostSort', 'user.setTopicSort', 'topic/' + ajaxify.data.slug);
|
||||||
|
|||||||
@@ -7,10 +7,8 @@ define('forum/topic/threadTools', [
|
|||||||
], function (components, translator) {
|
], function (components, translator) {
|
||||||
var ThreadTools = {};
|
var ThreadTools = {};
|
||||||
|
|
||||||
ThreadTools.init = function (tid) {
|
ThreadTools.init = function (tid, topicContainer) {
|
||||||
renderMenu();
|
renderMenu(topicContainer);
|
||||||
|
|
||||||
var topicContainer = $('.topic');
|
|
||||||
|
|
||||||
topicContainer.on('click', '[component="topic/delete"]', function () {
|
topicContainer.on('click', '[component="topic/delete"]', function () {
|
||||||
topicCommand('delete', tid);
|
topicCommand('delete', tid);
|
||||||
@@ -139,8 +137,8 @@ define('forum/topic/threadTools', [
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function renderMenu() {
|
function renderMenu(container) {
|
||||||
$('.topic').on('show.bs.dropdown', '.thread-tools', function () {
|
container.on('show.bs.dropdown', '.thread-tools', function () {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var dropdownMenu = $this.find('.dropdown-menu');
|
var dropdownMenu = $this.find('.dropdown-menu');
|
||||||
if (dropdownMenu.html()) {
|
if (dropdownMenu.html()) {
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ define('sort', ['components'], function (components) {
|
|||||||
var currentSetting = threadSort.find('a[data-sort="' + config[field] + '"]');
|
var currentSetting = threadSort.find('a[data-sort="' + config[field] + '"]');
|
||||||
currentSetting.find('i').addClass('fa-check');
|
currentSetting.find('i').addClass('fa-check');
|
||||||
|
|
||||||
$('.category, .topic').on('click', '[component="thread/sort"] a', function () {
|
$('body')
|
||||||
|
.off('click', '[component="thread/sort"] a')
|
||||||
|
.on('click', '[component="thread/sort"] a', function () {
|
||||||
var newSetting = $(this).attr('data-sort');
|
var newSetting = $(this).attr('data-sort');
|
||||||
socket.emit(method, newSetting, function (err) {
|
socket.emit(method, newSetting, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user