Popup: display enabled styles first

Optionally sort enabled styles before disabled styles in the popup menu.
Preference `localStorage['popup.enabledFirst']` controls the behavior;
default is 'true'.
This commit is contained in:
hideheader 2015-03-03 16:49:23 -05:00
parent 110c31d495
commit f8600c2fb3

View File

@ -52,7 +52,11 @@ chrome.tabs.getSelected(null, function(tab) {
}); });
function showStyles(styles) { function showStyles(styles) {
styles.sort(function(a, b) { return a.name.localeCompare(b.name)}); var enabledFirst = localStorage["popup.enabledFirst"] !== "false";
styles.sort(function(a, b) {
if (enabledFirst && a.enabled !== b.enabled) return !(a.enabled < b.enabled) ? -1 : 1;
return a.name.localeCompare(b.name);
});
var installed = document.getElementById("installed"); var installed = document.getElementById("installed");
if (styles.length == 0) { if (styles.length == 0) {
installed.innerHTML = "<div class='entry' id='no-styles'>" + t('noStylesForSite') + "</div>"; installed.innerHTML = "<div class='entry' id='no-styles'>" + t('noStylesForSite') + "</div>";