1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-23 02:42:41 +01:00

Support aborting "Pick" mode in element picker

This allows a user to go back to the previous selection after
entering interactive "Pick" mode.
This commit is contained in:
Raymond Hill 2024-03-03 20:08:15 -05:00
parent 0f4e50db07
commit a557f62112
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 12 additions and 8 deletions

View File

@ -266,9 +266,6 @@ html#ublock0-epicker,
height: 2em;
width: 2em;
}
#ublock0-epicker:not(.paused) #windowbar #minimize {
display: none;
}
#windowbar #quit:hover,
#windowbar #minimize:hover {
background-color: var(--surface-2)

View File

@ -161,9 +161,9 @@ dom.cl = class {
}
}
static remove(target, name) {
static remove(target, ...names) {
for ( const elem of normalizeTarget(target) ) {
elem.classList.remove(name);
elem.classList.remove(...names);
}
}

View File

@ -802,14 +802,16 @@ const showDialog = function(details) {
/******************************************************************************/
const pausePicker = function() {
pickerRoot.classList.add('paused');
dom.cl.add(pickerRoot, 'paused');
dom.cl.remove(pickerRoot, 'minimized');
svgListening(false);
};
/******************************************************************************/
const unpausePicker = function() {
pickerRoot.classList.remove('paused', 'preview');
dom.cl.remove(pickerRoot, 'paused', 'preview');
dom.cl.add(pickerRoot, 'minimized');
pickerContentPort.postMessage({
what: 'togglePreview',
state: false,
@ -836,7 +838,12 @@ const startPicker = function() {
$id('create').addEventListener('click', onCreateClicked);
$id('pick').addEventListener('click', onPickClicked);
$id('minimize').addEventListener('click', ( ) => {
dom.cl.toggle(dom.html, 'minimized');
if ( dom.cl.has(pickerRoot, 'paused') === false ) {
pausePicker();
onCandidateChanged();
} else {
dom.cl.toggle(pickerRoot, 'minimized');
}
});
$id('quit').addEventListener('click', onQuitClicked);
$id('move').addEventListener('mousedown', onStartMoving);