Change default sort
This commit is contained in:
parent
218b6b41ec
commit
198315c626
|
@ -435,7 +435,7 @@
|
|||
<div class="entry-col header-id">
|
||||
<a href="#" class="sortable tt-se" data-type="order" i18n-data-title="sortLabel;sortColumnInjection">#<span></span></a>
|
||||
</div>
|
||||
<a href="#" class="entry-col sortable header-state center-text tt-se" i18n-text="genericEnabledLabel" i18n-data-title="sortLabel;sortColumnEnabled" data-type="disabled"><span></span></a>
|
||||
<a href="#" class="entry-col sortable header-state center-text tt-se" i18n-text="genericEnabledLabel" i18n-data-title="sortLabel;sortColumnEnabled" data-type="enabled"><span></span></a>
|
||||
<div class="entry-col header-name">
|
||||
<a href="#" class="sortable tt-se" i18n-text="genericName" i18n-data-title="sortLabel;sortColumnName" data-type="title"><span></span></a>
|
||||
</div>
|
||||
|
|
|
@ -35,11 +35,16 @@ const sorter = (() => {
|
|||
parse: ({style}) => style.usercssData ? 0 : 1,
|
||||
sorter: sorterType.number
|
||||
},
|
||||
disabled: {
|
||||
text: t('genericDisabledLabel'), // added as either "enabled" or "disabled" by the addOptions function
|
||||
enabled: {
|
||||
text: t('genericEnabledLabel'),
|
||||
parse: ({style}) => style.enabled ? 0 : 1,
|
||||
sorter: sorterType.number
|
||||
},
|
||||
disabled: {
|
||||
text: t('genericDisabledLabel'),
|
||||
parse: ({style}) => style.enabled ? 1 : 0,
|
||||
sorter: sorterType.number
|
||||
},
|
||||
version: {
|
||||
text: '#',
|
||||
parse: ({style}) => (style.usercssData && style.usercssData.version || ''),
|
||||
|
@ -69,10 +74,10 @@ const sorter = (() => {
|
|||
return styles;
|
||||
}
|
||||
sortBy = sortBy.split(splitRegex);
|
||||
if (sortBy.join('') === '') {
|
||||
sortBy = defaultSort.split(splitRegex);
|
||||
}
|
||||
updateHeaders(sortBy);
|
||||
// Always append an ascending title (default) sort to keep sorts consistent; but don't
|
||||
// show it in the header
|
||||
sortBy = sortBy.concat(defaultSort.split(splitRegex));
|
||||
const len = sortBy.length;
|
||||
return styles.sort((a, b) => {
|
||||
let types, direction, x, y;
|
||||
|
@ -81,17 +86,17 @@ const sorter = (() => {
|
|||
// multi-sort
|
||||
while (result === 0 && index < len) {
|
||||
types = tagData[sortBy[index++]];
|
||||
direction = sortBy[index++] === 'asc' ? 1 : -1;
|
||||
x = types.parse(a);
|
||||
y = types.parse(b);
|
||||
// sort empty values to the bottom
|
||||
if (x === '') {
|
||||
result = 1;
|
||||
} else if (y === '') {
|
||||
result = -1;
|
||||
} else {
|
||||
direction = sortBy[index++] === 'asc' ? 1 : -1;
|
||||
result = types.sorter(x, y) * direction;
|
||||
return 1;
|
||||
}
|
||||
y = types.parse(b);
|
||||
if (y === '') {
|
||||
return -1;
|
||||
}
|
||||
result = types.sorter(x, y) * direction;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
@ -184,8 +189,9 @@ const sorter = (() => {
|
|||
function updateColumnCount() {
|
||||
let newValue = 1;
|
||||
for (let el = document.documentElement.lastElementChild;
|
||||
el.localName === 'style';
|
||||
el = el.previousElementSibling) {
|
||||
el.localName === 'style';
|
||||
el = el.previousElementSibling
|
||||
) {
|
||||
if (el.textContent.includes('--columns:')) {
|
||||
newValue = Math.max(1, getComputedStyle(document.documentElement).getPropertyValue('--columns') | 0);
|
||||
break;
|
||||
|
@ -199,7 +205,6 @@ const sorter = (() => {
|
|||
|
||||
function init() {
|
||||
prefs.subscribe(['manage.newUI.sort'], update);
|
||||
// addOptions();
|
||||
updateColumnCount();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user