right-click to expand all applies-to targets

This commit is contained in:
tophf 2022-02-21 07:12:11 +03:00
parent ce7137c54d
commit d162928fb9
4 changed files with 30 additions and 21 deletions

View File

@ -59,8 +59,10 @@
</p> </p>
<p class="style-info" data-type="age"></p> <p class="style-info" data-type="age"></p>
<div class="applies-to"> <div class="applies-to">
<a class="expander" tabindex="0">
<svg><use xlink:href="#svg-icon-select-arrow"/></svg>
</a>
<div class="targets"></div> <div class="targets"></div>
<a class="expander" tabindex="0">...</a>
</div> </div>
</div> </div>
</template> </template>
@ -361,7 +363,7 @@
</symbol> </symbol>
<symbol id="svg-icon-select-arrow" viewBox="0 0 1792 1792"> <symbol id="svg-icon-select-arrow" viewBox="0 0 1792 1792">
<path fill-rule="evenodd" d="M1408 704q0 26-19 45l-448 448q-19 19-45 19t-45-19l-448-448q-19-19-19-45t19-45 45-19h896q26 0 45 19t19 45z"/> <path d="M1408 704q0 26-19 45l-448 448q-19 19-45 19t-45-19l-448-448q-19-19-19-45t19-45 45-19h896q26 0 45 19t19 45z"/>
</symbol> </symbol>
<symbol id="svg-icon-help" viewBox="0 0 14 16"> <symbol id="svg-icon-help" viewBox="0 0 14 16">

View File

@ -77,6 +77,13 @@ const Events = {
}, },
expandTargets(event, entry) { expandTargets(event, entry) {
if (event.type === 'contextmenu') {
event.preventDefault();
const ex = '.expanded';
$$(`.has-more${$(ex, entry) ? ex : `:not(${ex})`} .expander`)
.forEach(el => el.click());
return;
}
if (!entry._allTargetsRendered) { if (!entry._allTargetsRendered) {
createTargetsElement({entry, expanded: true}); createTargetsElement({entry, expanded: true});
getFaviconSrc(entry); getFaviconSrc(entry);
@ -100,10 +107,11 @@ const Events = {
entryClicked(event) { entryClicked(event) {
const target = event.target; const target = event.target;
const entry = target.closest('.entry'); const entry = target.closest('.entry');
for (const selector in Events.ENTRY_ROUTES) { const routes = Events['ENTRY_ROUTES' + (event.type === 'contextmenu' ? '_CTX' : '')];
for (const selector in routes) {
for (let el = target; el && el !== entry; el = el.parentElement) { for (let el = target; el && el !== entry; el = el.parentElement) {
if (el.matches(selector)) { if (el.matches(selector)) {
return Events.ENTRY_ROUTES[selector].call(el, event, entry); return routes[selector].call(el, event, entry);
} }
} }
} }
@ -146,6 +154,9 @@ Events.ENTRY_ROUTES = {
'.applies-to .expander': Events.expandTargets, '.applies-to .expander': Events.expandTargets,
'.configure-usercss': Events.config, '.configure-usercss': Events.config,
}; };
Events.ENTRY_ROUTES_CTX = {
'.applies-to .expander': Events.expandTargets,
};
/* exported handleBulkChange */ /* exported handleBulkChange */
function handleBulkChange() { function handleBulkChange() {

View File

@ -611,16 +611,13 @@ button .svg-icon,
padding-top: .25rem; padding-top: .25rem;
padding-bottom: .25rem; padding-bottom: .25rem;
} }
.newUI .targets { .newUI .targets {
overflow: hidden; overflow: hidden;
max-height: calc(var(--num-targets) * 18px); max-height: calc(var(--num-targets) * 18px);
} }
.newUI .applies-to.expanded .targets { .newUI .applies-to.expanded .targets {
max-height: none; max-height: none;
} }
.newUI .target { .newUI .target {
display: block; display: block;
overflow: hidden; overflow: hidden;
@ -631,25 +628,23 @@ button .svg-icon,
padding-right: 1rem; padding-right: 1rem;
line-height: 18px; line-height: 18px;
} }
.expander {
.newUI .applies-to .expander {
margin: 0;
cursor: pointer; cursor: pointer;
font-size: 3ex; position: absolute;
line-height: .5ex; right: 4px;
vertical-align: super; }
letter-spacing: .1ex; .expander svg {
text-decoration: none; width: 16px;
height: 16px;
fill: var(--c50);
}
.expanded .expander {
transform: rotate(180deg);
transform-origin: 8px 8px;
} }
.newUI .applies-to:not(.has-more) .expander { .newUI .applies-to:not(.has-more) .expander {
display: none; display: none;
} }
.newUI .has-favicons .applies-to .expander {
margin-left: 20px;
}
.newUI .target:hover { .newUI .target:hover {
background-color: inherit; background-color: inherit;
} }

View File

@ -48,6 +48,7 @@ newUI.renderClass();
prefs.ready, prefs.ready,
]); ]);
installed.on('click', Events.entryClicked); installed.on('click', Events.entryClicked);
installed.on('contextmenu', Events.entryClicked);
installed.on('mouseover', Events.lazyAddEntryTitle, {passive: true}); installed.on('mouseover', Events.lazyAddEntryTitle, {passive: true});
installed.on('mouseout', Events.lazyAddEntryTitle, {passive: true}); installed.on('mouseout', Events.lazyAddEntryTitle, {passive: true});
$('#sync-styles').onclick = $('#sync-styles').onclick =