Split into utilDisplayName / utilDisplayNameForPath

This is because utilDisplayName gets called a bunch of places and we
only want to add the Arabic reversal code for textpath labels
This commit is contained in:
Bryan Housel
2017-01-03 20:58:56 -05:00
parent c70b6278fc
commit d63c766e69
4 changed files with 24 additions and 4 deletions
+1
View File
@@ -3,6 +3,7 @@ export { utilEntitySelector } from './util';
export { utilEntityOrMemberSelector } from './util';
export { utilGetAllNodes } from './util';
export { utilDisplayName } from './util';
export { utilDisplayNameForPath } from './util';
export { utilDisplayType } from './util';
export { utilStringQs } from './util';
export { utilQsString } from './util';
+3
View File
@@ -1,3 +1,6 @@
// see https://github.com/openstreetmap/iD/pull/3707
// https://gist.github.com/mapmeld/556b09ddec07a2044c76e1ef45f01c60
var chars = {
// madda above alef
1570: { initial: 'آ‎', isolated: 'ﺁ', medial: 'ﺁ', final: 'ﺂ' },
+8 -1
View File
@@ -69,9 +69,16 @@ export function utilDisplayName(entity) {
}
}
return name;
}
export function utilDisplayNameForPath(entity) {
var name = utilDisplayName(entity);
var isFirefox = utilDetect().browser.toLowerCase().indexOf('firefox') > -1;
var arabicRegex = /[\u0600-\u06FF]/g;
if (!isFirefox && name && (entity.tags.highway || entity.tags.railway) && arabicRegex.test(name)) {
if (!isFirefox && name && arabicRegex.test(name)) {
name = fixArabicScriptTextForSvg(name);
}