Add popup auto resort option
This commit is contained in:
parent
77b37d7ee0
commit
259cf4ab80
|
@ -1055,6 +1055,10 @@
|
|||
"message": "Styles before commands",
|
||||
"description": "Label for the checkbox controlling section order in the popup."
|
||||
},
|
||||
"popupAutoResort": {
|
||||
"message": "Resort styles in popup after toggling",
|
||||
"description": "Label for the checkbox controlling popup resorting."
|
||||
},
|
||||
"prefShowBadge": {
|
||||
"message": "Number of styles active for the current site",
|
||||
"description": "Label for the checkbox controlling toolbar badge text."
|
||||
|
|
|
@ -18,6 +18,7 @@ const prefs = (() => {
|
|||
'popup.breadcrumbs.usePath': false, // use URL path for 'this URL'
|
||||
'popup.enabledFirst': true, // display enabled styles before disabled styles
|
||||
'popup.stylesFirst': true, // display enabled styles before disabled styles
|
||||
'popup.autoResort': false, // auto resort styles after toggling
|
||||
'popup.borders': false, // add white borders on the sides
|
||||
'popup.findStylesInline': true, // use the inline style search
|
||||
|
||||
|
|
|
@ -101,6 +101,13 @@
|
|||
<span></span>
|
||||
</span>
|
||||
</label>
|
||||
<label>
|
||||
<span i18n-text="popupAutoResort"></span>
|
||||
<span class="onoffswitch">
|
||||
<input type="checkbox" id="popup.autoResort" class="slider">
|
||||
<span></span>
|
||||
</span>
|
||||
</label>
|
||||
<label class="chromium-only">
|
||||
<span i18n-text="popupBorders" i18n-title="popupBordersTooltip"></span>
|
||||
<span class="onoffswitch">
|
||||
|
|
|
@ -242,16 +242,18 @@ function showStyles(styles) {
|
|||
}
|
||||
|
||||
function sortStylesInPlace() {
|
||||
const enabledFirst = prefs.get('popup.enabledFirst');
|
||||
const styles = $$('.entry', installed);
|
||||
if (styles.length) {
|
||||
styles.sort((a, b) => {
|
||||
const aEnabled = a.styleMeta.enabled;
|
||||
return enabledFirst && aEnabled !== b.styleMeta.enabled
|
||||
? aEnabled ? -1 : 1
|
||||
: a.styleMeta.name.localeCompare(b.styleMeta.name);
|
||||
});
|
||||
styles.forEach(style => installed.appendChild(style));
|
||||
if (prefs.get('popup.autoResort')) {
|
||||
const enabledFirst = prefs.get('popup.enabledFirst');
|
||||
const styles = $$('.entry', installed);
|
||||
if (styles.length) {
|
||||
styles.sort((a, b) => {
|
||||
const aEnabled = a.styleMeta.enabled;
|
||||
return enabledFirst && aEnabled !== b.styleMeta.enabled
|
||||
? aEnabled ? -1 : 1
|
||||
: a.styleMeta.name.localeCompare(b.styleMeta.name);
|
||||
});
|
||||
styles.forEach(style => installed.appendChild(style));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user