Change: drop excludeStyleByUrlRedundant plus menu height

This commit is contained in:
narcolepticinsomniac 2019-06-02 13:57:26 -04:00 committed by GitHub
parent 5686e93328
commit 29908feb1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 20 deletions

View File

@ -26,6 +26,10 @@ body {
margin: 0; margin: 0;
} }
.firefox, .firefox body:not(.search-results-shown) {
overflow: hidden;
}
.firefox body { .firefox body {
color: #000; color: #000;
background-color: #fff; background-color: #fff;
@ -327,8 +331,7 @@ a.configure[target="_blank"] .svg-icon.config {
opacity: 0; opacity: 0;
} }
.entry.menu-active .menu { .entry.menu-active .menu {
/* FIXME: avoid hard coded height */ height: var(--menu-height, 0px);
height: 72px;
opacity: 1; opacity: 1;
} }
/* accessibility */ /* accessibility */
@ -336,12 +339,12 @@ a.configure[target="_blank"] .svg-icon.config {
display: none; display: none;
border: none; border: none;
align-items: center; align-items: center;
padding: 0 0 0 20px; padding: 3px 0 3px 20px;
height: 24px;
background: none; background: none;
text-decoration: none; text-decoration: none;
flex: none;
} }
.entry.menu-active.accessible-items .menu-item { .entry.menu-active .menu-item {
display: flex; display: flex;
} }
.entry .menu-item.delete { .entry .menu-item.delete {
@ -360,6 +363,7 @@ a.configure[target="_blank"] .svg-icon.config {
} }
.entry .menu-icon { .entry .menu-icon {
width: 26px; width: 26px;
flex-shrink: 0;
} }
.entry .menu-icon > * { .entry .menu-icon > * {
display: block; display: block;

View File

@ -335,16 +335,7 @@ function createStyleElement(style) {
entry.classList.toggle('regexp-partial', style.sloppy); entry.classList.toggle('regexp-partial', style.sloppy);
$('.exclude-by-domain-checkbox', entry).checked = styleExcluded(style, 'domain'); $('.exclude-by-domain-checkbox', entry).checked = styleExcluded(style, 'domain');
$('.exclude-by-url-checkbox', entry).checked = styleExcluded(style, 'url');
const excludeByUrlCheckbox = $('.exclude-by-url-checkbox', entry);
const isRedundant = getExcludeRule('domain') === getExcludeRule('url');
excludeByUrlCheckbox.checked = !isRedundant && styleExcluded(style, 'url');
excludeByUrlCheckbox.disabled = isRedundant;
const excludeByUrlLabel = $('.exclude-by-url', entry);
excludeByUrlLabel.classList.toggle('disabled', isRedundant);
excludeByUrlLabel.title = isRedundant ?
chrome.i18n.getMessage('excludeStyleByUrlRedundant') : '';
return entry; return entry;
} }
@ -358,10 +349,16 @@ function styleExcluded({exclusions}, type) {
} }
function getExcludeRule(type) { function getExcludeRule(type) {
const u = new URL(tabURL);
if (type === 'domain') { if (type === 'domain') {
return new URL(tabURL).origin + '/*'; return u.origin + '/*';
} }
return tabURL + '*'; // current page
return escapeGlob(u.origin + u.pathname);
}
function escapeGlob(text) {
return text.replace(/\*/g, '\\*');
} }
Object.assign(handleEvent, { Object.assign(handleEvent, {
@ -397,11 +394,11 @@ Object.assign(handleEvent, {
}, },
toggleMenu(event) { toggleMenu(event) {
document.documentElement.classList.toggle('menu-shown')
const entry = handleEvent.getClickedStyleElement(event); const entry = handleEvent.getClickedStyleElement(event);
entry.classList.toggle('menu-active'); entry.classList.toggle('menu-active');
setTimeout(() => { const menu = entry.querySelector('.menu');
entry.classList.toggle('accessible-items'); menu.style.setProperty('--menu-height', menu.scrollHeight + 'px');
}, 250);
event.preventDefault(); event.preventDefault();
}, },