mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: allow multiple topic selects in topic-list
chore: up persona
This commit is contained in:
@@ -100,7 +100,7 @@
|
||||
"nodebb-plugin-ntfy": "1.0.15",
|
||||
"nodebb-plugin-spam-be-gone": "2.0.6",
|
||||
"nodebb-rewards-essentials": "0.2.3",
|
||||
"nodebb-theme-harmony": "1.0.0-beta.97",
|
||||
"nodebb-theme-harmony": "1.0.0-beta.98",
|
||||
"nodebb-theme-lavender": "7.0.9",
|
||||
"nodebb-theme-peace": "2.0.19",
|
||||
"nodebb-theme-persona": "13.0.55",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
define('topicSelect', ['components'], function (components) {
|
||||
const TopicSelect = {};
|
||||
let lastSelected;
|
||||
let lastSelectedTopic;
|
||||
|
||||
let topicsContainer;
|
||||
|
||||
@@ -15,23 +15,24 @@ define('topicSelect', ['components'], function (components) {
|
||||
|
||||
topicsContainer.on('click', '[component="topic/select"]', function (ev) {
|
||||
const select = $(this);
|
||||
|
||||
const topicEl = select.parents('[component="category/topic"]');
|
||||
if (ev.shiftKey) {
|
||||
selectRange($(this).parents('[component="category/topic"]').attr('data-tid'));
|
||||
lastSelected = select;
|
||||
selectRange(topicEl.attr('data-tid'));
|
||||
lastSelectedTopic = topicEl;
|
||||
return false;
|
||||
}
|
||||
|
||||
const isSelected = select.parents('[data-tid]').hasClass('selected');
|
||||
toggleSelect(select, !isSelected);
|
||||
lastSelected = select;
|
||||
const isSelected = topicEl.hasClass('selected');
|
||||
toggleSelected(topicEl, !isSelected);
|
||||
lastSelectedTopic = topicEl;
|
||||
if (typeof onSelect === 'function') {
|
||||
onSelect();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function toggleSelect(select, isSelected) {
|
||||
function toggleSelected(topicEl, isSelected) {
|
||||
const select = topicEl.find('[component="topic/select"]');
|
||||
select.toggleClass('fa-check-square-o', isSelected);
|
||||
select.toggleClass('fa-square-o', !isSelected);
|
||||
select.parents('[component="category/topic"]').toggleClass('selected', isSelected);
|
||||
@@ -66,14 +67,14 @@ define('topicSelect', ['components'], function (components) {
|
||||
};
|
||||
|
||||
function selectRange(clickedTid) {
|
||||
if (!lastSelected) {
|
||||
lastSelected = $('[component="category/topic"]').first().find('[component="topic/select"]');
|
||||
if (!lastSelectedTopic) {
|
||||
lastSelectedTopic = $('[component="category/topic"]').first();
|
||||
}
|
||||
|
||||
const isClickedSelected = components.get('category/topic', 'tid', clickedTid).hasClass('selected');
|
||||
|
||||
const clickedIndex = getIndex(clickedTid);
|
||||
const lastIndex = getIndex(lastSelected.parents('[component="category/topic"]').attr('data-tid'));
|
||||
const lastIndex = getIndex(lastSelectedTopic.attr('data-tid'));
|
||||
selectIndexRange(clickedIndex, lastIndex, !isClickedSelected);
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ define('topicSelect', ['components'], function (components) {
|
||||
|
||||
for (let i = start; i <= end; i += 1) {
|
||||
const topic = $('[component="category/topic"]').eq(i);
|
||||
toggleSelect(topic.find('[component="topic/select"]'), isSelected);
|
||||
toggleSelected(topic, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user