Skip to content

Commit

Permalink
Change browser action icon on window focus change
Browse files Browse the repository at this point in the history
  • Loading branch information
EranSch committed Sep 10, 2014
1 parent 2d6f2a5 commit 19c161f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/lib/brain.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,26 @@ chrome.browserAction.onClicked.addListener(function(tab) {
* Going to assume that the hiding was handled on tab load so this is just for keeping up
* appearances.
*/
chrome.tabs.onActivated.addListener(function(tab) {
var updateBrowserIcon = function(tab) {
var id = tab.tabId || tab.id;
wpAdminHide.chkD(
tab.tabId,
id,
function() {
wpAdminHide.toggleIcon(true);
},
function() {
wpAdminHide.toggleIcon(false);
});
};

// Update icon when tab is changed within a single window
chrome.tabs.onActivated.addListener(updateBrowserIcon);

// Update icon when window focus changes
chrome.windows.onFocusChanged.addListener(function(windowId){
chrome.tabs.query({windowId: windowId, active: true}, function(tab){
updateBrowserIcon(tab['0']);
});
});

chrome.tabs.onUpdated.addListener(function(tabId, data, tab) {
Expand Down

0 comments on commit 19c161f

Please sign in to comment.