Merge pull request #34 from hideheader/Enabled-styles-first

Popup: sort enabled styles first
This commit is contained in:
Jason Barnabe 2015-03-03 20:18:07 -06:00
commit b2bce0fa7a

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>";