From 17809545c6b29516286d11a381a31d0ea982f25b Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 28 Nov 2017 23:21:52 -0500 Subject: [PATCH] Ensure only one pane shown at a time, remove unnecessary handlers --- modules/ui/background.js | 19 +++++++++---------- modules/ui/help.js | 14 ++++++++++---- modules/ui/map_data.js | 15 ++++++++------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/modules/ui/background.js b/modules/ui/background.js index 4b0dbfaf7..680775eca 100644 --- a/modules/ui/background.js +++ b/modules/ui/background.js @@ -17,6 +17,8 @@ import { svgIcon } from '../svg'; import { uiBackgroundOffset } from './background_offset'; import { uiCmd } from './cmd'; import { uiDisclosure } from './disclosure'; +import { uiHelp } from './help'; +import { uiMapData } from './map_data'; import { uiMapInMap } from './map_in_map'; import { uiTooltipHtml } from './tooltipHtml'; import { utilDetect } from '../util/detect'; @@ -346,10 +348,9 @@ export function uiBackground(context) { _shown = show; if (show) { - selection - .on('mousedown.background-inside', function() { - d3_event.stopPropagation(); - }); + uiMapData.hidePane(); + uiHelp.hidePane(); + update(); pane .style('display', 'block') @@ -358,9 +359,6 @@ export function uiBackground(context) { .duration(200) .style('right', '0px'); - pane.selectAll('.layer') - .call(setTooltips); - } else { pane .style('display', 'block') @@ -371,9 +369,6 @@ export function uiBackground(context) { .on('end', function() { d3_select(this).style('display', 'none'); }); - - selection - .on('mousedown.background-inside', null); } } } @@ -468,6 +463,10 @@ export function uiBackground(context) { d3_select(document) .call(keybinding); + + uiBackground.hidePane = hidePane; + uiBackground.togglePane = togglePane; + uiBackground.setVisible = setVisible; } return background; diff --git a/modules/ui/help.js b/modules/ui/help.js index 024515f77..01196b3a7 100644 --- a/modules/ui/help.js +++ b/modules/ui/help.js @@ -9,7 +9,9 @@ import marked from 'marked'; import { t, textDirection } from '../util/locale'; import { svgIcon } from '../svg'; import { uiCmd } from './cmd'; +import { uiBackground } from './background'; import { uiIntro } from './intro'; +import { uiMapData } from './map_data'; import { uiShortcuts } from './shortcuts'; import { uiTooltipHtml } from './tooltipHtml'; import { tooltip } from '../util/tooltip'; @@ -278,14 +280,15 @@ export function uiHelp(context) { shown = show; if (show) { - selection.on('mousedown.help-inside', function() { - return d3_event.stopPropagation(); - }); + uiBackground.hidePane(); + uiMapData.hidePane(); + pane.style('display', 'block') .style('right', '-500px') .transition() .duration(200) .style('right', '0px'); + } else { pane.style('right', '0px') .transition() @@ -294,7 +297,6 @@ export function uiHelp(context) { .on('end', function() { d3_select(this).style('display', 'none'); }); - selection.on('mousedown.help-inside', null); } } } @@ -449,6 +451,10 @@ export function uiHelp(context) { d3_select(document) .call(keybinding); + + uiHelp.hidePane = hidePane; + uiHelp.togglePane = togglePane; + uiHelp.setVisible = setVisible; } return help; diff --git a/modules/ui/map_data.js b/modules/ui/map_data.js index 2cff0c842..aef91c01b 100644 --- a/modules/ui/map_data.js +++ b/modules/ui/map_data.js @@ -8,7 +8,9 @@ import { d3keybinding as d3_keybinding } from '../lib/d3.keybinding.js'; import { svgIcon } from '../svg'; import { t, textDirection } from '../util/locale'; import { tooltip } from '../util/tooltip'; +import { uiBackground } from './background'; import { uiDisclosure } from './disclosure'; +import { uiHelp } from './help'; import { uiTooltipHtml } from './tooltipHtml'; @@ -26,7 +28,6 @@ export function uiMapData(context) { var _featureList = d3_select(null); - function showsFeature(d) { return context.features().enabled(d); } @@ -407,12 +408,10 @@ export function uiMapData(context) { _shown = show; if (show) { + uiBackground.hidePane(); + uiHelp.hidePane(); update(); - selection.on('mousedown.map_data-inside', function() { - return d3_event.stopPropagation(); - }); - pane .style('display', 'block') .style('right', '-300px') @@ -430,8 +429,6 @@ export function uiMapData(context) { .on('end', function() { d3_select(this).style('display', 'none'); }); - - selection.on('mousedown.map_data-inside', null); } } } @@ -501,6 +498,10 @@ export function uiMapData(context) { d3_select(document) .call(keybinding); + + uiMapData.hidePane = hidePane; + uiMapData.togglePane = togglePane; + uiMapData.setVisible = setVisible; } return mapData;