Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/ui.js

Issue 29329815: Issue 3274 - Unbreak toolbar icon tooltip (Closed)
Patch Set: Created Nov. 6, 2015, 12:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/child/requestNotifier.js ('K') | « lib/requestNotifier.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/ui.js
===================================================================
--- a/lib/ui.js
+++ b/lib/ui.js
@@ -1384,64 +1384,76 @@ let UI = exports.UI =
else
return [subscriptions, filters]
}, [0, 0]);
statusStr = statusStr.replace(/\?1\?/, activeSubscriptions).replace(/\?2\?/, activeFilters);
}
statusDescr.setAttribute("value", statusStr);
- let activeFilters = [];
- E("abp-tooltip-blocked-label").hidden = (state != "active");
- E("abp-tooltip-blocked").hidden = (state != "active");
+ E("abp-tooltip-blocked-label").hidden = true;
+ E("abp-tooltip-blocked").hidden = true;
+ E("abp-tooltip-filters-label").hidden = true;
+ E("abp-tooltip-filters").hidden = true;
+ E("abp-tooltip-more-filters").hidden = true;
+
if (state == "active")
{
let {getBrowser} = require("appSupport");
- let stats = RequestNotifier.getWindowStatistics(getBrowser(window).contentWindow);
+ let browser = getBrowser(window);
+ if ("selectedBrowser" in browser)
+ browser = browser.selectedBrowser;
+ let outerWindowID = browser.outerWindowID;
+ RequestNotifier.getWindowStatistics(outerWindowID, (stats) =>
+ {
+ E("abp-tooltip-blocked-label").hidden = false;
+ E("abp-tooltip-blocked").hidden = false;
- let blockedStr = Utils.getString("blocked_count_tooltip");
- blockedStr = blockedStr.replace(/\?1\?/, stats ? stats.blocked : 0).replace(/\?2\?/, stats ? stats.items : 0);
+ let blockedStr = Utils.getString("blocked_count_tooltip");
+ blockedStr = blockedStr.replace(/\?1\?/, stats ? stats.blocked : 0).replace(/\?2\?/, stats ? stats.items : 0);
- if (stats && stats.whitelisted + stats.hidden)
- {
- blockedStr += " " + Utils.getString("blocked_count_addendum");
- blockedStr = blockedStr.replace(/\?1\?/, stats.whitelisted).replace(/\?2\?/, stats.hidden);
- }
+ if (stats && stats.whitelisted + stats.hidden)
+ {
+ blockedStr += " " + Utils.getString("blocked_count_addendum");
+ blockedStr = blockedStr.replace(/\?1\?/, stats.whitelisted).replace(/\?2\?/, stats.hidden);
+ }
- E("abp-tooltip-blocked").setAttribute("value", blockedStr);
+ E("abp-tooltip-blocked").setAttribute("value", blockedStr);
- if (stats)
- {
- let filterSort = function(a, b)
+ let activeFilters = [];
+ if (stats)
{
- return stats.filters[b] - stats.filters[a];
- };
- for (let filter in stats.filters)
- activeFilters.push(filter);
- activeFilters = activeFilters.sort(filterSort);
- }
+ let filterSort = function(a, b)
+ {
+ return stats.filters[b] - stats.filters[a];
+ };
+ for (let filter in stats.filters)
+ activeFilters.push(filter);
+ activeFilters = activeFilters.sort(filterSort);
+ }
- if (activeFilters.length > 0)
- {
- let filtersContainer = E("abp-tooltip-filters");
- while (filtersContainer.firstChild)
- filtersContainer.removeChild(filtersContainer.firstChild);
+ if (activeFilters.length > 0)
+ {
+ let filtersContainer = E("abp-tooltip-filters");
+ while (filtersContainer.firstChild)
+ filtersContainer.removeChild(filtersContainer.firstChild);
- for (let i = 0; i < activeFilters.length && i < 3; i++)
- {
- let descr = filtersContainer.ownerDocument.createElement("description");
- descr.setAttribute("value", activeFilters[i] + " (" + stats.filters[activeFilters[i]] + ")");
- filtersContainer.appendChild(descr);
+ for (let i = 0; i < activeFilters.length && i < 3; i++)
+ {
+ let descr = filtersContainer.ownerDocument.createElement("description");
+ descr.setAttribute("value", activeFilters[i] + " (" + stats.filters[activeFilters[i]] + ")");
+ filtersContainer.appendChild(descr);
+ }
}
- }
+
+ E("abp-tooltip-filters-label").hidden = (activeFilters.length == 0);
+ E("abp-tooltip-filters").hidden = (activeFilters.length == 0);
+ E("abp-tooltip-more-filters").hidden = (activeFilters.length <= 3);
+ });
}
-
- E("abp-tooltip-filters-label").hidden = (activeFilters.length == 0);
- E("abp-tooltip-filters").hidden = (activeFilters.length == 0);
- E("abp-tooltip-more-filters").hidden = (activeFilters.length <= 3);
},
/**
* Updates state of the icon context menu.
*/
fillIconMenu: function(/**Event*/ event, /**Window*/ window, /**String*/ prefix)
{
function hideElement(id, hide)
« lib/child/requestNotifier.js ('K') | « lib/requestNotifier.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld