From 6c3e745d5d13029e9ade6b45f84964090ba88968 Mon Sep 17 00:00:00 2001 From: Richard Schreiber Date: Fri, 20 Jan 2023 08:50:08 +0100 Subject: [PATCH] Control: Remove empty help-text for colorpickers with no-contrast (#3042) --- src/pretix/static/pretixcontrol/js/ui/main.js | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/pretix/static/pretixcontrol/js/ui/main.js b/src/pretix/static/pretixcontrol/js/ui/main.js index 471e792f7..26b0e988d 100644 --- a/src/pretix/static/pretixcontrol/js/ui/main.js +++ b/src/pretix/static/pretixcontrol/js/ui/main.js @@ -291,7 +291,7 @@ var form_handlers = function (el) { maxTop: 200 } } - }).on('changeColor create', function (e) { + }).not(".no-contrast").on('changeColor create', function (e) { var rgb = $(this).colorpicker('color').toRGB(); var c = contrast([255,255,255], [rgb.r, rgb.g, rgb.b]); var mark = 'times'; @@ -302,21 +302,19 @@ var form_handlers = function (el) { if ($(this).val() === "") { $note.remove(); } - if (!$(this).is(".no-contrast")) { - if (c > 7) { - $note.html("") - .append(gettext('Your color has great contrast and is very easy to read!')); - $note.addClass("text-success").removeClass("text-warning").removeClass("text-danger"); - } else if (c > 2.5) { - $note.html("") - .append(gettext('Your color has decent contrast and is probably good-enough to read!')); - $note.removeClass("text-success").removeClass("text-warning").removeClass("text-danger"); - } else { - $note.html("") - .append(gettext('Your color has bad contrast for text on white background, please choose a darker ' + - 'shade.')); - $note.addClass("text-danger").removeClass("text-success").removeClass("text-warning"); - } + if (c > 7) { + $note.html("") + .append(gettext('Your color has great contrast and is very easy to read!')); + $note.addClass("text-success").removeClass("text-warning").removeClass("text-danger"); + } else if (c > 2.5) { + $note.html("") + .append(gettext('Your color has decent contrast and is probably good-enough to read!')); + $note.removeClass("text-success").removeClass("text-warning").removeClass("text-danger"); + } else { + $note.html("") + .append(gettext('Your color has bad contrast for text on white background, please choose a darker ' + + 'shade.')); + $note.addClass("text-danger").removeClass("text-success").removeClass("text-warning"); } });