From fb8efc2772ebda763e82e6d2249348725cece485 Mon Sep 17 00:00:00 2001 From: Kushan Joshi <0o3ko0@gmail.com> Date: Mon, 16 Jan 2017 11:49:06 +0530 Subject: [PATCH 1/6] Change translation on the fly --- modules/ui/init.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/ui/init.js b/modules/ui/init.js index 1b5661b42..7e93d9734 100644 --- a/modules/ui/init.js +++ b/modules/ui/init.js @@ -298,6 +298,19 @@ export function uiInit(context) { }); } + ui.restart = function(arg) { + context.container().selectAll('*').remove(); + context.locale(arg); + context.loadLocale(function(err) { + if (!err) { + context.history().unlock(); + render(context.container()); + } + }); + }; + + window.restart = ui.restart; + ui.sidebar = uiSidebar(context); return ui; From 1a5f155e3991d7f126c2b9148484eb7905244909 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Wed, 18 Jan 2017 23:44:03 +0530 Subject: [PATCH 2/6] Fix zoom behavior bind in map, delay removals to avoid flicker --- modules/renderer/map.js | 3 ++- modules/ui/init.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/renderer/map.js b/modules/renderer/map.js index fdc94c952..ec10c9201 100644 --- a/modules/renderer/map.js +++ b/modules/renderer/map.js @@ -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') diff --git a/modules/ui/init.js b/modules/ui/init.js index 7e93d9734..39e8fa15d 100644 --- a/modules/ui/init.js +++ b/modules/ui/init.js @@ -228,6 +228,7 @@ export function uiInit(context) { var mapDimensions = map.dimensions(); + function onResize() { mapDimensions = utilGetDimensions(content, true); map.dimensions(mapDimensions); @@ -247,6 +248,7 @@ export function uiInit(context) { }; } + // pan amount var pa = 10; @@ -285,7 +287,10 @@ export function uiInit(context) { } + var initCallback; + function ui(node, callback) { + initCallback = callback; var container = d3.select(node); context.container(container); context.loadLocale(function(err) { @@ -298,19 +303,21 @@ export function uiInit(context) { }); } + ui.restart = function(arg) { - context.container().selectAll('*').remove(); context.locale(arg); context.loadLocale(function(err) { if (!err) { + context.container().selectAll('*').remove(); context.history().unlock(); render(context.container()); + if (initCallback) initCallback(); } }); }; window.restart = ui.restart; - + ui.sidebar = uiSidebar(context); return ui; From d5805dc3cdf0694c1c01051818e062540b62dec9 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 19 Jan 2017 19:08:44 +0530 Subject: [PATCH 3/6] import textDirection instead of caching first time rtl detection --- modules/svg/labels.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/svg/labels.js b/modules/svg/labels.js index dfb0ce40e..94811840c 100644 --- a/modules/svg/labels.js +++ b/modules/svg/labels.js @@ -1,6 +1,7 @@ import * as d3 from 'd3'; import _ from 'lodash'; import rbush from 'rbush'; +import { textDirection } from '../util/locale'; import { geoExtent, @@ -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, From 513382f83573dc0e59d77c38594001658b3315aa Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 19 Jan 2017 19:09:33 +0530 Subject: [PATCH 4/6] Only show splash and history restore prompts the first time --- modules/ui/init.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/ui/init.js b/modules/ui/init.js index 39e8fa15d..2ef03a3b9 100644 --- a/modules/ui/init.js +++ b/modules/ui/init.js @@ -32,10 +32,15 @@ import { uiUndoRedo } from './undo_redo'; import { uiZoom } from './zoom'; import { uiCmd } from './cmd'; +var uiInitCounter = 0; + export function uiInit(context) { function render(container) { + container + .attr('dir', textDirection); + var map = context.map(); var hash = behaviorHash(context); @@ -68,13 +73,9 @@ export function uiInit(context) { content .append('div') .attr('id', 'map') - .attr('dir', 'ltr') + // .attr('dir', 'ltr') .call(map); - if (textDirection === 'rtl') { - d3.select('body').attr('dir', 'rtl'); - } - content .call(uiMapInMap(context)); @@ -268,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')) @@ -284,6 +287,8 @@ export function uiInit(context) { .on('authDone.ui', function() { authenticating.close(); }); + + uiInitCounter++; } @@ -316,6 +321,7 @@ export function uiInit(context) { }); }; + window.restart = ui.restart; ui.sidebar = uiSidebar(context); From a0045916d6e1a87cd7a57df99df3a7eb2bee69c4 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 20 Jan 2017 14:26:42 +0530 Subject: [PATCH 5/6] Remove test code, window.restart is now context.ui().restart --- modules/ui/init.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/ui/init.js b/modules/ui/init.js index 2ef03a3b9..b834366ac 100644 --- a/modules/ui/init.js +++ b/modules/ui/init.js @@ -32,10 +32,10 @@ import { uiUndoRedo } from './undo_redo'; import { uiZoom } from './zoom'; import { uiCmd } from './cmd'; -var uiInitCounter = 0; - export function uiInit(context) { + var uiInitCounter = 0; + function render(container) { container @@ -73,7 +73,6 @@ export function uiInit(context) { content .append('div') .attr('id', 'map') - // .attr('dir', 'ltr') .call(map); content @@ -292,10 +291,10 @@ export function uiInit(context) { } - var initCallback; + var renderCallback; function ui(node, callback) { - initCallback = callback; + renderCallback = callback; var container = d3.select(node); context.container(container); context.loadLocale(function(err) { @@ -314,16 +313,13 @@ export function uiInit(context) { context.loadLocale(function(err) { if (!err) { context.container().selectAll('*').remove(); - context.history().unlock(); render(context.container()); - if (initCallback) initCallback(); + if (renderCallback) renderCallback(); } }); }; - window.restart = ui.restart; - ui.sidebar = uiSidebar(context); return ui; From 2a39a25b3274f04360d7c9b33086b1a18d41fca4 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sat, 21 Jan 2017 21:55:47 -0500 Subject: [PATCH 6/6] Map div needs to remain ltr --- modules/ui/init.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ui/init.js b/modules/ui/init.js index b834366ac..81585bd9f 100644 --- a/modules/ui/init.js +++ b/modules/ui/init.js @@ -73,6 +73,7 @@ export function uiInit(context) { content .append('div') .attr('id', 'map') + .attr('dir', 'ltr') .call(map); content