From 5106c4bc4419be30ac9e0589d0972e677b224fa6 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 19 Apr 2015 10:06:05 -0400 Subject: [PATCH] this fixes rendering of toolbar icon --- platform/firefox/vapi-background.js | 21 +++++++++------------ src/js/async.js | 2 +- tools/make-firefox.sh | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index ed8adfa..b0c2295 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -744,12 +744,13 @@ vAPI.tabs.injectScript = function(tabId, details, callback) { /******************************************************************************/ vAPI.setIcon = function(tabId, iconId, badge) { - var iconStatus = typeof iconId === 'number'; - // If badge is undefined, then setIcon was called from the TabSelect event - var win = badge === undefined ? - iconId : - Services.wm.getMostRecentWindow('navigator:browser'); + var win; + if ( badge === undefined ) { + win = iconId; + } else { + win = Services.wm.getMostRecentWindow('navigator:browser'); + } var curTabId = vAPI.tabs.getTabId(getTabBrowser(win).selectedTab); var tb = vAPI.toolbarButton; @@ -757,7 +758,7 @@ vAPI.setIcon = function(tabId, iconId, badge) { if ( tabId === undefined ) { tabId = curTabId; } else if ( badge !== undefined ) { - tb.tabs[tabId] = { badge: badge, img: iconStatus === 'on' }; + tb.tabs[tabId] = { badge: badge, img: iconId }; } if ( tabId === curTabId ) { @@ -1600,12 +1601,8 @@ vAPI.toolbarButton.updateState = function(win, tabId) { var icon = this.tabs[tabId]; button.setAttribute('badge', icon && icon.badge || ''); - if ( !icon || !icon.img ) { - icon = ''; - } - else { - icon = 'url(' + vAPI.getURL('img/browsericons/icon19-19.png') + ')'; - } + var iconId = icon && icon.img ? icon.img : 'off'; + icon = 'url(' + vAPI.getURL('img/browsericons/icon19-' + iconId + '.png') + ')'; button.style.listStyleImage = icon; }; diff --git a/src/js/async.js b/src/js/async.js index d529d3e..5520cf3 100644 --- a/src/js/async.js +++ b/src/js/async.js @@ -149,7 +149,7 @@ return asyncJobManager; }; var updateBadgeAsync = function(tabId) { - if ( typeof tabId !== 'number' || tabId <= 0 ) { + if ( vAPI.isBehindTheSceneTabId(tabId) ) { return; } µm.asyncJobs.add('updateBadge-' + tabId, tabId, updateBadge, 500); diff --git a/tools/make-firefox.sh b/tools/make-firefox.sh index c082271..ba17a07 100755 --- a/tools/make-firefox.sh +++ b/tools/make-firefox.sh @@ -14,7 +14,7 @@ mv $DES/img/icon_128.png $DES/icon.png cp ./platform/firefox/vapi-*.js $DES/js/ cp ./platform/firefox/bootstrap.js $DES/ cp ./platform/firefox/frame*.js $DES/ -cp -R ./platform/firefox/img $DES/ +cp -R ./platform/chromium/img $DES/ cp ./platform/firefox/chrome.manifest $DES/ cp ./platform/firefox/install.rdf $DES/ cp ./platform/firefox/*.xul $DES/