From 9ae4b6c10d53153929d905f28bc7de57c0ba6dfe Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 4 Jan 2015 09:29:36 +0000 Subject: Modes; various improvements. - Add StateMode. - PasskeysMode is a StateMode. - BadgeUpdateMode is a StateMode. - Improve badge handling. - Add push method to Mode. - Document how modes work. - Cache badge on background page to reduce the number of updates. - Remove badge restriction on document.body?.tagName.toLowerCase() == "frameset". - Add ExitOnEscape mode, use it for ConstrainedMode and FindMode. - Move PostFindMode to its own file. --- background_scripts/main.coffee | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index fc0a792f..008eb89f 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -342,8 +342,13 @@ setBrowserActionIcon = (tabId,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]} -setBadge = (request) -> - chrome.browserAction.setBadgeText {text: request.badge || ""} +setBadge = do -> + current = "" + (request) -> + badge = request.badge + if badge? and badge != current + chrome.browserAction.setBadgeText {text: badge || ""} + current = badge # 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. -- cgit v1.2.3