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>
isekai-main
Barış Soner Uşaklı
parent e0c137c912
commit cfedd0877f

@ -314,14 +314,24 @@ define('forum/category/tools', [
baseIndex = parseInt(topicListEl.find('[component="category/topic"].pinned').first().attr('data-index'), 10);
},
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', {
tid: ui.item.attr('data-tid'),
order: baseIndex + ui.item.index(),
tid: tid,
order: baseIndex + newIndex,
}, function (err) {
if (err) {
return alerts.error(err);
}
topicListEl.find('[component="category/topic"].pinned').each((index, el) => {
pinnedTopicEls.each((index, el) => {
$(el).attr('data-index', baseIndex + index);
});
});

Loading…
Cancel
Save