close colorpicker config on Enter

This commit is contained in:
tophf 2017-11-22 05:35:24 +03:00
parent 612b21c732
commit 78bf2c8d9b

View File

@ -1,4 +1,4 @@
/* global CodeMirror loadScript editors */ /* global CodeMirror loadScript editors showHelp */
'use strict'; 'use strict';
window.initColorpicker = () => { window.initColorpicker = () => {
@ -75,9 +75,10 @@ window.initColorpicker = () => {
onkeydown(event) { onkeydown(event) {
const key = CodeMirror.keyName(event); const key = CodeMirror.keyName(event);
// ignore: [Shift?] characters, modifiers-only, [Shift?] Esc, Enter, [Shift?] Tab // ignore: [Shift?] characters, modifiers-only, [Shift?] Esc, Enter, [Shift?] Tab
if (/^(Enter|(Shift-)?(Esc|Tab))$/.test(key)) { if (key === 'Enter' || key === 'Esc') {
$('#help-popup .dismiss').onclick();
return; return;
} else if (/^((Shift-)?[!-~]|(Shift-?|Ctrl-?|Alt-?|Cmd-?)*)$/.test(key)) { } else if (/^((Shift-)?(Esc|Tab|[!-~])|(Shift-?|Ctrl-?|Alt-?|Cmd-?)*)$/.test(key)) {
this.setCustomValidity('Not allowed'); this.setCustomValidity('Not allowed');
} else { } else {
this.setCustomValidity(''); this.setCustomValidity('');