mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-20 17:18:51 +02:00
N°2396 Autocomplete: Harmonize accent handling
This commit is contained in:
@@ -511,15 +511,10 @@
|
||||
var length = 0;
|
||||
|
||||
function matchSubset(s, sub) {
|
||||
if (!options.matchCase)
|
||||
if (typeof s.normalize === 'function'){
|
||||
s = s.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, "");
|
||||
sub = sub.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, "");
|
||||
}
|
||||
else {
|
||||
s = ie_normalize(s.toLowerCase());
|
||||
sub = ie_normalize(sub.toLowerCase());
|
||||
}
|
||||
if (!options.matchCase){
|
||||
s = s.toLowerCase().latinise().replace(/[\u0300-\u036f]/g, "");
|
||||
sub = sub.toLowerCase().latinise().replace(/[\u0300-\u036f]/g, "");
|
||||
}
|
||||
var i = s.indexOf(sub);
|
||||
if (options.matchContains === "word"){
|
||||
i = s.toLowerCase().search("\\b" + sub.toLowerCase());
|
||||
@@ -528,23 +523,6 @@
|
||||
return i === 0 || options.matchContains;
|
||||
};
|
||||
|
||||
function ie_normalize(s)
|
||||
{
|
||||
//Cheap replacement for normalize on IE. Works only on a (small) subset of what's possible in unicode
|
||||
var r = s.toLowerCase();
|
||||
r = r.replace(new RegExp(/[àáâãäå]/g),"a");
|
||||
r = r.replace(new RegExp(/æ/g),"ae");
|
||||
r = r.replace(new RegExp(/ç/g),"c");
|
||||
r = r.replace(new RegExp(/[èéêë]/g),"e");
|
||||
r = r.replace(new RegExp(/[ìíîï]/g),"i");
|
||||
r = r.replace(new RegExp(/ñ/g),"n");
|
||||
r = r.replace(new RegExp(/[òóôõö]/g),"o");
|
||||
r = r.replace(new RegExp(/œ/g),"oe");
|
||||
r = r.replace(new RegExp(/[ùúûü]/g),"u");
|
||||
r = r.replace(new RegExp(/[ýÿ]/g),"y");
|
||||
return r;
|
||||
}
|
||||
|
||||
function add(q, value) {
|
||||
if (length > options.cacheLength){
|
||||
flush();
|
||||
|
||||
Reference in New Issue
Block a user