From 64ae720a5a1f1d89f96dc34ba1373b09eabb0919 Mon Sep 17 00:00:00 2001 From: Kerrick Long Date: Sun, 29 Apr 2012 05:06:40 -0500 Subject: [PATCH] fixed non-working class Background.setBadgeDefaults --- js/common.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/js/common.js b/js/common.js index 579ed29..10bb8fe 100644 --- a/js/common.js +++ b/js/common.js @@ -216,13 +216,32 @@ BrowserAction.prototype.handleManualClick = function (tab) { * @method */ BrowserAction.prototype.setBadgeDefaults = function (tabId) { - chrome.browserAction.setIcon({'path': '/pix/alien-fade.png', 'tabId': tabId}); - chrome.browserAction.setBadgeText({'text': '?', 'tabId': tabId}); - chrome.browserAction.setTitle({'title': 'Click to load data.', 'tabId': tabId}); - chrome.browserAction.setBadgeBackgroundColor({'color': [192, 192, 192, 255], 'tabId': tabId}); - chrome.browserAction.setPopup({popup: '', tabId: tabId}); - chrome.browserAction.onClicked.addListener(this.handleManualClick); - return true; + var tabArray; + + function setTheseBadgeDefaults (tabArray) { + utils.forEach(tabArray, function (tab) { + chrome.browserAction.setIcon({'path': '/pix/alien-fade.png', 'tabId': tab.id}); + chrome.browserAction.setBadgeText({'text': '?', 'tabId': tab.id}); + chrome.browserAction.setTitle({'title': 'Click to load data.', 'tabId': tab.id}); + chrome.browserAction.setBadgeBackgroundColor({'color': [192, 192, 192, 255], 'tabId': tab.id}); + chrome.browserAction.setPopup({popup: '', tabId: tab.id}); + }); + } + + if (typeof tabId !== 'undefined') { + chrome.tabs.get(tabId, function (tabs) { + tabArray = tabs; + setTheseBadgeDefaults(tabArray); + }); + } else { + chrome.tabs.query({}, function (tabs) { + tabArray = tabs; + setTheseBadgeDefaults(tabArray); + }); + } + + chrome.browserAction.onClicked.addListener(this.handleManualClick); + return true; }; /**