mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-30 17:00:35 +02:00
update RTL detection
This commit is contained in:
@@ -3355,15 +3355,15 @@ img.tile-removing {
|
||||
|
||||
.mly-wrapper.active {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
/* Right-to-left localization settings */
|
||||
|
||||
/* sidebar */
|
||||
[dir='rtl'] #sidebar {
|
||||
float: right;
|
||||
}
|
||||
|
||||
#sidebar .search-header .icon {
|
||||
[dir='rtl'] #sidebar .search-header .icon {
|
||||
left: auto;
|
||||
right: 10px;
|
||||
}
|
||||
@@ -3542,7 +3542,7 @@ img.tile-removing {
|
||||
border-radius: 0 0 4px 0;
|
||||
}
|
||||
|
||||
[dir='rtl'] .geolocate-control button svg, [dir='rtl'] .list-item-gpx-browse svg {
|
||||
[dir='rtl'] .list-item-gpx-browse svg {
|
||||
transform: rotateY(180deg);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { d3keybinding } from '../lib/d3.keybinding.js';
|
||||
import { t } from '../util/locale';
|
||||
import { t, textDirection } from '../util/locale';
|
||||
import { rendererBackgroundSource } from '../renderer/index';
|
||||
import { geoMetersToOffset, geoOffsetToMeters } from '../geo/index';
|
||||
import { utilDetect } from '../util/detect';
|
||||
@@ -150,7 +150,7 @@ export function uiBackground(context) {
|
||||
.attr('class', 'best')
|
||||
.call(tooltip()
|
||||
.title(t('background.best_imagery'))
|
||||
.placement((iD.detect().textDirection === 'rtl') ? 'right' : 'left'))
|
||||
.placement((textDirection === 'rtl') ? 'right' : 'left'))
|
||||
.append('span')
|
||||
.html('★');
|
||||
|
||||
@@ -337,7 +337,7 @@ export function uiBackground(context) {
|
||||
var content = selection.append('div')
|
||||
.attr('class', 'fillL map-overlay col3 content hide'),
|
||||
tooltipBehavior = tooltip()
|
||||
.placement((iD.detect().textDirection === 'rtl') ? 'right' : 'left')
|
||||
.placement((textDirection === 'rtl') ? 'right' : 'left')
|
||||
.html(true)
|
||||
.title(uiTooltipHtml(t('background.description'), key)),
|
||||
button = selection.append('button')
|
||||
@@ -369,7 +369,7 @@ export function uiBackground(context) {
|
||||
.on('click.set-opacity', setOpacity)
|
||||
.html('<div class="select-box"></div>')
|
||||
.call(tooltip()
|
||||
.placement((iD.detect().textDirection === 'rtl') ? 'right' : 'left'))
|
||||
.placement((textDirection === 'rtl') ? 'right' : 'left'))
|
||||
.append('div')
|
||||
.attr('class', 'opacity')
|
||||
.style('opacity', function(d) { return 1.25 - d; });
|
||||
@@ -388,7 +388,7 @@ export function uiBackground(context) {
|
||||
.attr('class', 'layer-browse')
|
||||
.call(tooltip()
|
||||
.title(t('background.custom_button'))
|
||||
.placement((iD.detect().textDirection === 'rtl') ? 'right' : 'left'))
|
||||
.placement((textDirection === 'rtl') ? 'right' : 'left'))
|
||||
.on('click', editCustom)
|
||||
.call(svgIcon('#icon-search'));
|
||||
|
||||
@@ -498,7 +498,7 @@ export function uiBackground(context) {
|
||||
.attr('class', 'nudge-reset disabled')
|
||||
.on('click', resetOffset)
|
||||
.call(
|
||||
(iD.detect().textDirection === 'rtl') ? svgIcon('#icon-redo') : svgIcon('#icon-undo')
|
||||
(textDirection === 'rtl') ? svgIcon('#icon-redo') : svgIcon('#icon-undo')
|
||||
);
|
||||
|
||||
context.map()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { t } from '../util/locale';
|
||||
import { t, textDirection } from '../util/locale';
|
||||
import { tooltip } from '../util/tooltip';
|
||||
import { actionChangeTags } from '../actions/index';
|
||||
import { modeBrowse } from '../modes/index';
|
||||
@@ -46,7 +46,7 @@ export function uiEntityEditor(context) {
|
||||
.attr('class', 'fl preset-reset preset-choose')
|
||||
.on('click', function() { dispatch.call('choose', this, activePreset); })
|
||||
.append('span')
|
||||
.html((iD.detect().textDirection === 'rtl') ? '►' : '◄');
|
||||
.html((textDirection === 'rtl') ? '►' : '◄');
|
||||
|
||||
enter
|
||||
.append('button')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { t } from '../util/locale';
|
||||
import { t, textDirection } from '../util/locale';
|
||||
import { tooltip } from '../util/tooltip';
|
||||
import { modeBrowse } from '../modes/index';
|
||||
import { geoExtent } from '../geo/index';
|
||||
@@ -55,6 +55,6 @@ export function uiGeolocate(context) {
|
||||
.on('click', click)
|
||||
.call(svgIcon('#icon-geolocate', 'light'))
|
||||
.call(tooltip()
|
||||
.placement((iD.detect().textDirection === 'rtl') ? 'right' : 'left'));
|
||||
.placement((textDirection === 'rtl') ? 'right' : 'left'));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import marked from 'marked';
|
||||
import { d3keybinding } from '../lib/d3.keybinding.js';
|
||||
import { t } from '../util/locale';
|
||||
import { t, textDirection } from '../util/locale';
|
||||
import { svgIcon } from '../svg/index';
|
||||
import { uiIntro } from './intro/index';
|
||||
import { uiTooltipHtml } from './tooltipHtml';
|
||||
@@ -113,7 +113,7 @@ export function uiHelp(context) {
|
||||
var pane = selection.append('div')
|
||||
.attr('class', 'help-wrap map-overlay fillL col5 content hide'),
|
||||
tooltipBehavior = tooltip()
|
||||
.placement((iD.detect().textDirection === 'rtl') ? 'right' : 'left')
|
||||
.placement((textDirection === 'rtl') ? 'right' : 'left')
|
||||
.html(true)
|
||||
.title(uiTooltipHtml(t('help.title'), key)),
|
||||
button = selection.append('button')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as d3 from 'd3';
|
||||
import { d3keybinding } from '../lib/d3.keybinding.js';
|
||||
import { t } from '../util/locale';
|
||||
import { t, textDirection } from '../util/locale';
|
||||
import { tooltip } from '../util/tooltip';
|
||||
import { utilDetect } from '../util/detect';
|
||||
import { utilSetDimensions } from '../util/dimensions';
|
||||
@@ -73,11 +73,11 @@ export function uiInit(context) {
|
||||
content
|
||||
.append('div')
|
||||
.attr('id', 'map')
|
||||
.attr('dir', 'auto')
|
||||
.attr('dir', 'ltr')
|
||||
.call(map);
|
||||
|
||||
if (iD.detect().textDirection === 'rtl') {
|
||||
d3.select('body').attr('dir', 'rtl');
|
||||
if (textDirection === 'rtl') {
|
||||
d3.select('body').attr('dir', 'rtl');
|
||||
}
|
||||
|
||||
content
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { d3keybinding } from '../lib/d3.keybinding.js';
|
||||
import { t } from '../util/locale';
|
||||
import { t, textDirection } from '../util/locale';
|
||||
import { svgIcon } from '../svg/index';
|
||||
import { uiTooltipHtml } from './tooltipHtml';
|
||||
import { tooltip } from '../util/tooltip';
|
||||
@@ -216,7 +216,7 @@ export function uiMapData(context) {
|
||||
.attr('class', 'list-item-gpx-extent')
|
||||
.call(tooltip()
|
||||
.title(t('gpx.zoom'))
|
||||
.placement((iD.detect().textDirection === 'rtl') ? 'right' : 'left'))
|
||||
.placement((textDirection === 'rtl') ? 'right' : 'left'))
|
||||
.on('click', function() {
|
||||
d3.event.preventDefault();
|
||||
d3.event.stopPropagation();
|
||||
@@ -229,7 +229,7 @@ export function uiMapData(context) {
|
||||
.attr('class', 'list-item-gpx-browse')
|
||||
.call(tooltip()
|
||||
.title(t('gpx.browse'))
|
||||
.placement((iD.detect().textDirection === 'rtl') ? 'right' : 'left'))
|
||||
.placement((textDirection === 'rtl') ? 'right' : 'left'))
|
||||
.on('click', function() {
|
||||
d3.select(document.createElement('input'))
|
||||
.attr('type', 'file')
|
||||
@@ -388,7 +388,7 @@ export function uiMapData(context) {
|
||||
.append('div')
|
||||
.attr('class', 'fillL map-overlay col3 content hide'),
|
||||
tooltipBehavior = tooltip()
|
||||
.placement((iD.detect().textDirection === 'rtl') ? 'right' : 'left')
|
||||
.placement((textDirection === 'rtl') ? 'right' : 'left')
|
||||
.html(true)
|
||||
.title(uiTooltipHtml(t('map_data.description'), key)),
|
||||
button = selection
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { d3combobox } from '../lib/d3.combobox.js';
|
||||
import { t } from '../util/locale';
|
||||
import { t, textDirection } from '../util/locale';
|
||||
import { modeBrowse } from '../modes/index';
|
||||
import { svgIcon } from '../svg/index';
|
||||
import { uiDisclosure } from './disclosure';
|
||||
@@ -161,7 +161,7 @@ export function uiPreset(context) {
|
||||
.attr('class', 'modified-icon')
|
||||
.attr('tabindex', -1)
|
||||
.call(
|
||||
(iD.detect().textDirection === 'rtl') ? svgIcon('#icon-redo') : svgIcon('#icon-undo')
|
||||
(textDirection === 'rtl') ? svgIcon('#icon-redo') : svgIcon('#icon-undo')
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import { utilRebind } from '../util/rebind';
|
||||
import { d3keybinding } from '../lib/d3.keybinding.js';
|
||||
import { t } from '../util/locale';
|
||||
import { t, textDirection } from '../util/locale';
|
||||
import { actionChangePreset } from '../actions/index';
|
||||
import { operationDelete } from '../operations/index';
|
||||
import { modeBrowse } from '../modes/index';
|
||||
@@ -44,7 +44,7 @@ export function uiPresetList(context) {
|
||||
.attr('class', 'preset-choose')
|
||||
.on('click', function() { dispatch.call('choose', this, currentPreset); })
|
||||
.append('span')
|
||||
.html((iD.detect().textDirection === 'rtl') ? '◄' : '►');
|
||||
.html((textDirection === 'rtl') ? '◄' : '►');
|
||||
} else {
|
||||
messagewrap
|
||||
.append('button')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as d3 from 'd3';
|
||||
import { d3keybinding } from '../lib/d3.keybinding.js';
|
||||
import { t } from '../util/locale';
|
||||
import { t, textDirection } from '../util/locale';
|
||||
import { svgIcon } from '../svg/index';
|
||||
import { uiCmd } from './cmd';
|
||||
import { uiTooltipHtml } from './tooltipHtml';
|
||||
@@ -46,12 +46,12 @@ export function uiUndoRedo(context) {
|
||||
|
||||
buttons.each(function(d) {
|
||||
var iconName = d.id;
|
||||
if (iD.detect().textDirection === 'rtl') {
|
||||
if (iconName === 'undo') {
|
||||
iconName = 'redo';
|
||||
} else if (iconName === 'redo') {
|
||||
iconName = 'undo';
|
||||
}
|
||||
if (textDirection === 'rtl') {
|
||||
if (iconName === 'undo') {
|
||||
iconName = 'redo';
|
||||
} else if (iconName === 'redo') {
|
||||
iconName = 'undo';
|
||||
}
|
||||
}
|
||||
d3.select(this)
|
||||
.call(svgIcon('#icon-' + iconName));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { d3keybinding } from '../lib/d3.keybinding.js';
|
||||
import { t } from '../util/locale';
|
||||
import { t, textDirection } from '../util/locale';
|
||||
import { svgIcon } from '../svg/index';
|
||||
import { uiCmd } from './cmd';
|
||||
import { uiTooltipHtml } from './tooltipHtml';
|
||||
@@ -57,7 +57,7 @@ export function uiZoom(context) {
|
||||
.attr('class', function(d) { return d.id; })
|
||||
.on('click.editor', function(d) { d.action(); })
|
||||
.call(tooltip()
|
||||
.placement((iD.detect().textDirection === 'rtl') ? 'right' : 'left')
|
||||
.placement((textDirection === 'rtl') ? 'right' : 'left')
|
||||
.html(true)
|
||||
.title(function(d) {
|
||||
return uiTooltipHtml(d.title, d.key);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { currentLocale } from './locale';
|
||||
import { currentLocale, setTextDirection } from './locale';
|
||||
|
||||
export function utilDetect() {
|
||||
var detected = {};
|
||||
@@ -64,6 +64,13 @@ export function utilDetect() {
|
||||
detected.locale = loadedLocale;
|
||||
}
|
||||
|
||||
if (['ar', 'fa', 'iw', 'dv'].indexOf(detected.locale.split('-')[0]) > -1 || window.location.href.indexOf('rtl-test-rtl') > -1) {
|
||||
detected.textDirection = 'rtl';
|
||||
} else {
|
||||
detected.textDirection = 'ltr';
|
||||
}
|
||||
setTextDirection(detected.textDirection);
|
||||
|
||||
detected.host = window.location && (window.location.origin + window.location.pathname);
|
||||
|
||||
detected.filedrop = (window.FileReader && 'ondrop' in window);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
var translations = Object.create(null);
|
||||
|
||||
export var currentLocale = 'en';
|
||||
export var textDirection = 'ltr';
|
||||
|
||||
export function setLocale(_) {
|
||||
if (translations[_] !== undefined) {
|
||||
@@ -47,3 +48,13 @@ export function t(s, o, loc) {
|
||||
|
||||
return missing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given string 'ltr' or 'rtl', save that setting
|
||||
*
|
||||
* @param {string} s ltr or rtl
|
||||
*/
|
||||
|
||||
export function setTextDirection(dir) {
|
||||
textDirection = dir;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { t } from './locale';
|
||||
import { t, textDirection } from './locale';
|
||||
import { utilDetect } from './detect';
|
||||
import { remove as removeDiacritics } from 'diacritics';
|
||||
|
||||
@@ -174,8 +174,8 @@ export function utilFastMouse(container) {
|
||||
rectTop = rect.top,
|
||||
clientLeft = +container.clientLeft,
|
||||
clientTop = +container.clientTop;
|
||||
if (iD.detect().textDirection === 'rtl') {
|
||||
rectLeft = 0;
|
||||
if (textDirection === 'rtl') {
|
||||
rectLeft = 0;
|
||||
}
|
||||
return function(e) {
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user