From f8600c2fb3b377dc185d07533be0b80da4865a0b Mon Sep 17 00:00:00 2001 From: hideheader Date: Tue, 3 Mar 2015 16:49:23 -0500 Subject: [PATCH] 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'. --- popup.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/popup.js b/popup.js index 51d5cea2..39936b69 100644 --- a/popup.js +++ b/popup.js @@ -52,7 +52,11 @@ chrome.tabs.getSelected(null, function(tab) { }); 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"); if (styles.length == 0) { installed.innerHTML = "
" + t('noStylesForSite') + "
";