From f16cafc034e48290b93a72de9aa4c64cfcb260eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 7 Feb 2019 11:18:29 +0100 Subject: [PATCH] handle users typing subjects in all caps (#30454) --- javascripts/theme.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/javascripts/theme.js b/javascripts/theme.js index ff83fe5..03548b3 100644 --- a/javascripts/theme.js +++ b/javascripts/theme.js @@ -107,6 +107,19 @@ function alter_new_issue_page() { return false; } }); + $('input#issue_subject').on('change', function(evt) { + var val = $(this).val(); + var uppercases = val.match(/[A-Z]/g).length; + var all_letters = val.match(/[^\s+]/g).length; + var ratio = uppercases / all_letters; + if (ratio > 0.6) { // more than 60% of uppercase letters + // change to lower case + $(this).val(val.toLowerCase()); + // and disable high priority values + $('#issue_priority_id option + option + option').attr('disabled', true); + } + return true; + }); } $(function() {