Index: desktop-options.js |
=================================================================== |
--- a/desktop-options.js |
+++ b/desktop-options.js |
@@ -533,18 +533,12 @@ |
function findParentData(element, dataName, returnElement) |
{ |
- while (element) |
- { |
- if (element.hasAttribute("data-" + dataName)) |
- { |
- if (returnElement) |
- return element; |
- return element.getAttribute("data-" + dataName); |
- } |
- |
- element = element.parentElement; |
- } |
- return null; |
+ element = element.closest(`[data-${dataName}]`); |
+ if (!element) |
+ return null; |
+ if (returnElement) |
+ return element; |
+ return element.getAttribute(`data-${dataName}`); |
} |
function sendMessageHandleErrors(message, onSuccess) |
@@ -918,10 +912,10 @@ |
{ |
setLinks("enable-acceptable-ads-description", link); |
}); |
- setElementText(E("tracking-warning-1"), "options_tracking_warning_1", |
+ setElementText(E("tracking-warning-1"), "options_tracking_warning_1", |
[getMessage("common_feature_privacy_title"), |
- getMessage("options_acceptableAds_ads_label")]); |
- setElementText(E("tracking-warning-3"), "options_tracking_warning_3", |
+ getMessage("options_acceptableAds_ads_label")]); |
+ setElementText(E("tracking-warning-3"), "options_tracking_warning_3", |
[getMessage("options_acceptableAds_privacy_label")]); |
getDocLink("privacy_friendly_ads", (link) => |
@@ -1295,7 +1289,7 @@ |
updateSubscription(subscription); |
break; |
case "added": |
- let {url, recommended} = subscription; |
+ let {url} = subscription; |
// Handle custom subscription |
if (/^~user/.test(url)) |
{ |
@@ -1401,27 +1395,41 @@ |
function updateTooltips() |
{ |
- let anchors = document.querySelectorAll(":not(.tooltip) > [data-tooltip]"); |
- for (let anchor of anchors) |
+ const tooltipsSelector = ":not(.tooltip) > [data-tooltip]"; |
+ const anchors = document.querySelectorAll(tooltipsSelector); |
+ for (const anchor of anchors) |
{ |
- let id = anchor.getAttribute("data-tooltip"); |
+ // avoid creating same tooltip N times |
+ // updateTooltips gets invoked during bootstrap |
+ if (anchor.querySelector('[role="tooltip"]')) |
+ continue; |
- let wrapper = document.createElement("div"); |
- wrapper.className = "icon tooltip"; |
- anchor.parentNode.replaceChild(wrapper, anchor); |
- wrapper.appendChild(anchor); |
+ const id = anchor.getAttribute("data-tooltip"); |
- let tooltip = document.createElement("div"); |
+ anchor.classList.add("icon", "tooltip"); |
+ |
+ const tooltip = document.createElement("div"); |
tooltip.setAttribute("role", "tooltip"); |
- let paragraph = document.createElement("p"); |
+ const paragraph = document.createElement("p"); |
paragraph.textContent = getMessage(id); |
tooltip.appendChild(paragraph); |
- wrapper.appendChild(tooltip); |
+ anchor.appendChild(tooltip); |
+ |
+ // if focused and the mouse reaches another (?) |
+ // blur the active element to drop previous tooltip |
+ anchor.addEventListener("mouseover", dropActiveElement); |
} |
} |
+ function dropActiveElement(event) |
+ { |
+ const active = event.target.ownerDocument.activeElement; |
+ if (active) |
+ active.blur(); |
+ } |
+ |
ext.onMessage.addListener((message) => |
{ |
switch (message.type) |