Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change translation on the fly #3764

Merged
merged 7 commits into from
Jan 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/renderer/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export function rendererMap(context) {

selection
.on('dblclick.map', dblClick)
.call(zoom, projection.transform());
.call(zoom)
.call(zoom.transform, projection.transform());

supersurface = selection.append('div')
.attr('id', 'supersurface')
Expand Down
2 changes: 1 addition & 1 deletion modules/svg/labels.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as d3 from 'd3';
import _ from 'lodash';
import rbush from 'rbush';
import { textDirection } from '../util/locale';

import {
geoExtent,
Expand Down Expand Up @@ -355,7 +356,6 @@ export function svgLabels(projection, context) {

var coord = projection(entity.loc),
margin = 2,
textDirection = detected.textDirection,
offset = pointOffsets[textDirection],
p = {
height: height,
Expand Down
37 changes: 30 additions & 7 deletions modules/ui/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ import { uiCmd } from './cmd';


export function uiInit(context) {
var uiInitCounter = 0;


function render(container) {
container
.attr('dir', textDirection);

var map = context.map();

var hash = behaviorHash(context);
Expand Down Expand Up @@ -71,10 +76,6 @@ export function uiInit(context) {
.attr('dir', 'ltr')
.call(map);

if (textDirection === 'rtl') {
d3.select('body').attr('dir', 'rtl');
}

content
.call(uiMapInMap(context));

Expand Down Expand Up @@ -228,6 +229,7 @@ export function uiInit(context) {

var mapDimensions = map.dimensions();


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra newline

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, I've been adding 2 spaces before function blocks and anywhere else I want documentation to go.

function onResize() {
mapDimensions = utilGetDimensions(content, true);
map.dimensions(mapDimensions);
Expand All @@ -247,6 +249,7 @@ export function uiInit(context) {
};
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra newline

// pan amount
var pa = 10;

Expand All @@ -266,9 +269,11 @@ export function uiInit(context) {

context.enter(modeBrowse(context));

context.container()
.call(uiSplash(context))
.call(uiRestore(context));
if (!uiInitCounter++) {
context.container()
.call(uiSplash(context))
.call(uiRestore(context));
}

var authenticating = uiLoading(context)
.message(t('loading_auth'))
Expand All @@ -282,10 +287,15 @@ export function uiInit(context) {
.on('authDone.ui', function() {
authenticating.close();
});

uiInitCounter++;
}


var renderCallback;

function ui(node, callback) {
renderCallback = callback;
var container = d3.select(node);
context.container(container);
context.loadLocale(function(err) {
Expand All @@ -298,6 +308,19 @@ export function uiInit(context) {
});
}


ui.restart = function(arg) {
context.locale(arg);
context.loadLocale(function(err) {
if (!err) {
context.container().selectAll('*').remove();
render(context.container());
if (renderCallback) renderCallback();
}
});
};


ui.sidebar = uiSidebar(context);

return ui;
Expand Down