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

Side by Side Diff: lib/ui.js

Issue 29329815: Issue 3274 - Unbreak toolbar icon tooltip (Closed)
Patch Set: Fixed JSDoc comment Created Nov. 25, 2015, 10:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/requestNotifier.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 else if (!current.disabled && !(Prefs.subscriptions_exceptionscheckbox & & current.url == Prefs.subscriptions_exceptionsurl)) 1382 else if (!current.disabled && !(Prefs.subscriptions_exceptionscheckbox & & current.url == Prefs.subscriptions_exceptionsurl))
1383 return [subscriptions + 1, filters]; 1383 return [subscriptions + 1, filters];
1384 else 1384 else
1385 return [subscriptions, filters] 1385 return [subscriptions, filters]
1386 }, [0, 0]); 1386 }, [0, 0]);
1387 1387
1388 statusStr = statusStr.replace(/\?1\?/, activeSubscriptions).replace(/\?2\? /, activeFilters); 1388 statusStr = statusStr.replace(/\?1\?/, activeSubscriptions).replace(/\?2\? /, activeFilters);
1389 } 1389 }
1390 statusDescr.setAttribute("value", statusStr); 1390 statusDescr.setAttribute("value", statusStr);
1391 1391
1392 let activeFilters = []; 1392 E("abp-tooltip-blocked-label").hidden = true;
1393 E("abp-tooltip-blocked-label").hidden = (state != "active"); 1393 E("abp-tooltip-blocked").hidden = true;
1394 E("abp-tooltip-blocked").hidden = (state != "active"); 1394 E("abp-tooltip-filters-label").hidden = true;
1395 E("abp-tooltip-filters").hidden = true;
1396 E("abp-tooltip-more-filters").hidden = true;
1397
1395 if (state == "active") 1398 if (state == "active")
1396 { 1399 {
1397 let {getBrowser} = require("appSupport"); 1400 let {getBrowser} = require("appSupport");
1398 let stats = RequestNotifier.getWindowStatistics(getBrowser(window).content Window); 1401 let browser = getBrowser(window);
1402 if ("selectedBrowser" in browser)
1403 browser = browser.selectedBrowser;
1404 let outerWindowID = browser.outerWindowID;
1405 RequestNotifier.getWindowStatistics(outerWindowID, (stats) =>
1406 {
1407 E("abp-tooltip-blocked-label").hidden = false;
1408 E("abp-tooltip-blocked").hidden = false;
1399 1409
1400 let blockedStr = Utils.getString("blocked_count_tooltip"); 1410 let blockedStr = Utils.getString("blocked_count_tooltip");
1401 blockedStr = blockedStr.replace(/\?1\?/, stats ? stats.blocked : 0).replac e(/\?2\?/, stats ? stats.items : 0); 1411 blockedStr = blockedStr.replace(/\?1\?/, stats ? stats.blocked : 0).repl ace(/\?2\?/, stats ? stats.items : 0);
1402 1412
1403 if (stats && stats.whitelisted + stats.hidden) 1413 if (stats && stats.whitelisted + stats.hidden)
1404 { 1414 {
1405 blockedStr += " " + Utils.getString("blocked_count_addendum"); 1415 blockedStr += " " + Utils.getString("blocked_count_addendum");
1406 blockedStr = blockedStr.replace(/\?1\?/, stats.whitelisted).replace(/\?2 \?/, stats.hidden); 1416 blockedStr = blockedStr.replace(/\?1\?/, stats.whitelisted).replace(/\ ?2\?/, stats.hidden);
1407 } 1417 }
1408 1418
1409 E("abp-tooltip-blocked").setAttribute("value", blockedStr); 1419 E("abp-tooltip-blocked").setAttribute("value", blockedStr);
1410 1420
1411 if (stats) 1421 let activeFilters = [];
1412 { 1422 if (stats)
1413 let filterSort = function(a, b)
1414 { 1423 {
1415 return stats.filters[b] - stats.filters[a]; 1424 let filterSort = function(a, b)
1416 }; 1425 {
1417 for (let filter in stats.filters) 1426 return stats.filters[b] - stats.filters[a];
1418 activeFilters.push(filter); 1427 };
1419 activeFilters = activeFilters.sort(filterSort); 1428 for (let filter in stats.filters)
1420 } 1429 activeFilters.push(filter);
1430 activeFilters = activeFilters.sort(filterSort);
1431 }
1421 1432
1422 if (activeFilters.length > 0) 1433 if (activeFilters.length > 0)
1423 { 1434 {
1424 let filtersContainer = E("abp-tooltip-filters"); 1435 let filtersContainer = E("abp-tooltip-filters");
1425 while (filtersContainer.firstChild) 1436 while (filtersContainer.firstChild)
1426 filtersContainer.removeChild(filtersContainer.firstChild); 1437 filtersContainer.removeChild(filtersContainer.firstChild);
1427 1438
1428 for (let i = 0; i < activeFilters.length && i < 3; i++) 1439 for (let i = 0; i < activeFilters.length && i < 3; i++)
1429 { 1440 {
1430 let descr = filtersContainer.ownerDocument.createElement("description" ); 1441 let descr = filtersContainer.ownerDocument.createElement("descriptio n");
1431 descr.setAttribute("value", activeFilters[i] + " (" + stats.filters[ac tiveFilters[i]] + ")"); 1442 descr.setAttribute("value", activeFilters[i] + " (" + stats.filters[ activeFilters[i]] + ")");
1432 filtersContainer.appendChild(descr); 1443 filtersContainer.appendChild(descr);
1444 }
1433 } 1445 }
1434 } 1446
1447 E("abp-tooltip-filters-label").hidden = (activeFilters.length == 0);
1448 E("abp-tooltip-filters").hidden = (activeFilters.length == 0);
1449 E("abp-tooltip-more-filters").hidden = (activeFilters.length <= 3);
1450 });
1435 } 1451 }
1436
1437 E("abp-tooltip-filters-label").hidden = (activeFilters.length == 0);
1438 E("abp-tooltip-filters").hidden = (activeFilters.length == 0);
1439 E("abp-tooltip-more-filters").hidden = (activeFilters.length <= 3);
1440 }, 1452 },
1441 1453
1442 /** 1454 /**
1443 * Updates state of the icon context menu. 1455 * Updates state of the icon context menu.
1444 */ 1456 */
1445 fillIconMenu: function(/**Event*/ event, /**Window*/ window, /**String*/ prefi x) 1457 fillIconMenu: function(/**Event*/ event, /**Window*/ window, /**String*/ prefi x)
1446 { 1458 {
1447 function hideElement(id, hide) 1459 function hideElement(id, hide)
1448 { 1460 {
1449 let element = window.document.getElementById(id); 1461 let element = window.document.getElementById(id);
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)], 1940 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)],
1929 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa tegory.bind(Notification, "*", null)] 1941 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa tegory.bind(Notification, "*", null)]
1930 ]; 1942 ];
1931 1943
1932 onShutdown.add(function() 1944 onShutdown.add(function()
1933 { 1945 {
1934 for (let window of UI.applicationWindows) 1946 for (let window of UI.applicationWindows)
1935 if (UI.isBottombarOpen(window)) 1947 if (UI.isBottombarOpen(window))
1936 UI.toggleBottombar(window); 1948 UI.toggleBottombar(window);
1937 }); 1949 });
OLDNEW
« no previous file with comments | « lib/requestNotifier.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld