handle users typing subjects in all caps (#30454)

This commit is contained in:
Frédéric Péters 2019-02-07 11:18:29 +01:00
parent 68162dc7be
commit f16cafc034
1 changed files with 13 additions and 0 deletions

View File

@ -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() {