make colorpicker notify embedder on closing

re-enables Esc key in config-dialog after colorpicker closed itself due to an outside click
This commit is contained in:
tophf 2017-12-06 00:24:27 +03:00
parent 07a0518586
commit 85c67872a5

View File

@ -218,8 +218,11 @@
setFromHexLettercaseElement(); setFromHexLettercaseElement();
} }
function hide() { function hide({notify = true} = {}) {
if (shown) { if (shown) {
if (notify) {
colorpickerCallback('');
}
unregisterEvents(); unregisterEvents();
focusNoScroll(prevFocusedElement); focusNoScroll(prevFocusedElement);
$root.remove(); $root.remove();
@ -553,6 +556,12 @@
releaseMouse(event, ['saturation', 'hue', 'opacity']); releaseMouse(event, ['saturation', 'hue', 'opacity']);
} }
function onMouseDown(event) {
if (event.button === 0 && !event.target.closest('.colorpicker-popup')) {
hide();
}
}
function onMouseMove(event) { function onMouseMove(event) {
if (event.button !== 0) { if (event.button !== 0) {
return; return;
@ -589,7 +598,7 @@
colorpickerCallback(e.which === 27 ? '' : undefined); colorpickerCallback(e.which === 27 ? '' : undefined);
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
hide(); hide({notify: false});
break; break;
} }
} }
@ -601,12 +610,6 @@
} }
} }
function onMouseDown(event) {
if (!event.target.closest('.colorpicker-popup')) {
hide();
}
}
//endregion //endregion
//region Event utilities //region Event utilities