From 85c67872a5dcc2959f5ccc9eb3c9ea560e885dea Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 6 Dec 2017 00:24:27 +0300 Subject: [PATCH] make colorpicker notify embedder on closing re-enables Esc key in config-dialog after colorpicker closed itself due to an outside click --- vendor-overwrites/colorpicker/colorpicker.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/vendor-overwrites/colorpicker/colorpicker.js b/vendor-overwrites/colorpicker/colorpicker.js index 1fef896f..4668406c 100644 --- a/vendor-overwrites/colorpicker/colorpicker.js +++ b/vendor-overwrites/colorpicker/colorpicker.js @@ -218,8 +218,11 @@ setFromHexLettercaseElement(); } - function hide() { + function hide({notify = true} = {}) { if (shown) { + if (notify) { + colorpickerCallback(''); + } unregisterEvents(); focusNoScroll(prevFocusedElement); $root.remove(); @@ -553,6 +556,12 @@ releaseMouse(event, ['saturation', 'hue', 'opacity']); } + function onMouseDown(event) { + if (event.button === 0 && !event.target.closest('.colorpicker-popup')) { + hide(); + } + } + function onMouseMove(event) { if (event.button !== 0) { return; @@ -589,7 +598,7 @@ colorpickerCallback(e.which === 27 ? '' : undefined); e.preventDefault(); e.stopPropagation(); - hide(); + hide({notify: false}); break; } } @@ -601,12 +610,6 @@ } } - function onMouseDown(event) { - if (!event.target.closest('.colorpicker-popup')) { - hide(); - } - } - //endregion //region Event utilities