diff options
| author | Stephen Blott | 2015-01-16 12:08:42 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-16 13:42:32 +0000 |
| commit | cd49c88eaad6550ba768159347be6c88f1c26d15 (patch) | |
| tree | 43702a2e9e074ad2e23f9c51d3c5fabf6afa3d76 /background_scripts | |
| parent | bbc7257842293fbd58dd2f84a58c86691ceae3e1 (diff) | |
| download | vimium-cd49c88eaad6550ba768159347be6c88f1c26d15.tar.bz2 | |
Modes; clean up.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/main.coffee | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index e8f39326..83a6b3f8 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -339,17 +339,29 @@ updateOpenTabs = (tab) -> setBrowserActionIcon = (tabId,path) -> chrome.browserAction.setIcon({ tabId: tabId, path: path }) -# This color should match the blue of the Vimium browser popup (although it looks a little darker, to me?). chrome.browserAction.setBadgeBackgroundColor - color: [102, 176, 226, 255] + # This is Vimium blue (from the icon). + # color: [102, 176, 226, 255] + # This is a slightly darker blue. It makes the badge more striking in the corner of the eye, and the symbol + # easier to read. + color: [82, 156, 206, 255] setBadge = do -> current = "" + timer = null + updateBadge = (badge) -> -> chrome.browserAction.setBadgeText text: badge (request) -> badge = request.badge if badge? and badge != current - chrome.browserAction.setBadgeText {text: badge || ""} current = badge + clearTimeout timer if timer + if badge == "" + # We set an empty badge immediately. This is the common case when changing tabs. + updateBadge(badge)() + else + # We wait a few milliseconds before setting any other badge. This avoids badge flicker when there are + # rapid changes (e.g. InsertMode is activated by find, followed almost immediately by PostFindMode). + timer = setTimeout updateBadge(badge), 50 # Updates the browserAction icon to indicate whether Vimium is enabled or disabled on the current page. # Also propagates new enabled/disabled/passkeys state to active window, if necessary. |
