mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
fix: pinned topic ordering if parent element has non topic elements
for example <ul component="category" class="topic-list" itemscope itemtype="http://www.schema.org/ItemList" data-nextstart="{nextStart}" data-set="{set}"> <meta itemprop="itemListOrder" content="descending"> {{{each topics}}} <!-- IMPORT partials/topics_list_item.tpl --> {{{ end }}} </ul>
This commit is contained in:
@@ -314,14 +314,24 @@ define('forum/category/tools', [
|
|||||||
baseIndex = parseInt(topicListEl.find('[component="category/topic"].pinned').first().attr('data-index'), 10);
|
baseIndex = parseInt(topicListEl.find('[component="category/topic"].pinned').first().attr('data-index'), 10);
|
||||||
},
|
},
|
||||||
update: function (ev, ui) {
|
update: function (ev, ui) {
|
||||||
|
const tid = ui.item.attr('data-tid');
|
||||||
|
const pinnedTopicEls = topicListEl.find('[component="category/topic"].pinned');
|
||||||
|
let newIndex = 0;
|
||||||
|
pinnedTopicEls.each((index, el) => {
|
||||||
|
if ($(el).attr('data-tid') === tid) {
|
||||||
|
newIndex = index;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
socket.emit('topics.orderPinnedTopics', {
|
socket.emit('topics.orderPinnedTopics', {
|
||||||
tid: ui.item.attr('data-tid'),
|
tid: tid,
|
||||||
order: baseIndex + ui.item.index(),
|
order: baseIndex + newIndex,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return alerts.error(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
topicListEl.find('[component="category/topic"].pinned').each((index, el) => {
|
pinnedTopicEls.each((index, el) => {
|
||||||
$(el).attr('data-index', baseIndex + index);
|
$(el).attr('data-index', baseIndex + index);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user