mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +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'));
|
||||
|
||||
postTools.init(tid);
|
||||
threadTools.init(tid);
|
||||
threadTools.init(tid, $('.topic'));
|
||||
events.init();
|
||||
|
||||
sort.handleSort('topicPostSort', 'user.setTopicSort', 'topic/' + ajaxify.data.slug);
|
||||
|
||||
@@ -7,10 +7,8 @@ define('forum/topic/threadTools', [
|
||||
], function (components, translator) {
|
||||
var ThreadTools = {};
|
||||
|
||||
ThreadTools.init = function (tid) {
|
||||
renderMenu();
|
||||
|
||||
var topicContainer = $('.topic');
|
||||
ThreadTools.init = function (tid, topicContainer) {
|
||||
renderMenu(topicContainer);
|
||||
|
||||
topicContainer.on('click', '[component="topic/delete"]', function () {
|
||||
topicCommand('delete', tid);
|
||||
@@ -139,8 +137,8 @@ define('forum/topic/threadTools', [
|
||||
}
|
||||
};
|
||||
|
||||
function renderMenu() {
|
||||
$('.topic').on('show.bs.dropdown', '.thread-tools', function () {
|
||||
function renderMenu(container) {
|
||||
container.on('show.bs.dropdown', '.thread-tools', function () {
|
||||
var $this = $(this);
|
||||
var dropdownMenu = $this.find('.dropdown-menu');
|
||||
if (dropdownMenu.html()) {
|
||||
|
||||
@@ -10,17 +10,19 @@ define('sort', ['components'], function (components) {
|
||||
var currentSetting = threadSort.find('a[data-sort="' + config[field] + '"]');
|
||||
currentSetting.find('i').addClass('fa-check');
|
||||
|
||||
$('.category, .topic').on('click', '[component="thread/sort"] a', function () {
|
||||
var newSetting = $(this).attr('data-sort');
|
||||
socket.emit(method, newSetting, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
config[field] = newSetting;
|
||||
var qs = decodeURIComponent($.param(utils.params()));
|
||||
ajaxify.go(gotoOnSave + (qs ? '?' + qs : ''));
|
||||
$('body')
|
||||
.off('click', '[component="thread/sort"] a')
|
||||
.on('click', '[component="thread/sort"] a', function () {
|
||||
var newSetting = $(this).attr('data-sort');
|
||||
socket.emit(method, newSetting, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
config[field] = newSetting;
|
||||
var qs = decodeURIComponent($.param(utils.params()));
|
||||
ajaxify.go(gotoOnSave + (qs ? '?' + qs : ''));
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return module;
|
||||
|
||||
Reference in New Issue
Block a user