Commit 69abf564 authored by Thomas Greiner's avatar Thomas Greiner

Issue 6758 - Made tooltips open on click

parent c279adea
......@@ -15,6 +15,9 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
@import "io-popout.scss";
@import "io-popout-fixes.scss";
html
{
font-size: 16px;
......@@ -352,22 +355,22 @@ button[role="checkbox"][disabled].icon.toggle::before
background-image: url(icons/checkmark.svg?approved#approved);
}
.context-menu .icon.update-subscription::before
.icon.update-subscription::before
{
background-image: url(icons/reload.svg);
}
.context-menu .icon.website::before
.icon.website::before
{
background-image: url(icons/globe.svg);
}
.context-menu .icon.source::before
.icon.source::before
{
background-image: url(icons/code.svg);
}
.context-menu .icon.delete::before
.icon.delete::before
{
background-image: url(icons/trash.svg?default#default);
}
......@@ -408,17 +411,6 @@ button[role="checkbox"][disabled].icon.toggle::before
background-image: url(icons/delete.svg?tertiary-hover#tertiary-hover);
}
.tooltip::before
{
width: 1.1rem;
height: 1.1rem;
}
.icon.tooltip::before
{
background-image: url(icons/tooltip.svg);
}
#dialog .table.list li button.icon::before
{
width: 1.3rem;
......@@ -1232,159 +1224,6 @@ html[dir="rtl"] #content-whitelist form button
border: 1px solid #CDCDCD;
}
/*
Context menu
*/
li [role="menubar"]
{
position: relative;
}
[role="tooltip"]
{
right: -0.8rem;
margin-top: 0.8rem;
opacity: 1;
padding: 0.2rem 1rem;
position: absolute;
-webkit-transition: opacity 200ms ease-in-out 400ms,
visibility 0ms linear 400ms;
transition: opacity 200ms ease-in-out 400ms,
visibility 0ms linear 400ms;
visibility: visible;
width: 15rem;
z-index: 1;
}
html[dir="rtl"] [role="tooltip"]
{
right: auto;
left: -0.8rem;
}
[role="tooltip"],
.context-menu .content
{
border: 1px solid #077CA6;
border-radius: 3px;
background-color: #FFFFFF;
}
.tooltip:not(:hover) > [role="tooltip"],
[role="tooltip"]:hover
{
visibility: hidden;
opacity: 0;
-webkit-transition-delay: 0ms;
transition-delay: 0ms;
}
.context-menu
{
position: absolute;
right: 2.5rem;
top: -2rem;
z-index: 1;
visibility: hidden;
}
html[dir="rtl"] .context-menu
{
right: auto;
left: 2.5rem;
}
.context-menu .content
{
padding: 0rem;
position: relative;
cursor: default;
}
li.show-context-menu .context-menu
{
visibility: visible;
}
[role="tooltip"]::before,
.context-menu::before
{
content: "";
width: 0rem;
height: 0rem;
position: absolute;
}
[role="tooltip"]::before
{
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #077CA6;
top: -10px;
right: 15px;
}
html[dir="rtl"] [role="tooltip"]::before
{
right: auto;
left: 15px;
}
.context-menu::before
{
border-left: 10px solid #077CA6;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
top: 22px;
right: -0.5rem;
}
html[dir="rtl"] .context-menu::before
{
border-left: 0rem;
border-right: 10px solid #077CA6;
right: auto;
left: -0.5rem;
}
.context-menu li[role="menuitem"]
{
width: 12.2rem;
border: 0rem;
padding: 0rem;
}
.context-menu li[role="menuitem"] > *
{
width: 100%;
display: flex;
border: 0rem;
padding: 0.7rem 0rem;
color: #077CA6;
align-items: center;
font-size: 1rem;
font-weight: 400;
text-transform: none;
text-decoration: none;
}
.context-menu li[role="menuitem"] > *:hover,
.context-menu li[role="menuitem"] > *:focus
{
background-color: #E1F2FA;
cursor: pointer;
}
.context-menu li[role="menuitem"] .icon::before
{
height: 1rem;
width: 1rem;
margin: 0rem 1.1rem;
border: 0rem;
}
/*
Help tab content
*/
......
/*
* This file is part of Adblock Plus <https://adblockplus.org/>,
* Copyright (C) 2006-present eyeo GmbH
*
* Adblock Plus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* Adblock Plus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
io-popout ul
{
padding: 0;
}
io-popout li
{
list-style: none;
}
.table.cols io-popout li
{
padding: 0;
border: 0;
}
.table.cols io-popout li > *
{
width: 100%;
display: flex;
border: 0rem;
padding: 0.7rem 0rem;
color: #077CA6;
align-items: center;
font-size: 1rem;
font-weight: 400;
text-transform: none;
text-decoration: none;
}
io-popout li > *:hover,
io-popout li > *:focus
{
background-color: #E1F2FA;
cursor: pointer;
}
io-popout li .icon::before
{
height: var(--icon-size-inner);
width: var(--icon-size-inner);
margin: 0 var(--icon-size-inner);
border: none;
}
/*
* This file is part of Adblock Plus <https://adblockplus.org/>,
* Copyright (C) 2006-present eyeo GmbH
*
* Adblock Plus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* Adblock Plus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
io-popout
{
--background-color: #FFF;
--border: 1px solid #077CA6;
--icon-size-inner: 1.1rem;
--icon-size-outer: 1.5rem;
--pointer-size: 10px;
--pointer-offset-out: calc(var(--pointer-size) / -2 - 1px);
--pointer-offset-start: calc(var(--icon-size-outer) +
var(--pointer-offset-out));
--content-offset-out: calc(-0.5 * var(--icon-size-outer));
--content-offset-start: calc(1.5 * var(--icon-size-outer));
}
/*
* This component is not keyboard-accessible yet but we need it to be focusable
* to detect when we can close it
*/
io-popout:focus
{
outline: none;
}
/* Prevent pre-rendered content to show up before component has loaded */
io-popout > :not(.wrapper)
{
display: none;
}
/*******************************************************************************
* Anchor
******************************************************************************/
io-popout > .wrapper
{
display: inline-block;
position: relative;
}
io-popout > .wrapper::before
{
width: var(--icon-size-inner);
height: var(--icon-size-inner);
cursor: pointer;
}
io-popout > .wrapper.menubar::before
{
background-image: url(icons/gear.svg?default#default);
}
io-popout > .wrapper.tooltip::before
{
background-image: url(icons/tooltip.svg);
}
/*******************************************************************************
* Anchor pointer
******************************************************************************/
io-popout > .wrapper > [role]::before
{
display: block;
position: absolute;
z-index: 2;
width: var(--pointer-size);
height: var(--pointer-size);
border: var(--border);
border-bottom: none;
border-right: none;
background-color: var(--background-color);
content: "";
}
io-popout[expanded=""] > .wrapper > [role]::before,
io-popout[expanded="above"] > .wrapper > [role]::before,
io-popout[expanded="below"] > .wrapper > [role]::before
{
right: var(--pointer-offset-start);
}
html[dir="rtl"] io-popout[expanded=""] > .wrapper > [role]::before,
html[dir="rtl"] io-popout[expanded="above"] > .wrapper > [role]::before,
html[dir="rtl"] io-popout[expanded="below"] > .wrapper > [role]::before
{
left: var(--pointer-offset-start);
right: auto;
}
io-popout[expanded=""] > .wrapper > [role]::before,
io-popout[expanded="below"] > .wrapper > [role]::before
{
top: var(--pointer-offset-out);
transform: rotate(45deg);
}
io-popout[expanded="above"] > .wrapper > [role]::before
{
bottom: var(--pointer-offset-out);
transform: rotate(-135deg);
}
io-popout[expanded="start"] > .wrapper > [role]::before
{
z-index: 1;
top: var(--pointer-offset-start);
right: var(--pointer-offset-out);
transform: rotate(135deg);
}
html[dir="rtl"] io-popout[expanded="start"] > .wrapper > [role]::before
{
left: var(--pointer-offset-out);
right: auto;
transform: rotate(-45deg);
}
/*******************************************************************************
* Content
******************************************************************************/
io-popout > .wrapper > [role]
{
position: absolute;
z-index: 1;
line-height: 1.5rem;
border: var(--border);
border-radius: 3px;
background-color: var(--background-color);
cursor: default;
}
io-popout [aria-hidden="true"]
{
display: none;
}
io-popout[expanded=""] > .wrapper > [role],
io-popout[expanded="above"] > .wrapper > [role],
io-popout[expanded="below"] > .wrapper > [role]
{
right: var(--content-offset-out);
}
html[dir="rtl"] io-popout[expanded=""] > .wrapper > [role],
html[dir="rtl"] io-popout[expanded="above"] > .wrapper > [role],
html[dir="rtl"] io-popout[expanded="below"] > .wrapper > [role]
{
left: var(--content-offset-out);
right: auto;
}
io-popout[expanded=""] > .wrapper > [role],
io-popout[expanded="below"] > .wrapper > [role]
{
top: var(--content-offset-start);
}
io-popout[expanded="above"] > .wrapper > [role]
{
bottom: var(--content-offset-start);
}
io-popout[expanded="start"] > .wrapper > [role]
{
top: var(--content-offset-out);
right: var(--content-offset-start);
}
html[dir="rtl"] io-popout[expanded="start"] > .wrapper > [role]
{
left: var(--content-offset-start);
right: auto;
}
io-popout > .wrapper > [role="menubar"]
{
width: 12.2rem;
}
io-popout > .wrapper > [role="tooltip"],
{
width: 15rem;
}
/*
* We need to ensure that any content overlays the anchor pointer or otherwise
* its inner half becomes visible when the content's background color changes
*/
io-popout > .wrapper > [role] *
{
z-index: 3;
}
io-popout .close
{
position: absolute;
top: 10px;
right: 10px;
}
html[dir="rtl"] io-popout .close
{
left: 10px;
right: auto;
}
io-popout .close:focus
{
outline: none;
}
io-popout p
{
padding: 0.2rem 1rem;
}
io-popout [role="tooltip"] p
{
/* Approximated to achieve a total tooltip height of 12.5em without
hiding overflowing anchor pointer */
max-height: 9em;
overflow-y: auto;
}
io-popout .close + *
{
margin-top: 2em;
}
......@@ -88,7 +88,7 @@
<template>
<button data-action="toggle-remove-subscription" data-disable="preconfigured" role="checkbox" class="control icon"></button>
<span data-display="title"></span>
<span data-tooltip="options_protection_%value%_tooltip"></span>
<io-popout type="tooltip" i18n-body="options_protection_%value%_tooltip"></io-popout>
</template>
</ul>
</section>
......@@ -154,7 +154,7 @@
<template>
<button data-action="toggle-remove-subscription" data-disable="preconfigured" role="checkbox" class="control icon"></button>
<span class="i18n_options_anti_cv_title"></span>
<span data-tooltip="options_anti_cv_tooltip"></span>
<io-popout type="tooltip" i18n-body="options_anti_cv_tooltip"></io-popout>
<span class="i18n_options_new_label new"></span>
</template>
</ul>
......@@ -220,17 +220,17 @@
<li data-pref="shouldShowBlockElementMenu">
<button class="icon" role="checkbox" data-action="toggle-pref"></button>
<span class="i18n_options_customize_blockElement" data-display="title"></span>
<span data-tooltip="options_customize_blockElement_tooltip"></span>
<io-popout type="tooltip" i18n-body="options_customize_blockElement_tooltip"></io-popout>
</li>
<li data-pref="show_devtools_panel">
<button class="icon" role="checkbox" data-action="toggle-pref"></button>
<span class="i18n_options_customize_showDevToolsPanel" data-display="title"></span>
<span data-tooltip="options_customize_showDevToolsPanel_tooltip"></span>
<io-popout type="tooltip" i18n-body="options_customize_showDevToolsPanel_tooltip"></io-popout>
</li>
<li data-pref="notifications_ignoredcategories">
<button class="icon" role="checkbox" data-action="toggle-pref"></button>
<span class="i18n_options_customize_showNotifications" data-display="title"></span>
<span data-tooltip="options_customize_showNotifications_tooltip"></span>
<io-popout type="tooltip" i18n-body="options_customize_showNotifications_tooltip"></io-popout>
</li>
</ul>
</section>
......@@ -268,25 +268,22 @@
<span class="message"></span>
</div>
<div class="col5">
<button data-action="open-context-menu" class="icon gear"></button>
<div role="menubar" class="context-menu-wrapper">
<div class="context-menu">
<ul class="content" role="menu">
<li role="menuitem">
<button class="i18n_options_filterList_updateNow icon update-subscription" data-action="update-subscription"></button>
</li>
<li role="menuitem">
<a class="i18n_options_filterList_website icon website" target="_blank"></a>
</li>
<li role="menuitem">
<a class="i18n_options_filterList_source icon source" target="_blank"></a>
</li>
<li role="menuitem">
<button class="i18n_options_control_remove_title icon delete" data-hide="preconfigured" data-action="remove-subscription"></button>
</li>
</ul>
</div>
</div>
<io-popout type="menubar">
<ul class="content" role="menu">
<li role="menuitem">
<button class="i18n_options_filterList_updateNow icon update-subscription" data-action="update-subscription"></button>
</li>
<li role="menuitem">
<a class="i18n_options_filterList_website icon website" target="_blank"></a>
</li>
<li role="menuitem">
<a class="i18n_options_filterList_source icon source" target="_blank"></a>
</li>
<li role="menuitem">
<button class="i18n_options_control_remove_title icon delete" data-hide="preconfigured" data-action="remove-subscription"></button>
</li>
</ul>
</io-popout>
</div>
<div class="col5">
<button data-hide="preconfigured" data-action="remove-subscription" class="control icon delete"></button>
......
......@@ -20,6 +20,8 @@
"use strict";
require("./io-popout");
let subscriptionsMap = Object.create(null);
let filtersMap = Object.create(null);
let acceptableAdsUrl = null;
......@@ -146,14 +148,14 @@ Collection.prototype.addItem = function(item)
listItem.setAttribute("data-access", item.url || item.text);
listItem.setAttribute("role", "section");
const tooltip = listItem.querySelector("[data-tooltip]");
const tooltip = listItem.querySelector("io-popout[type='tooltip']");
if (tooltip)
{
let tooltipId = tooltip.getAttribute("data-tooltip");
let tooltipId = tooltip.getAttribute("i18n-body");
tooltipId = tooltipId.replace("%value%", item.recommended);
if (getMessage(tooltipId))
{
tooltip.setAttribute("data-tooltip", tooltipId);
tooltip.setAttribute("i18n-body", tooltipId);
}
}
......@@ -307,7 +309,7 @@ Collection.prototype.updateItem = function(item)
}
}
const websiteElement = element.querySelector(".context-menu .website");
const websiteElement = element.querySelector("io-popout .website");
if (websiteElement)
{
if (item.homepage)
......@@ -316,7 +318,7 @@ Collection.prototype.updateItem = function(item)
websiteElement.setAttribute("aria-hidden", true);
}
const sourceElement = element.querySelector(".context-menu .source");
const sourceElement = element.querySelector("io-popout .source");
if (sourceElement)
sourceElement.setAttribute("href", item.url);
......@@ -434,7 +436,6 @@ function addSubscription(subscription)
collection.addItem(subscription);
subscriptionsMap[url] = subscription;
updateTooltips();
}
function updateSubscription(subscription)
......@@ -454,7 +455,6 @@ function updateSubscription(subscription)
if (subscription.disabled == false)
{
collections.more.addItem(subscription);
updateTooltips();
}
else
{
......@@ -641,12 +641,6 @@ function execAction(action, element)
closeDialog();
break;
}
case "open-context-menu": {
const listItem = findParentData(element, "access", true);
if (listItem && !listItem.classList.contains("show-context-menu"))
listItem.classList.add("show-context-menu");
break;
}
case "open-dialog": {
const dialog = findParentData(element, "dialog", false);
openDialog(dialog);
......@@ -788,10 +782,6 @@ function setCustomFiltersView(mode)
function onClick(e)
{
const context = document.querySelector(".show-context-menu");
if (context)
context.classList.remove("show-context-menu");
let actions = findParentData(e.target, "action", false);
if (!actions)
return;
......@@ -912,8 +902,6 @@ function onDOMLoaded()
[addonVersion]);
});
updateTooltips();
// Initialize interactive UI elements
document.body.addEventListener("click", onClick, false);
document.body.addEventListener("keyup", onKeyUp, false);
......@@ -1409,29 +1397,6 @@ function onPrefMessage(key, value, initial)
checkbox.setAttribute("aria-checked", value);
}
function updateTooltips()
{
const anchors = document.querySelectorAll(":not(.tooltip) > [data-tooltip]");
for (const anchor of anchors)
{
const id = anchor.getAttribute("data-tooltip");
const wrapper = document.createElement("div");
wrapper.className = "icon tooltip";
anchor.parentNode.replaceChild(wrapper, anchor);
wrapper.appendChild(anchor);
const tooltip = document.createElement("div");
tooltip.setAttribute("role", "tooltip");
const paragraph = document.createElement("p");
paragraph.textContent = getMessage(id);
tooltip.appendChild(paragraph);
wrapper.appendChild(tooltip);
}
}
const port = browser.runtime.connect({name: "ui"});
port.onMessage.addListener((message) =>
......
/*
* This file is part of Adblock Plus <https://adblockplus.org/>,
* Copyright (C) 2006-present eyeo GmbH
*
* Adblock Plus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* Adblock Plus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.