Skip to content

Commit

Permalink
Code cleanups, move local feature names to helper
Browse files Browse the repository at this point in the history
  • Loading branch information
bhousel committed Mar 23, 2017
1 parent 61d1d1f commit 09d3e2d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 61 deletions.
46 changes: 46 additions & 0 deletions modules/ui/intro/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,49 @@ export function icon(name, svgklass) {
return '<svg class="icon ' + (svgklass || '') + '">' +
'<use xlink:href="' + name + '"></use></svg>';
}


export var localNames = {
n2140018997: 'city_hall',
n367813436: 'fire_department',
w203988286: 'memory_isle_park',
w203972937: 'riverwalk_trail',
w203972938: 'riverwalk_trail',
w203972940: 'riverwalk_trail',
w41785752: 'w_michigan_ave',
w134150789: 'w_michigan_ave',
w134150795: 'w_michigan_ave',
w134150800: 'w_michigan_ave',
w134150811: 'w_michigan_ave',
w134150802: 'e_michigan_ave',
w134150836: 'e_michigan_ave',
w41074896: 'e_michigan_ave',
w17965834: 'spring_st',
w203986457: 'scidmore_park',
w203049587: 'petting_zoo',
w17967397: 'n_andrews_st',
w17967315: 's_andrews_st',
w17967326: 'n_constantine_st',
w17966400: 's_constantine_st',
w170848823: 'rocky_river',
w170848824: 'rocky_river',
w170848331: 'rocky_river',
w17967752: 'railroad_dr',
w17965998: 'conrail_rr',
w134150845: 'conrail_rr',
w170989131: 'st_joseph_river',
w143497377: 'n_main_st',
w134150801: 's_main_st',
w134150830: 's_main_st',
w17966462: 's_main_st',
w17967734: 'water_st',
w17964996: 'foster_st',
w170848330: 'portage_river',
w17965351: 'flower_st',
w17965502: 'elm_st',
w17965402: 'walnut_st',
w17964793: 'morris_ave',
w17967444: 'east_st',
w17966984: 'portage_ave'
};

82 changes: 21 additions & 61 deletions modules/ui/intro/intro.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as d3 from 'd3';
import { t } from '../../util/locale';
import { localNames } from './helper';

import { coreGraph } from '../../core/graph';
import { modeBrowse } from '../../modes/browse';
import { osmEntity } from '../../osm/entity';
Expand All @@ -13,72 +15,31 @@ import { uiIntroLine } from './line';
import { uiIntroStartEditing } from './start_editing';


var sampleIntros = {
var chapterUi = {
navigation: uiIntroNavigation,
point: uiIntroPoint,
area: uiIntroArea,
line: uiIntroLine,
startEditing: uiIntroStartEditing
};


export function uiIntro(context) {
var chapter;

function localizedName(id) {
var features = {
n2140018997: 'city_hall',
n367813436: 'fire_department',
w203988286: 'memory_isle_park',
w203972937: 'riverwalk_trail',
w203972938: 'riverwalk_trail',
w203972940: 'riverwalk_trail',
w41785752: 'w_michigan_ave',
w134150789: 'w_michigan_ave',
w134150795: 'w_michigan_ave',
w134150800: 'w_michigan_ave',
w134150811: 'w_michigan_ave',
w134150802: 'e_michigan_ave',
w134150836: 'e_michigan_ave',
w41074896: 'e_michigan_ave',
w17965834: 'spring_st',
w203986457: 'scidmore_park',
w203049587: 'petting_zoo',
w17967397: 'n_andrews_st',
w17967315: 's_andrews_st',
w17967326: 'n_constantine_st',
w17966400: 's_constantine_st',
w170848823: 'rocky_river',
w170848824: 'rocky_river',
w170848331: 'rocky_river',
w17967752: 'railroad_dr',
w17965998: 'conrail_rr',
w134150845: 'conrail_rr',
w170989131: 'st_joseph_river',
w143497377: 'n_main_st',
w134150801: 's_main_st',
w134150830: 's_main_st',
w17966462: 's_main_st',
w17967734: 'water_st',
w17964996: 'foster_st',
w170848330: 'portage_river',
w17965351: 'flower_st',
w17965502: 'elm_st',
w17965402: 'walnut_st',
w17964793: 'morris_ave',
w17967444: 'east_st',
w17966984: 'portage_ave'
};

return features[id] && t('intro.graph.' + features[id]);
}
var chapterFlow = [
'navigation',
'point',
'area',
'line',
'startEditing'
];


var introGraph = {};
export function uiIntro(context) {
var introGraph = {},
currChapter;

// create entities for intro graph and localize names
for (var key in dataIntroGraph) {
introGraph[key] = osmEntity(dataIntroGraph[key]);
var name = localizedName(key);
var name = localNames[id] && t('intro.graph.' + localNames[id]);
if (name) {
introGraph[key].tags.name = name;
}
Expand Down Expand Up @@ -113,8 +74,8 @@ export function uiIntro(context) {
var curtain = uiCurtain();
selection.call(curtain);

var chapters = ['navigation', 'point', 'area', 'line', 'startEditing'].map(function(chapter, i) {
var s = sampleIntros[chapter](context, reveal)
var chapters = chapterFlow.map(function(chapter, i) {
var s = chapterUi[chapter](context, reveal)
.on('done', function() {
entered.filter(function(d) {
return d.title === s.title;
Expand Down Expand Up @@ -176,18 +137,17 @@ export function uiIntro(context) {


function enter(newChapter) {
if (chapter) { chapter.exit(); }
if (currChapter) { currChapter.exit(); }

context.enter(modeBrowse(context));

chapter = newChapter;
chapter.enter();
currChapter = newChapter;
currChapter.enter();

entered.classed('active', function(d) {
return d.title === chapter.title;
return d.title === currChapter.title;
});
}

}


Expand Down

0 comments on commit 09d3e2d

Please sign in to comment.