Merge pull request #3222 from openstreetmap/ui-2

Continuation of work from #3194
This commit is contained in:
Tom MacWright
2016-07-05 18:08:14 -04:00
committed by GitHub
96 changed files with 15007 additions and 15297 deletions
+1 -21
View File
@@ -45,11 +45,7 @@ $(BUILDJS_TARGETS): $(BUILDJS_SOURCES) build.js
MODULE_TARGETS = \
js/lib/id/index.js \
js/lib/id/services.js \
js/lib/id/ui/index.js \
js/lib/id/svg.js \
js/lib/id/ui/core.js \
js/lib/id/ui/intro.js \
js/lib/id/ui/preset.js
js/lib/id/svg.js
js/lib/id/index.js: $(shell find modules -type f)
@rm -f $@
@@ -63,22 +59,6 @@ js/lib/id/svg.js: $(shell find modules/svg -type f)
@rm -f $@
node_modules/.bin/rollup -c rollup.config.js -f umd -n iD.svg modules/svg/index.js --no-strict -o $@
js/lib/id/ui/index.js: $(shell find modules/ui -type f)
@rm -f $@
node_modules/.bin/rollup -c rollup.config.js -f umd -n iD modules/ui/ui.js --no-strict -o $@
js/lib/id/ui/core.js: $(shell find modules/ui/core -type f)
@rm -f $@
node_modules/.bin/rollup -c rollup.config.js -f umd -n iD.ui modules/ui/core/index.js --no-strict -o $@
js/lib/id/ui/intro.js: $(shell find modules/ui/intro -type f)
@rm -f $@
node_modules/.bin/rollup -c rollup.config.js -f umd -n iD.ui.intro modules/ui/intro/index.js --no-strict -o $@
js/lib/id/ui/preset.js: $(shell find modules/ui/preset -type f)
@rm -f $@
node_modules/.bin/rollup -c rollup.config.js -f umd -n iD.ui.preset modules/ui/preset/index.js --no-strict -o $@
dist/iD.js: \
js/lib/bootstrap-tooltip.js \
js/lib/d3.v3.js \
-5
View File
@@ -38,11 +38,6 @@
<script src='js/lib/id/svg.js'></script>
<script src='js/lib/id/services.js'></script>
<script src='js/lib/id/ui/index.js'></script>
<script src='js/lib/id/ui/core.js'></script>
<script src='js/lib/id/ui/intro.js'></script>
<script src='js/lib/id/ui/preset.js'></script>
<script src='data/data_dev.js'></script>
<script src='js/lib/locale.js'></script>
+1 -1
View File
@@ -362,7 +362,7 @@ window.iD = function () {
context.undo = withDebouncedSave(history.undo);
context.redo = withDebouncedSave(history.redo);
ui = iD.ui(context);
ui = iD.ui.init(context);
connection = iD.Connection();
+14331 -6052
View File
File diff suppressed because it is too large Load Diff
-6094
View File
File diff suppressed because it is too large Load Diff
-251
View File
@@ -1,251 +0,0 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.iD = global.iD || {})));
}(this, function (exports) { 'use strict';
function ui(context) {
function render(container) {
var map = context.map();
if (iD.detect().opera) container.classed('opera', true);
var hash = iD.behavior.Hash(context);
hash();
if (!hash.hadHash) {
map.centerZoom([0, 0], 2);
}
container.append('svg')
.attr('id', 'defs')
.call(iD.svg.Defs(context));
container.append('div')
.attr('id', 'sidebar')
.attr('class', 'col4')
.call(ui.sidebar);
var content = container.append('div')
.attr('id', 'content');
var bar = content.append('div')
.attr('id', 'bar')
.attr('class', 'fillD');
content.append('div')
.attr('id', 'map')
.call(map);
content
.call(iD.ui.MapInMap(context));
content.append('div')
.call(iD.ui.Info(context));
bar.append('div')
.attr('class', 'spacer col4');
var limiter = bar.append('div')
.attr('class', 'limiter');
limiter.append('div')
.attr('class', 'button-wrap joined col3')
.call(iD.ui.Modes(context), limiter);
limiter.append('div')
.attr('class', 'button-wrap joined col1')
.call(iD.ui.UndoRedo(context));
limiter.append('div')
.attr('class', 'button-wrap col1')
.call(iD.ui.Save(context));
bar.append('div')
.attr('class', 'full-screen')
.call(iD.ui.FullScreen(context));
bar.append('div')
.attr('class', 'spinner')
.call(iD.ui.Spinner(context));
var controls = bar.append('div')
.attr('class', 'map-controls');
controls.append('div')
.attr('class', 'map-control zoombuttons')
.call(iD.ui.Zoom(context));
controls.append('div')
.attr('class', 'map-control geolocate-control')
.call(iD.ui.Geolocate(context));
controls.append('div')
.attr('class', 'map-control background-control')
.call(iD.ui.Background(context));
controls.append('div')
.attr('class', 'map-control map-data-control')
.call(iD.ui.MapData(context));
controls.append('div')
.attr('class', 'map-control help-control')
.call(iD.ui.Help(context));
var about = content.append('div')
.attr('id', 'about');
about.append('div')
.attr('id', 'attrib')
.call(iD.ui.Attribution(context));
var footer = about.append('div')
.attr('id', 'footer')
.attr('class', 'fillD');
footer.append('div')
.attr('class', 'api-status')
.call(iD.ui.Status(context));
footer.append('div')
.attr('id', 'scale-block')
.call(iD.ui.Scale(context));
var aboutList = footer.append('div')
.attr('id', 'info-block')
.append('ul')
.attr('id', 'about-list');
if (!context.embed()) {
aboutList.call(iD.ui.Account(context));
}
aboutList.append('li')
.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('href', 'https://github.com/openstreetmap/iD')
.text(iD.version);
var issueLinks = aboutList.append('li');
issueLinks.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('href', 'https://github.com/openstreetmap/iD/issues')
.call(iD.svg.Icon('#icon-bug', 'light'))
.call(bootstrap.tooltip()
.title(t('report_a_bug'))
.placement('top')
);
issueLinks.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('href', 'https://github.com/openstreetmap/iD/blob/master/CONTRIBUTING.md#translating')
.call(iD.svg.Icon('#icon-translate', 'light'))
.call(bootstrap.tooltip()
.title(t('help_translate'))
.placement('top')
);
aboutList.append('li')
.attr('class', 'feature-warning')
.attr('tabindex', -1)
.call(iD.ui.FeatureInfo(context));
aboutList.append('li')
.attr('class', 'user-list')
.attr('tabindex', -1)
.call(iD.ui.Contributors(context));
window.onbeforeunload = function() {
return context.save();
};
window.onunload = function() {
context.history().unlock();
};
var mapDimensions = map.dimensions();
d3.select(window).on('resize.editor', function() {
mapDimensions = content.dimensions(null);
map.dimensions(mapDimensions);
});
function pan(d) {
return function() {
d3.event.preventDefault();
if (!context.inIntro()) context.pan(d);
};
}
// pan amount
var pa = 10;
var keybinding = d3.keybinding('main')
.on('⌫', function() { d3.event.preventDefault(); })
.on('←', pan([pa, 0]))
.on('↑', pan([0, pa]))
.on('→', pan([-pa, 0]))
.on('↓', pan([0, -pa]))
.on('⇧←', pan([mapDimensions[0], 0]))
.on('⇧↑', pan([0, mapDimensions[1]]))
.on('⇧→', pan([-mapDimensions[0], 0]))
.on('⇧↓', pan([0, -mapDimensions[1]]))
.on(iD.ui.cmd('⌘←'), pan([mapDimensions[0], 0]))
.on(iD.ui.cmd('⌘↑'), pan([0, mapDimensions[1]]))
.on(iD.ui.cmd('⌘→'), pan([-mapDimensions[0], 0]))
.on(iD.ui.cmd('⌘↓'), pan([0, -mapDimensions[1]]));
d3.select(document)
.call(keybinding);
context.enter(iD.modes.Browse(context));
context.container()
.call(iD.ui.Splash(context))
.call(iD.ui.Restore(context));
var authenticating = iD.ui.Loading(context)
.message(t('loading_auth'));
context.connection()
.on('authenticating.ui', function() {
context.container()
.call(authenticating);
})
.on('authenticated.ui', function() {
authenticating.close();
});
}
function ui(container) {
context.container(container);
context.loadLocale(function() {
render(container);
});
}
ui.sidebar = iD.ui.Sidebar(context);
return ui;
}
ui.tooltipHtml = function(text, key) {
var s = '<span>' + text + '</span>';
if (key) {
s += '<div class="keyhint-wrap">' +
'<span> ' + (t('tooltip_keyhint')) + ' </span>' +
'<span class="keyhint"> ' + key + '</span></div>';
}
return s;
};
exports.ui = ui;
Object.defineProperty(exports, '__esModule', { value: true });
}));
-582
View File
@@ -1,582 +0,0 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.iD = global.iD || {}, global.iD.ui = global.iD.ui || {}, global.iD.ui.intro = global.iD.ui.intro || {})));
}(this, function (exports) { 'use strict';
function area(context, reveal) {
var event = d3.dispatch('done'),
timeout;
var step = {
title: 'intro.areas.title'
};
step.enter = function() {
var playground = [-85.63552, 41.94159],
corner = [-85.63565411045074, 41.9417715536927];
context.map().centerZoom(playground, 19);
reveal('button.add-area',
t('intro.areas.add', { button: iD.ui.intro.icon('#icon-area', 'pre-text') }),
{ tooltipClass: 'intro-areas-add' });
context.on('enter.intro', addArea);
function addArea(mode) {
if (mode.id !== 'add-area') return;
context.on('enter.intro', drawArea);
var padding = 120 * Math.pow(2, context.map().zoom() - 19);
var pointBox = iD.ui.intro.pad(corner, padding, context);
reveal(pointBox, t('intro.areas.corner'));
context.map().on('move.intro', function() {
padding = 120 * Math.pow(2, context.map().zoom() - 19);
pointBox = iD.ui.intro.pad(corner, padding, context);
reveal(pointBox, t('intro.areas.corner'), {duration: 0});
});
}
function drawArea(mode) {
if (mode.id !== 'draw-area') return;
context.on('enter.intro', enterSelect);
var padding = 150 * Math.pow(2, context.map().zoom() - 19);
var pointBox = iD.ui.intro.pad(playground, padding, context);
reveal(pointBox, t('intro.areas.place'));
context.map().on('move.intro', function() {
padding = 150 * Math.pow(2, context.map().zoom() - 19);
pointBox = iD.ui.intro.pad(playground, padding, context);
reveal(pointBox, t('intro.areas.place'), {duration: 0});
});
}
function enterSelect(mode) {
if (mode.id !== 'select') return;
context.map().on('move.intro', null);
context.on('enter.intro', null);
timeout = setTimeout(function() {
reveal('.preset-search-input',
t('intro.areas.search',
{ name: context.presets().item('leisure/playground').name() }));
d3.select('.preset-search-input').on('keyup.intro', keySearch);
}, 500);
}
function keySearch() {
var first = d3.select('.preset-list-item:first-child');
if (first.classed('preset-leisure-playground')) {
reveal(first.select('.preset-list-button').node(), t('intro.areas.choose'));
d3.selection.prototype.one.call(context.history(), 'change.intro', selectedPreset);
d3.select('.preset-search-input').on('keyup.intro', null);
}
}
function selectedPreset() {
reveal('.pane',
t('intro.areas.describe', { button: iD.ui.intro.icon('#icon-apply', 'pre-text') }));
context.on('exit.intro', event.done);
}
};
step.exit = function() {
window.clearTimeout(timeout);
context.on('enter.intro', null);
context.on('exit.intro', null);
context.history().on('change.intro', null);
context.map().on('move.intro', null);
d3.select('.preset-search-input').on('keyup.intro', null);
};
return d3.rebind(step, event, 'on');
}
function line(context, reveal) {
var event = d3.dispatch('done'),
timeouts = [];
var step = {
title: 'intro.lines.title'
};
function timeout(f, t) {
timeouts.push(window.setTimeout(f, t));
}
function eventCancel() {
d3.event.stopPropagation();
d3.event.preventDefault();
}
step.enter = function() {
var centroid = [-85.62830, 41.95699];
var midpoint = [-85.62975395449628, 41.95787501510204];
var start = [-85.6297754121684, 41.95805253325314];
var intersection = [-85.62974496187628, 41.95742515554585];
context.map().centerZoom(start, 18);
reveal('button.add-line',
t('intro.lines.add', { button: iD.ui.intro.icon('#icon-line', 'pre-text') }),
{ tooltipClass: 'intro-lines-add' });
context.on('enter.intro', addLine);
function addLine(mode) {
if (mode.id !== 'add-line') return;
context.on('enter.intro', drawLine);
var padding = 150 * Math.pow(2, context.map().zoom() - 18);
var pointBox = iD.ui.intro.pad(start, padding, context);
reveal(pointBox, t('intro.lines.start'));
context.map().on('move.intro', function() {
padding = 150 * Math.pow(2, context.map().zoom() - 18);
pointBox = iD.ui.intro.pad(start, padding, context);
reveal(pointBox, t('intro.lines.start'), {duration: 0});
});
}
function drawLine(mode) {
if (mode.id !== 'draw-line') return;
context.history().on('change.intro', addIntersection);
context.on('enter.intro', retry);
var padding = 300 * Math.pow(2, context.map().zoom() - 19);
var pointBox = iD.ui.intro.pad(midpoint, padding, context);
reveal(pointBox, t('intro.lines.intersect', {name: t('intro.graph.flower_st')}));
context.map().on('move.intro', function() {
padding = 300 * Math.pow(2, context.map().zoom() - 19);
pointBox = iD.ui.intro.pad(midpoint, padding, context);
reveal(pointBox, t('intro.lines.intersect', {name: t('intro.graph.flower_st')}), {duration: 0});
});
}
// ended line before creating intersection
function retry(mode) {
if (mode.id !== 'select') return;
var pointBox = iD.ui.intro.pad(intersection, 30, context),
ids = mode.selectedIDs();
reveal(pointBox, t('intro.lines.restart', {name: t('intro.graph.flower_st')}));
d3.select(window).on('mousedown.intro', eventCancel, true);
timeout(function() {
context.replace(iD.actions.DeleteMultiple(ids));
step.exit();
step.enter();
}, 3000);
}
function addIntersection(changes) {
if ( _.some(changes.created(), function(d) {
return d.type === 'node' && context.graph().parentWays(d).length > 1;
})) {
context.history().on('change.intro', null);
context.on('enter.intro', enterSelect);
var padding = 900 * Math.pow(2, context.map().zoom() - 19);
var pointBox = iD.ui.intro.pad(centroid, padding, context);
reveal(pointBox, t('intro.lines.finish'));
context.map().on('move.intro', function() {
padding = 900 * Math.pow(2, context.map().zoom() - 19);
pointBox = iD.ui.intro.pad(centroid, padding, context);
reveal(pointBox, t('intro.lines.finish'), {duration: 0});
});
}
}
function enterSelect(mode) {
if (mode.id !== 'select') return;
context.map().on('move.intro', null);
context.on('enter.intro', null);
d3.select('#curtain').style('pointer-events', 'all');
presetCategory();
}
function presetCategory() {
timeout(function() {
d3.select('#curtain').style('pointer-events', 'none');
var road = d3.select('.preset-category-road .preset-list-button');
reveal(road.node(), t('intro.lines.road'));
road.one('click.intro', roadCategory);
}, 500);
}
function roadCategory() {
timeout(function() {
var grid = d3.select('.subgrid');
reveal(grid.node(), t('intro.lines.residential'));
grid.selectAll(':not(.preset-highway-residential) .preset-list-button')
.one('click.intro', retryPreset);
grid.selectAll('.preset-highway-residential .preset-list-button')
.one('click.intro', roadDetails);
}, 500);
}
// selected wrong road type
function retryPreset() {
timeout(function() {
var preset = d3.select('.entity-editor-pane .preset-list-button');
reveal(preset.node(), t('intro.lines.wrong_preset'));
preset.one('click.intro', presetCategory);
}, 500);
}
function roadDetails() {
reveal('.pane',
t('intro.lines.describe', { button: iD.ui.intro.icon('#icon-apply', 'pre-text') }));
context.on('exit.intro', event.done);
}
};
step.exit = function() {
d3.select(window).on('mousedown.intro', null, true);
d3.select('#curtain').style('pointer-events', 'none');
timeouts.forEach(window.clearTimeout);
context.on('enter.intro', null);
context.on('exit.intro', null);
context.map().on('move.intro', null);
context.history().on('change.intro', null);
};
return d3.rebind(step, event, 'on');
}
function navigation(context, reveal) {
var event = d3.dispatch('done'),
timeouts = [];
var step = {
title: 'intro.navigation.title'
};
function set(f, t) {
timeouts.push(window.setTimeout(f, t));
}
function eventCancel() {
d3.event.stopPropagation();
d3.event.preventDefault();
}
step.enter = function() {
var rect = context.surfaceRect(),
map = {
left: rect.left + 10,
top: rect.top + 70,
width: rect.width - 70,
height: rect.height - 170
};
context.map().centerZoom([-85.63591, 41.94285], 19);
reveal(map, t('intro.navigation.drag'));
context.map().on('move.intro', _.debounce(function() {
context.map().on('move.intro', null);
townhall();
context.on('enter.intro', inspectTownHall);
}, 400));
function townhall() {
var hall = [-85.63645945147184, 41.942986488012565];
var point = context.projection(hall);
if (point[0] < 0 || point[0] > rect.width ||
point[1] < 0 || point[1] > rect.height) {
context.map().center(hall);
}
var box = iD.ui.intro.pointBox(hall, context);
reveal(box, t('intro.navigation.select'));
context.map().on('move.intro', function() {
var box = iD.ui.intro.pointBox(hall, context);
reveal(box, t('intro.navigation.select'), {duration: 0});
});
}
function inspectTownHall(mode) {
if (mode.id !== 'select') return;
context.on('enter.intro', null);
context.map().on('move.intro', null);
set(function() {
reveal('.entity-editor-pane',
t('intro.navigation.pane', { button: iD.ui.intro.icon('#icon-close', 'pre-text') }));
context.on('exit.intro', streetSearch);
}, 700);
}
function streetSearch() {
context.on('exit.intro', null);
reveal('.search-header input',
t('intro.navigation.search', { name: t('intro.graph.spring_st') }));
d3.select('.search-header input').on('keyup.intro', searchResult);
}
function searchResult() {
var first = d3.select('.feature-list-item:nth-child(0n+2)'), // skip No Results item
firstName = first.select('.entity-name'),
name = t('intro.graph.spring_st');
if (!firstName.empty() && firstName.text() === name) {
reveal(first.node(), t('intro.navigation.choose', { name: name }));
context.on('exit.intro', selectedStreet);
d3.select('.search-header input')
.on('keydown.intro', eventCancel, true)
.on('keyup.intro', null);
}
}
function selectedStreet() {
var springSt = [-85.63585099140167, 41.942506848938926];
context.map().center(springSt);
context.on('exit.intro', event.done);
set(function() {
reveal('.entity-editor-pane',
t('intro.navigation.chosen', {
name: t('intro.graph.spring_st'),
button: iD.ui.intro.icon('#icon-close', 'pre-text')
}));
}, 400);
}
};
step.exit = function() {
timeouts.forEach(window.clearTimeout);
context.map().on('move.intro', null);
context.on('enter.intro', null);
context.on('exit.intro', null);
d3.select('.search-header input')
.on('keydown.intro', null)
.on('keyup.intro', null);
};
return d3.rebind(step, event, 'on');
}
function point(context, reveal) {
var event = d3.dispatch('done'),
timeouts = [];
var step = {
title: 'intro.points.title'
};
function setTimeout(f, t) {
timeouts.push(window.setTimeout(f, t));
}
function eventCancel() {
d3.event.stopPropagation();
d3.event.preventDefault();
}
step.enter = function() {
context.map().centerZoom([-85.63279, 41.94394], 19);
reveal('button.add-point',
t('intro.points.add', { button: iD.ui.intro.icon('#icon-point', 'pre-text') }),
{ tooltipClass: 'intro-points-add' });
var corner = [-85.632481,41.944094];
context.on('enter.intro', addPoint);
function addPoint(mode) {
if (mode.id !== 'add-point') return;
context.on('enter.intro', enterSelect);
var pointBox = iD.ui.intro.pad(corner, 150, context);
reveal(pointBox, t('intro.points.place'));
context.map().on('move.intro', function() {
pointBox = iD.ui.intro.pad(corner, 150, context);
reveal(pointBox, t('intro.points.place'), {duration: 0});
});
}
function enterSelect(mode) {
if (mode.id !== 'select') return;
context.map().on('move.intro', null);
context.on('enter.intro', null);
setTimeout(function() {
reveal('.preset-search-input',
t('intro.points.search', {name: context.presets().item('amenity/cafe').name()}));
d3.select('.preset-search-input').on('keyup.intro', keySearch);
}, 500);
}
function keySearch() {
var first = d3.select('.preset-list-item:first-child');
if (first.classed('preset-amenity-cafe')) {
reveal(first.select('.preset-list-button').node(), t('intro.points.choose'));
d3.selection.prototype.one.call(context.history(), 'change.intro', selectedPreset);
d3.select('.preset-search-input')
.on('keydown.intro', eventCancel, true)
.on('keyup.intro', null);
}
}
function selectedPreset() {
setTimeout(function() {
reveal('.entity-editor-pane', t('intro.points.describe'), {tooltipClass: 'intro-points-describe'});
context.history().on('change.intro', closeEditor);
context.on('exit.intro', selectPoint);
}, 400);
}
function closeEditor() {
d3.select('.preset-search-input').on('keydown.intro', null);
context.history().on('change.intro', null);
reveal('.entity-editor-pane',
t('intro.points.close', { button: iD.ui.intro.icon('#icon-apply', 'pre-text') }));
}
function selectPoint() {
context.on('exit.intro', null);
context.history().on('change.intro', null);
context.on('enter.intro', enterReselect);
var pointBox = iD.ui.intro.pad(corner, 150, context);
reveal(pointBox, t('intro.points.reselect'));
context.map().on('move.intro', function() {
pointBox = iD.ui.intro.pad(corner, 150, context);
reveal(pointBox, t('intro.points.reselect'), {duration: 0});
});
}
function enterReselect(mode) {
if (mode.id !== 'select') return;
context.map().on('move.intro', null);
context.on('enter.intro', null);
setTimeout(function() {
reveal('.entity-editor-pane',
t('intro.points.fixname', { button: iD.ui.intro.icon('#icon-apply', 'pre-text') }));
context.on('exit.intro', deletePoint);
}, 500);
}
function deletePoint() {
context.on('exit.intro', null);
context.on('enter.intro', enterDelete);
var pointBox = iD.ui.intro.pad(corner, 150, context);
reveal(pointBox, t('intro.points.reselect_delete'));
context.map().on('move.intro', function() {
pointBox = iD.ui.intro.pad(corner, 150, context);
reveal(pointBox, t('intro.points.reselect_delete'), {duration: 0});
});
}
function enterDelete(mode) {
if (mode.id !== 'select') return;
context.map().on('move.intro', null);
context.on('enter.intro', null);
context.on('exit.intro', deletePoint);
context.map().on('move.intro', deletePoint);
context.history().on('change.intro', deleted);
setTimeout(function() {
var node = d3.select('.radial-menu-item-delete').node();
var pointBox = iD.ui.intro.pad(node.getBoundingClientRect(), 50, context);
reveal(pointBox,
t('intro.points.delete', { button: iD.ui.intro.icon('#operation-delete', 'pre-text') }));
}, 300);
}
function deleted(changed) {
if (changed.deleted().length) event.done();
}
};
step.exit = function() {
timeouts.forEach(window.clearTimeout);
context.on('exit.intro', null);
context.on('enter.intro', null);
context.map().on('move.intro', null);
context.history().on('change.intro', null);
d3.select('.preset-search-input')
.on('keyup.intro', null)
.on('keydown.intro', null);
};
return d3.rebind(step, event, 'on');
}
function startEditing(context, reveal) {
var event = d3.dispatch('done', 'startEditing'),
modal,
timeouts = [];
var step = {
title: 'intro.startediting.title'
};
function timeout(f, t) {
timeouts.push(window.setTimeout(f, t));
}
step.enter = function() {
reveal('.map-control.help-control',
t('intro.startediting.help', { button: iD.ui.intro.icon('#icon-help', 'pre-text') }));
timeout(function() {
reveal('#bar button.save', t('intro.startediting.save'));
}, 5000);
timeout(function() {
reveal('#surface');
}, 10000);
timeout(function() {
modal = iD.ui.modal(context.container());
modal.select('.modal')
.attr('class', 'modal-splash modal col6');
modal.selectAll('.close').remove();
var startbutton = modal.select('.content')
.attr('class', 'fillL')
.append('button')
.attr('class', 'modal-section huge-modal-button')
.on('click', function() {
modal.remove();
});
startbutton.append('div')
.attr('class','illustration');
startbutton.append('h2')
.text(t('intro.startediting.start'));
event.startEditing();
}, 10500);
};
step.exit = function() {
if (modal) modal.remove();
timeouts.forEach(window.clearTimeout);
};
return d3.rebind(step, event, 'on');
}
exports.area = area;
exports.line = line;
exports.navigation = navigation;
exports.point = point;
exports.startEditing = startEditing;
Object.defineProperty(exports, '__esModule', { value: true });
}));
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,4 +1,4 @@
import { cmd } from '../ui/core/index';
import { cmd } from '../ui/index';
export function Copy(context) {
var keybinding = d3.keybinding('copy');
+1 -1
View File
@@ -1,6 +1,6 @@
import { Select } from '../modes/index';
import { Extent, pointInPolygon } from '../geo/index';
import { Lasso as uiLasso } from '../ui/core/index';
import { Lasso as uiLasso } from '../ui/index';
export function Lasso(context) {
+1 -1
View File
@@ -1,7 +1,7 @@
import { Move as MoveMode } from '../modes/index';
import { Extent, pointInPolygon } from '../geo/index';
import { CopyEntities, ChangeTags, Move as MoveAction} from '../actions/index';
import { cmd } from '../ui/core/index';
import { cmd } from '../ui/index';
export function Paste(context) {
var keybinding = d3.keybinding('paste');
+1 -1
View File
@@ -3,7 +3,7 @@ import { Graph } from './graph';
import { Difference } from './difference';
import { Tree } from './tree';
import { SessionMutex } from '../util/index';
import { Loading } from '../ui/core/index';
import { Loading } from '../ui/index';
export function History(context) {
var stack, index, tree,
+2
View File
@@ -6,6 +6,7 @@ import * as util from './util/index';
import * as operations from './operations/index';
import * as presets from './presets/index';
import * as validations from './validations/index';
import * as ui from './ui/index';
// core
export { Connection } from './core/connection';
@@ -34,5 +35,6 @@ export {
operations,
presets,
util,
ui,
validations
};
+1 -1
View File
@@ -2,7 +2,7 @@ import { Graph } from '../core/index';
import { displayName, displayType } from '../util/index';
import { Browse } from './index';
import { DiscardTags, Noop, MergeRemoteChanges, Revert } from '../actions/index';
import { Commit, Loading, Success, Conflicts } from '../ui/core/index';
import { Commit, Loading, Success, Conflicts } from '../ui/index';
export function Save(context) {
var ui = Commit(context)
+1 -1
View File
@@ -5,7 +5,7 @@ import { DragNode, Browse } from './index';
import { Extent, pointInPolygon, chooseEdge } from '../geo/index';
import { AddMidpoint } from '../actions/index';
import * as Operations from '../operations/index';
import { RadialMenu, SelectionList } from '../ui/core/index';
import { RadialMenu, SelectionList } from '../ui/index';
export function Select(context, selectedIDs) {
var mode = {
+3 -1
View File
@@ -1,6 +1,8 @@
import { Select, Browse } from '../modes/index';
import { sphericalDistance } from '../geo/index';
import { DeleteMultiple } from '../actions/index';
import { cmd } from '../ui/index';
export function Delete(selectedIDs, context) {
var action = DeleteMultiple(selectedIDs);
@@ -70,7 +72,7 @@ export function Delete(selectedIDs, context) {
};
operation.id = 'delete';
operation.keys = [iD.ui.cmd('⌘⌫'), iD.ui.cmd('⌘⌦')];
operation.keys = [cmd('⌘⌫'), cmd('⌘⌦')];
operation.title = t('operations.delete.title');
return operation;
+1 -1
View File
@@ -1,7 +1,7 @@
import { setTransform, fastMouse } from '../util/index';
import { interp, Extent } from '../geo/index';
import { Layers, Areas, Midpoints, Points, Vertices, Lines, Labels } from '../svg/index';
import { flash } from '../ui/core/index';
import { flash } from '../ui/index';
export function Map(context) {
var dimensions = [1, 1],
@@ -1,3 +1,4 @@
import { Icon } from '../svg/index';
export function Account(context) {
var connection = context.connection();
@@ -32,7 +33,7 @@ export function Account(context) {
.attr('src', details.image_url);
} else {
userLink
.call(iD.svg.Icon('#icon-avatar', 'pre-text light'));
.call(Icon('#icon-avatar', 'pre-text light'));
}
// Add user name
@@ -1,5 +1,10 @@
import { Icon } from '../svg/index';
import { setTransform } from '../util/index';
import { BackgroundSource } from '../renderer/index';
import { offsetToMeters, metersToOffset } from '../geo/index';
import { cmd } from './cmd';
import { MapInMap } from './map_in_map';
import { tooltipHtml } from './tooltipHtml';
export function Background(context) {
var key = 'B',
@@ -33,7 +38,7 @@ export function Background(context) {
.attr('data-opacity', d);
if (!iD.detect().opera) {
iD.util.setTransform(bg, 0, 0);
setTransform(bg, 0, 0);
}
opacityList.selectAll('li')
@@ -50,7 +55,7 @@ export function Background(context) {
.html(true)
.title(function() {
var tip = '<div>' + t('background.switch') + '</div>';
return iD.ui.tooltipHtml(tip, iD.ui.cmd('⌘B'));
return tooltipHtml(tip, cmd('⌘B'));
})
.placement('top')
);
@@ -100,7 +105,7 @@ export function Background(context) {
}
function setCustom(template) {
context.background().baseLayerSource(iD.BackgroundSource.Custom(template));
context.background().baseLayerSource(BackgroundSource.Custom(template));
selectLayer();
context.storage('background-custom-template', template);
}
@@ -168,7 +173,7 @@ export function Background(context) {
}
function updateOffsetVal() {
var meters = iD.geo.offsetToMeters(context.background().offset()),
var meters = offsetToMeters(context.background().offset()),
x = +meters[0].toFixed(2),
y = +meters[1].toFixed(2);
@@ -224,7 +229,7 @@ export function Background(context) {
return;
}
context.background().offset(iD.geo.metersToOffset(d));
context.background().offset(metersToOffset(d));
updateOffsetVal();
}
@@ -308,11 +313,11 @@ export function Background(context) {
tooltip = bootstrap.tooltip()
.placement('left')
.html(true)
.title(iD.ui.tooltipHtml(t('background.description'), key)),
.title(tooltipHtml(t('background.description'), key)),
button = selection.append('button')
.attr('tabindex', -1)
.on('click', toggle)
.call(iD.svg.Icon('#icon-layers', 'light'))
.call(Icon('#icon-layers', 'light'))
.call(tooltip),
shown = false;
@@ -351,7 +356,7 @@ export function Background(context) {
var custom = backgroundList.append('li')
.attr('class', 'custom_layer')
.datum(iD.BackgroundSource.Custom());
.datum(BackgroundSource.Custom());
custom.append('button')
.attr('class', 'layer-browse')
@@ -359,7 +364,7 @@ export function Background(context) {
.title(t('background.custom_button'))
.placement('left'))
.on('click', editCustom)
.call(iD.svg.Icon('#icon-search'));
.call(Icon('#icon-search'));
var label = custom.append('label');
@@ -382,7 +387,7 @@ export function Background(context) {
.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.call(iD.svg.Icon('#icon-out-link', 'inline'))
.call(Icon('#icon-out-link', 'inline'))
.attr('href', 'https://github.com/openstreetmap/iD/blob/master/FAQ.md#how-can-i-report-an-issue-with-background-imagery')
.append('span')
.text(t('background.imagery_source_faq'));
@@ -400,7 +405,7 @@ export function Background(context) {
.append('label')
.call(bootstrap.tooltip()
.html(true)
.title(iD.ui.tooltipHtml(t('background.minimap.tooltip'), '/'))
.title(tooltipHtml(t('background.minimap.tooltip'), '/'))
.placement('top')
);
@@ -466,7 +471,7 @@ export function Background(context) {
.attr('title', t('background.reset'))
.attr('class', 'nudge-reset disabled')
.on('click', resetOffset)
.call(iD.svg.Icon('#icon-undo'));
.call(Icon('#icon-undo'));
context.map()
.on('move.background-update', _.debounce(update, 1000));
@@ -1,3 +1,6 @@
import { Icon } from '../svg/index';
import { entityOrMemberSelector, displayName } from '../util/index';
import { Select } from '../modes/index';
export function Commit(context) {
var dispatch = d3.dispatch('cancel', 'save');
@@ -11,7 +14,7 @@ export function Commit(context) {
context.graph().entity(entity.id).geometry(context.graph()) !== 'vertex') {
context.map().zoomTo(entity);
context.surface().selectAll(
iD.util.entityOrMemberSelector([entity.id], context.graph()))
entityOrMemberSelector([entity.id], context.graph()))
.classed('hover', true);
}
}
@@ -59,7 +62,7 @@ export function Commit(context) {
.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.call(iD.svg.Icon('#icon-alert', 'inline'))
.call(Icon('#icon-alert', 'inline'))
.attr('href', t('commit.google_warning_link'))
.append('span')
.text(t('commit.google_warning'));
@@ -94,7 +97,7 @@ export function Commit(context) {
changeSetInfo.append('a')
.attr('target', '_blank')
.attr('tabindex', -1)
.call(iD.svg.Icon('#icon-out-link', 'inline'))
.call(Icon('#icon-out-link', 'inline'))
.attr('href', t('commit.about_changeset_comments_link'))
.append('span')
.text(t('commit.about_changeset_comments'));
@@ -123,7 +126,7 @@ export function Commit(context) {
.on('click', warningClick);
warningLi
.call(iD.svg.Icon('#icon-alert', 'pre-text'));
.call(Icon('#icon-alert', 'pre-text'));
warningLi
.append('strong').text(function(d) {
@@ -218,7 +221,7 @@ export function Commit(context) {
li.each(function(d) {
d3.select(this)
.call(iD.svg.Icon('#icon-' + d.entity.geometry(d.graph), 'pre-text ' + d.changeType));
.call(Icon('#icon-' + d.entity.geometry(d.graph), 'pre-text ' + d.changeType));
});
li.append('span')
@@ -236,7 +239,7 @@ export function Commit(context) {
li.append('span')
.attr('class', 'entity-name')
.text(function(d) {
var name = iD.util.displayName(d.entity) || '',
var name = displayName(d.entity) || '',
string = '';
if (name !== '') string += ':';
return string += ' ' + name;
@@ -250,7 +253,7 @@ export function Commit(context) {
function mouseover(d) {
if (d.entity) {
context.surface().selectAll(
iD.util.entityOrMemberSelector([d.entity.id], context.graph())
entityOrMemberSelector([d.entity.id], context.graph())
).classed('hover', true);
}
}
@@ -264,7 +267,7 @@ export function Commit(context) {
if (d.entity) {
context.map().zoomTo(d.entity);
context.enter(
iD.modes.Select(context, [d.entity.id])
Select(context, [d.entity.id])
.suppressMenu(true));
}
}
@@ -1,12 +1,12 @@
import { modal as modalModule } from './modal';
import { modal } from './modal';
export function confirm(selection) {
var modal = modalModule(selection);
var modalSelection = modal(selection);
modal.select('.modal')
modalSelection.select('.modal')
.classed('modal-alert', true);
var section = modal.select('.content');
var section = modalSelection.select('.content');
section.append('div')
.attr('class', 'modal-section header');
@@ -17,17 +17,17 @@ export function confirm(selection) {
var buttons = section.append('div')
.attr('class', 'modal-section buttons cf');
modal.okButton = function() {
modalSelection.okButton = function() {
buttons
.append('button')
.attr('class', 'action col4')
.on('click.confirm', function() {
modal.remove();
modalSelection.remove();
})
.text(t('confirm.okay'));
return modal;
return modalSelection;
};
return modal;
return modalSelection;
}
@@ -1,3 +1,6 @@
import { Icon } from '../svg/index';
import { entityOrMemberSelector } from '../util/index';
import { Extent } from '../geo/index';
export function Conflicts(context) {
var dispatch = d3.dispatch('download', 'cancel', 'save'),
list;
@@ -11,7 +14,7 @@ export function Conflicts(context) {
.append('button')
.attr('class', 'fr')
.on('click', function() { dispatch.cancel(); })
.call(iD.svg.Icon('#icon-close'));
.call(Icon('#icon-close'));
header
.append('h3')
@@ -197,7 +200,7 @@ export function Conflicts(context) {
.selectAll('input')
.property('checked', function(d) { return d === datum; });
var extent = iD.geo.Extent(),
var extent = Extent(),
entity;
entity = context.graph().hasEntity(datum.id);
@@ -223,7 +226,7 @@ export function Conflicts(context) {
context.map().zoomTo(entity);
}
context.surface().selectAll(
iD.util.entityOrMemberSelector([entity.id], context.graph()))
entityOrMemberSelector([entity.id], context.graph()))
.classed('hover', true);
}
}
@@ -1,3 +1,4 @@
import { Icon } from '../svg/index';
export function Contributors(context) {
var debouncedUpdate = _.debounce(function() { update(); }, 1000),
limit = 4,
@@ -16,7 +17,7 @@ export function Contributors(context) {
subset = u.slice(0, u.length > limit ? limit - 1 : limit);
wrap.html('')
.call(iD.svg.Icon('#icon-nearby', 'pre-text light'));
.call(Icon('#icon-nearby', 'pre-text light'));
var userList = d3.select(document.createElement('span'));
-21
View File
@@ -1,21 +0,0 @@
import { modal as modalModule } from './modal';
export function flash(selection) {
var modal = modalModule(selection);
modal.select('.modal').classed('modal-flash', true);
modal.select('.content')
.classed('modal-section', true)
.append('div')
.attr('class', 'description');
modal.on('click.flash', function() { modal.remove(); });
setTimeout(function() {
modal.remove();
return true;
}, 1500);
return modal;
}
@@ -1,4 +1,7 @@
import { preset as presetModule } from './preset';
import { Icon } from '../svg/index';
import { Browse } from '../modes/index';
import { ChangeTags } from '../actions/index';
import { preset } from './preset';
import { PresetIcon } from './preset_icon';
import { RawTagEditor } from './raw_tag_editor';
import { RawMemberEditor } from './raw_member_editor';
@@ -12,10 +15,10 @@ export function EntityEditor(context) {
modified = false,
base,
id,
preset,
activePreset,
reference;
var presetEditor = presetModule(context)
var presetEditor = preset(context)
.on('change', changeTags);
var rawTagEditor = RawTagEditor(context)
.on('change', changeTags);
@@ -38,7 +41,7 @@ export function EntityEditor(context) {
$enter.append('button')
.attr('class', 'fr preset-close')
.call(iD.svg.Icon(modified ? '#icon-apply' : '#icon-close'));
.call(Icon(modified ? '#icon-apply' : '#icon-close'));
$enter.append('h3');
@@ -48,7 +51,7 @@ export function EntityEditor(context) {
$header.select('.preset-close')
.on('click', function() {
context.enter(iD.modes.Browse(context));
context.enter(Browse(context));
});
var $body = selection.selectAll('.inspector-body')
@@ -90,28 +93,28 @@ export function EntityEditor(context) {
selection.selectAll('.preset-reset')
.on('click', function() {
dispatch.choose(preset);
dispatch.choose(activePreset);
});
// Update
$body.select('.preset-list-item button')
.call(PresetIcon()
.geometry(context.geometry(id))
.preset(preset));
.preset(activePreset));
$body.select('.preset-list-item .label')
.text(preset.name());
.text(activePreset.name());
$body.select('.inspector-preset')
.call(presetEditor
.preset(preset)
.preset(activePreset)
.entityID(id)
.tags(tags)
.state(state));
$body.select('.raw-tag-editor')
.call(rawTagEditor
.preset(preset)
.preset(activePreset)
.entityID(id)
.tags(tags)
.state(state));
@@ -198,9 +201,9 @@ export function EntityEditor(context) {
}
if (!_.isEqual(entity.tags, tags)) {
if (coalesceChanges) {
context.overwrite(iD.actions.ChangeTags(id, tags), annotation);
context.overwrite(ChangeTags(id, tags), annotation);
} else {
context.perform(iD.actions.ChangeTags(id, tags), annotation);
context.perform(ChangeTags(id, tags), annotation);
coalesceChanges = !!onInput;
}
}
@@ -230,10 +233,10 @@ export function EntityEditor(context) {
};
entityEditor.preset = function(_) {
if (!arguments.length) return preset;
if (_ !== preset) {
preset = _;
reference = TagReference(preset.reference(context.geometry(id)), context)
if (!arguments.length) return activePreset;
if (_ !== activePreset) {
activePreset = _;
reference = TagReference(activePreset.reference(context.geometry(id)), context)
.showing(false);
}
return entityEditor;
@@ -1,3 +1,4 @@
import { tooltipHtml } from './tooltipHtml';
export function FeatureInfo(context) {
function update(selection) {
var features = context.features(),
@@ -17,7 +18,7 @@ export function FeatureInfo(context) {
.placement('top')
.html(true)
.title(function() {
return iD.ui.tooltipHtml(hiddenList.join('<br/>'));
return tooltipHtml(hiddenList.join('<br/>'));
});
var warning = selection.append('a')
@@ -1,3 +1,8 @@
import { Icon } from '../svg/index';
import { Entity } from '../core/index';
import { displayName, entityOrMemberSelector } from '../util/index';
import { Select } from '../modes/index';
import { Extent, chooseEdge } from '../geo/index';
import * as sexagesimal from 'sexagesimal';
export function FeatureList(context) {
@@ -33,7 +38,7 @@ export function FeatureList(context) {
.on('input', inputevent);
searchWrap
.call(iD.svg.Icon('#icon-search', 'pre-text'));
.call(Icon('#icon-search', 'pre-text'));
var listWrap = selection.append('div')
.attr('class', 'inspector-body');
@@ -95,7 +100,7 @@ export function FeatureList(context) {
entities[entity.id] = true;
var name = iD.util.displayName(entity) || '';
var name = displayName(entity) || '';
if (name.toLowerCase().indexOf(q) >= 0) {
result.push({
id: entity.id,
@@ -120,12 +125,12 @@ export function FeatureList(context) {
// https://github.com/openstreetmap/iD/issues/1890
if (d.osm_type && d.osm_id) {
result.push({
id: iD.Entity.id.fromOSM(d.osm_type, d.osm_id),
id: Entity.id.fromOSM(d.osm_type, d.osm_id),
geometry: d.osm_type === 'relation' ? 'relation' : d.osm_type === 'way' ? 'line' : 'point',
type: d.type !== 'yes' ? (d.type.charAt(0).toUpperCase() + d.type.slice(1)).replace('_', ' ')
: (d.class.charAt(0).toUpperCase() + d.class.slice(1)).replace('_', ' '),
name: d.display_name,
extent: new iD.geo.Extent(
extent: new Extent(
[parseFloat(d.boundingbox[3]), parseFloat(d.boundingbox[0])],
[parseFloat(d.boundingbox[2]), parseFloat(d.boundingbox[1])])
});
@@ -148,7 +153,7 @@ export function FeatureList(context) {
.enter().append('button')
.property('disabled', true)
.attr('class', 'no-results-item')
.call(iD.svg.Icon('#icon-alert', 'pre-text'));
.call(Icon('#icon-alert', 'pre-text'));
resultsIndicator.append('span')
.attr('class', 'entity-name');
@@ -193,7 +198,7 @@ export function FeatureList(context) {
label.each(function(d) {
d3.select(this)
.call(iD.svg.Icon('#icon-' + d.geometry, 'pre-text'));
.call(Icon('#icon-' + d.geometry, 'pre-text'));
});
label.append('span')
@@ -217,7 +222,7 @@ export function FeatureList(context) {
function mouseover(d) {
if (d.id === -1) return;
context.surface().selectAll(iD.util.entityOrMemberSelector([d.id], context.graph()))
context.surface().selectAll(entityOrMemberSelector([d.id], context.graph()))
.classed('hover', true);
}
@@ -236,10 +241,10 @@ export function FeatureList(context) {
context.map().center(d.entity.loc);
} else if (d.entity.type === 'way') {
var center = context.projection(context.map().center()),
edge = iD.geo.chooseEdge(context.childNodes(d.entity), center, context.projection);
edge = chooseEdge(context.childNodes(d.entity), center, context.projection);
context.map().center(edge.loc);
}
context.enter(iD.modes.Select(context, [d.entity.id]).suppressMenu(true));
context.enter(Select(context, [d.entity.id]).suppressMenu(true));
} else {
context.zoomToEntity(d.id);
}
@@ -1,3 +1,5 @@
import { Extent, chooseEdge, sphericalDistance } from '../../geo/index';
export function address(field, context) {
var dispatch = d3.dispatch('init', 'change'),
wrap,
@@ -15,7 +17,7 @@ export function address(field, context) {
function getStreets() {
var extent = entity.extent(context.graph()),
l = extent.center(),
box = iD.geo.Extent(l).padByMeters(200);
box = Extent(l).padByMeters(200);
return context.intersects(box)
.filter(isAddressable)
@@ -23,7 +25,7 @@ export function address(field, context) {
var loc = context.projection([
(extent[0][0] + extent[1][0]) / 2,
(extent[0][1] + extent[1][1]) / 2]),
choice = iD.geo.chooseEdge(context.childNodes(d), loc, context.projection);
choice = chooseEdge(context.childNodes(d), loc, context.projection);
return {
title: d.tags.name,
value: d.tags.name,
@@ -41,7 +43,7 @@ export function address(field, context) {
function getCities() {
var extent = entity.extent(context.graph()),
l = extent.center(),
box = iD.geo.Extent(l).padByMeters(200);
box = Extent(l).padByMeters(200);
return context.intersects(box)
.filter(isAddressable)
@@ -49,7 +51,7 @@ export function address(field, context) {
return {
title: d.tags['addr:city'] || d.tags.name,
value: d.tags['addr:city'] || d.tags.name,
dist: iD.geo.sphericalDistance(d.extent(context.graph()).center(), l)
dist: sphericalDistance(d.extent(context.graph()).center(), l)
};
}).sort(function(a, b) {
return a.dist - b.dist;
@@ -75,7 +77,7 @@ export function address(field, context) {
function getPostCodes() {
var extent = entity.extent(context.graph()),
l = extent.center(),
box = iD.geo.Extent(l).padByMeters(200);
box = Extent(l).padByMeters(200);
return context.intersects(box)
.filter(isAddressable)
@@ -83,7 +85,7 @@ export function address(field, context) {
return {
title: d.tags['addr:postcode'],
value: d.tags['addr:postcode'],
dist: iD.geo.sphericalDistance(d.extent(context.graph()).center(), l)
dist: sphericalDistance(d.extent(context.graph()).center(), l)
};
}).sort(function(a, b) {
return a.dist - b.dist;
@@ -1,4 +1,5 @@
export { check as defaultcheck };
import { oneWayTags } from '../../core/index';
export function check(field) {
var dispatch = d3.dispatch('change'),
options = field.strings && field.strings.options,
@@ -25,7 +26,7 @@ export function check(field) {
// where implied oneway tag exists (e.g. `junction=roundabout`) #2220, #1841
if (field.id === 'oneway') {
for (var key in entity.tags) {
if (key in iD.oneWayTags && (entity.tags[key] in iD.oneWayTags[key])) {
if (key in oneWayTags && (entity.tags[key] in oneWayTags[key])) {
texts[0] = t('presets.fields.oneway_yes.options.undefined');
break;
}
+36
View File
@@ -0,0 +1,36 @@
import { access } from './access';
import { address } from './address';
import { check, defaultcheck} from './check';
import { combo, typeCombo, multiCombo } from './combo';
import { cycleway } from './cycleway';
import { text, url, number, email, tel } from './input';
import { localized } from './localized';
import { lanes } from './lanes';
import { maxspeed } from './maxspeed';
import { radio } from './radio';
import { restrictions } from './restrictions';
import { textarea } from './textarea';
import { wikipedia } from './wikipedia';
export var fields = {
access: access,
address: address,
check: check,
defaultcheck: defaultcheck,
combo: combo,
typeCombo: typeCombo,
multiCombo: multiCombo,
cycleway: cycleway,
text: text,
url: url,
number: number,
email: email,
tel: tel,
localized: localized,
lanes: lanes,
maxspeed: maxspeed,
radio: radio,
restrictions: restrictions,
textarea: textarea,
wikipedia: wikipedia
};
@@ -1,3 +1,5 @@
import { Icon } from '../../svg/index';
import { SuggestNames } from '../../util/index';
export function localized(field, context) {
var dispatch = d3.dispatch('change', 'input'),
wikipedia = iD.services.wikipedia(),
@@ -17,7 +19,7 @@ export function localized(field, context) {
if (field.id === 'name') {
var preset = context.presets().match(entity, context.graph());
input.call(d3.combobox().fetcher(
iD.util.SuggestNames(preset, iD.data.suggestions)
SuggestNames(preset, iD.data.suggestions)
));
}
@@ -33,7 +35,7 @@ export function localized(field, context) {
.append('button')
.attr('class', 'button-input-action localized-add minor')
.attr('tabindex', -1)
.call(iD.svg.Icon('#icon-plus'))
.call(Icon('#icon-plus'))
.call(bootstrap.tooltip()
.title(t('translate.translate'))
.placement('left'));
@@ -150,7 +152,7 @@ export function localized(field, context) {
.style('max-height','0px')
.remove();
})
.call(iD.svg.Icon('#operation-delete'));
.call(Icon('#operation-delete'));
wrap.append('input')
.attr('class', 'localized-lang')
@@ -1,3 +1,4 @@
import { pointInPolygon } from '../../geo/index';
export function maxspeed(field, context) {
var dispatch = d3.dispatch('change'),
entity,
@@ -31,7 +32,7 @@ export function maxspeed(field, context) {
imperial = _.some(iD.data.imperial.features, function(f) {
return _.some(f.geometry.coordinates, function(d) {
return iD.geo.pointInPolygon(loc, d);
return pointInPolygon(loc, d);
});
});
@@ -1,10 +1,15 @@
import { Layers, Vertices, Lines, Turns } from '../../svg/index';
import { Hover } from '../../behavior/index';
import { Entity } from '../../core/index';
import { Intersection, Extent, RawMercator, Turn, inferRestriction } from '../../geo/index';
import { UnrestrictTurn, RestrictTurn } from '../../actions/index';
export function restrictions(field, context) {
var dispatch = d3.dispatch('change'),
hover = iD.behavior.Hover(context),
hover = Hover(context),
vertexID,
fromNodeID;
function restrictions(selection) {
// if form field is hidden or has detached from dom, clean up.
if (!d3.select('.inspector-wrap.inspector-hidden').empty() || !selection.node().parentNode) {
@@ -24,12 +29,12 @@ export function restrictions(field, context) {
.attr('class', 'restriction-help');
var intersection = iD.geo.Intersection(context.graph(), vertexID),
var intersection = Intersection(context.graph(), vertexID),
graph = intersection.graph,
vertex = graph.entity(vertexID),
filter = d3.functor(true),
extent = iD.geo.Extent(),
projection = iD.geo.RawMercator();
extent = Extent(),
projection = RawMercator();
var d = wrap.dimensions(),
c = [d[0] / 2, d[1] / 2],
@@ -44,10 +49,10 @@ export function restrictions(field, context) {
.translate([c[0] - s[0], c[1] - s[1]])
.clipExtent([[0, 0], d]);
var drawLayers = iD.svg.Layers(projection, context).only('osm').dimensions(d),
drawVertices = iD.svg.Vertices(projection, context),
drawLines = iD.svg.Lines(projection, context),
drawTurns = iD.svg.Turns(projection, context);
var drawLayers = Layers(projection, context).only('osm').dimensions(d),
drawVertices = Vertices(projection, context),
drawLines = Lines(projection, context),
drawTurns = Turns(projection, context);
enter
.call(drawLayers)
@@ -91,17 +96,17 @@ export function restrictions(field, context) {
function click() {
var datum = d3.event.target.__data__;
if (datum instanceof iD.Entity) {
if (datum instanceof Entity) {
fromNodeID = intersection.adjacentNodeId(datum.id);
render();
} else if (datum instanceof iD.geo.Turn) {
} else if (datum instanceof Turn) {
if (datum.restriction) {
context.perform(
iD.actions.UnrestrictTurn(datum, projection),
UnrestrictTurn(datum, projection),
t('operations.restriction.annotation.delete'));
} else {
context.perform(
iD.actions.RestrictTurn(datum, projection),
RestrictTurn(datum, projection),
t('operations.restriction.annotation.create'));
}
}
@@ -109,7 +114,7 @@ export function restrictions(field, context) {
function mouseover() {
var datum = d3.event.target.__data__;
if (datum instanceof iD.geo.Turn) {
if (datum instanceof Turn) {
var graph = context.graph(),
presets = context.presets(),
preset;
@@ -118,7 +123,7 @@ export function restrictions(field, context) {
preset = presets.match(graph.entity(datum.restriction), graph);
} else {
preset = presets.item('type/restriction/' +
iD.geo.inferRestriction(
inferRestriction(
graph,
datum.from,
datum.via,
@@ -1,3 +1,5 @@
import { Icon } from '../../svg/index';
import { ChangeTags } from '../../actions/index';
export function wikipedia(field, context) {
var dispatch = d3.dispatch('change'),
wikipedia = iD.services.wikipedia(),
@@ -65,7 +67,7 @@ export function wikipedia(field, context) {
.attr('class', 'wiki-link button-input-action minor')
.attr('tabindex', -1)
.attr('target', '_blank')
.call(iD.svg.Icon('#icon-out-link', 'inline'));
.call(Icon('#icon-out-link', 'inline'));
}
function language() {
@@ -148,7 +150,7 @@ export function wikipedia(field, context) {
return id.match(/^Q\d+$/);
});
context.overwrite(iD.actions.ChangeTags(currEntityId, currTags), annotation);
context.overwrite(ChangeTags(currEntityId, currTags), annotation);
dispatch.change(currTags);
});
}
+21
View File
@@ -0,0 +1,21 @@
import { modal } from './modal';
export function flash(selection) {
var modalSelection = modal(selection);
modalSelection.select('.modal').classed('modal-flash', true);
modalSelection.select('.content')
.classed('modal-section', true)
.append('div')
.attr('class', 'description');
modalSelection.on('click.flash', function() { modalSelection.remove(); });
setTimeout(function() {
modalSelection.remove();
return true;
}, 1500);
return modalSelection;
}
@@ -1,3 +1,6 @@
import { Icon } from '../svg/index';
import { Browse } from '../modes/index';
import { Extent } from '../geo/index';
import { Loading } from './loading';
export function Geolocate(context) {
@@ -6,7 +9,7 @@ export function Geolocate(context) {
timeoutId;
function click() {
context.enter(iD.modes.Browse(context));
context.enter(Browse(context));
context.container().call(locating);
navigator.geolocation.getCurrentPosition(success, error, geoOptions);
@@ -17,7 +20,7 @@ export function Geolocate(context) {
function success(position) {
var map = context.map(),
extent = iD.geo.Extent([position.coords.longitude, position.coords.latitude])
extent = Extent([position.coords.longitude, position.coords.latitude])
.padByMeters(position.coords.accuracy);
map.centerZoom(extent.center(), Math.min(20, map.extentZoom(extent)));
@@ -41,7 +44,7 @@ export function Geolocate(context) {
.attr('tabindex', -1)
.attr('title', t('geolocate.title'))
.on('click', click)
.call(iD.svg.Icon('#icon-geolocate', 'light'))
.call(Icon('#icon-geolocate', 'light'))
.call(bootstrap.tooltip()
.placement('left'));
};
@@ -1,4 +1,6 @@
import { Icon } from '../svg/index';
import { intro } from './intro';
import { tooltipHtml } from './tooltipHtml';
export function Help(context) {
var key = 'H';
@@ -102,11 +104,11 @@ export function Help(context) {
tooltip = bootstrap.tooltip()
.placement('left')
.html(true)
.title(iD.ui.tooltipHtml(t('help.title'), key)),
.title(tooltipHtml(t('help.title'), key)),
button = selection.append('button')
.attr('tabindex', -1)
.on('click', toggle)
.call(iD.svg.Icon('#icon-help', 'light'))
.call(Icon('#icon-help', 'light'))
.call(tooltip),
shown = false;
@@ -1,3 +1,5 @@
export { init } from './init';
export { fields } from './fields/index';
export { Account } from './account';
export { Attribution } from './attribution';
export { Background } from './background';
@@ -43,6 +45,7 @@ export { Status } from './status';
export { Success } from './success';
export { TagReference } from './tag_reference';
export { Toggle } from './toggle';
export { tooltipHtml } from './tooltipHtml';
export { UndoRedo } from './undo_redo';
export { ViewOnOSM } from './view_on_osm';
export { Zoom } from './zoom';
@@ -1,3 +1,4 @@
import { Extent } from '../geo/index';
import { cmd } from './cmd';
export function Info(context) {
@@ -103,7 +104,7 @@ export function Info(context) {
var resolver = context.graph(),
selected = _.filter(context.selectedIDs(), function(e) { return context.hasEntity(e); }),
singular = selected.length === 1 ? selected[0] : null,
extent = iD.geo.Extent(),
extent = Extent(),
entity;
wrap.html('');
+146 -41
View File
@@ -1,10 +1,66 @@
export function ui(context) {
import { fields } from './fields/index';
import { Account } from './account';
import { Attribution } from './attribution';
import { Background } from './background';
import { cmd } from './cmd';
import { Commit } from './commit';
import { confirm } from './confirm';
import { Conflicts } from './conflicts';
import { Contributors } from './contributors';
import { Disclosure } from './disclosure';
import { EntityEditor } from './entity_editor';
import { FeatureInfo } from './feature_info';
import { FeatureList } from './feature_list';
import { flash } from './flash';
import { FullScreen } from './full_screen';
import { Geolocate } from './geolocate';
import { Help } from './help';
import { Info } from './info';
import { Inspector } from './inspector';
import { intro } from './intro/index';
import { Lasso } from './lasso';
import { Loading } from './loading';
import { MapData } from './map_data';
import { MapInMap } from './map_in_map';
import { modal } from './modal';
import { Modes } from './modes';
import { Notice } from './notice';
import { preset } from './preset';
import { PresetIcon } from './preset_icon';
import { PresetList } from './preset_list';
import { RadialMenu } from './radial_menu';
import { RawMemberEditor } from './raw_member_editor';
import { RawMembershipEditor } from './raw_membership_editor';
import { RawTagEditor } from './raw_tag_editor';
import { Restore } from './restore';
import { Save } from './save';
import { Scale } from './scale';
import { SelectionList } from './selection_list';
import { Sidebar } from './sidebar';
import { SourceSwitch } from './source_switch';
import { Spinner } from './spinner';
import { Splash } from './splash';
import { Status } from './status';
import { Success } from './success';
import { TagReference } from './tag_reference';
import { Toggle } from './toggle';
import { tooltipHtml } from './tooltipHtml';
import { UndoRedo } from './undo_redo';
import { ViewOnOSM } from './view_on_osm';
import { Zoom } from './zoom';
import { Defs, Icon } from '../svg/index';
import { Hash } from '../behavior/index';
import { Browse } from '../modes/index';
export function init(context) {
function render(container) {
var map = context.map();
if (iD.detect().opera) container.classed('opera', true);
var hash = iD.behavior.Hash(context);
var hash = Hash(context);
hash();
@@ -14,7 +70,7 @@ export function ui(context) {
container.append('svg')
.attr('id', 'defs')
.call(iD.svg.Defs(context));
.call(Defs(context));
container.append('div')
.attr('id', 'sidebar')
@@ -33,10 +89,10 @@ export function ui(context) {
.call(map);
content
.call(iD.ui.MapInMap(context));
.call(MapInMap(context));
content.append('div')
.call(iD.ui.Info(context));
.call(Info(context));
bar.append('div')
.attr('class', 'spacer col4');
@@ -46,53 +102,53 @@ export function ui(context) {
limiter.append('div')
.attr('class', 'button-wrap joined col3')
.call(iD.ui.Modes(context), limiter);
.call(Modes(context), limiter);
limiter.append('div')
.attr('class', 'button-wrap joined col1')
.call(iD.ui.UndoRedo(context));
.call(UndoRedo(context));
limiter.append('div')
.attr('class', 'button-wrap col1')
.call(iD.ui.Save(context));
.call(Save(context));
bar.append('div')
.attr('class', 'full-screen')
.call(iD.ui.FullScreen(context));
.call(FullScreen(context));
bar.append('div')
.attr('class', 'spinner')
.call(iD.ui.Spinner(context));
.call(Spinner(context));
var controls = bar.append('div')
.attr('class', 'map-controls');
controls.append('div')
.attr('class', 'map-control zoombuttons')
.call(iD.ui.Zoom(context));
.call(Zoom(context));
controls.append('div')
.attr('class', 'map-control geolocate-control')
.call(iD.ui.Geolocate(context));
.call(Geolocate(context));
controls.append('div')
.attr('class', 'map-control background-control')
.call(iD.ui.Background(context));
.call(Background(context));
controls.append('div')
.attr('class', 'map-control map-data-control')
.call(iD.ui.MapData(context));
.call(MapData(context));
controls.append('div')
.attr('class', 'map-control help-control')
.call(iD.ui.Help(context));
.call(Help(context));
var about = content.append('div')
.attr('id', 'about');
about.append('div')
.attr('id', 'attrib')
.call(iD.ui.Attribution(context));
.call(Attribution(context));
var footer = about.append('div')
.attr('id', 'footer')
@@ -100,11 +156,11 @@ export function ui(context) {
footer.append('div')
.attr('class', 'api-status')
.call(iD.ui.Status(context));
.call(Status(context));
footer.append('div')
.attr('id', 'scale-block')
.call(iD.ui.Scale(context));
.call(Scale(context));
var aboutList = footer.append('div')
.attr('id', 'info-block')
@@ -112,7 +168,7 @@ export function ui(context) {
.attr('id', 'about-list');
if (!context.embed()) {
aboutList.call(iD.ui.Account(context));
aboutList.call(Account(context));
}
aboutList.append('li')
@@ -128,7 +184,7 @@ export function ui(context) {
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('href', 'https://github.com/openstreetmap/iD/issues')
.call(iD.svg.Icon('#icon-bug', 'light'))
.call(Icon('#icon-bug', 'light'))
.call(bootstrap.tooltip()
.title(t('report_a_bug'))
.placement('top')
@@ -138,7 +194,7 @@ export function ui(context) {
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('href', 'https://github.com/openstreetmap/iD/blob/master/CONTRIBUTING.md#translating')
.call(iD.svg.Icon('#icon-translate', 'light'))
.call(Icon('#icon-translate', 'light'))
.call(bootstrap.tooltip()
.title(t('help_translate'))
.placement('top')
@@ -147,12 +203,12 @@ export function ui(context) {
aboutList.append('li')
.attr('class', 'feature-warning')
.attr('tabindex', -1)
.call(iD.ui.FeatureInfo(context));
.call(FeatureInfo(context));
aboutList.append('li')
.attr('class', 'user-list')
.attr('tabindex', -1)
.call(iD.ui.Contributors(context));
.call(Contributors(context));
window.onbeforeunload = function() {
return context.save();
@@ -189,21 +245,21 @@ export function ui(context) {
.on('⇧↑', pan([0, mapDimensions[1]]))
.on('⇧→', pan([-mapDimensions[0], 0]))
.on('⇧↓', pan([0, -mapDimensions[1]]))
.on(iD.ui.cmd('⌘←'), pan([mapDimensions[0], 0]))
.on(iD.ui.cmd('⌘↑'), pan([0, mapDimensions[1]]))
.on(iD.ui.cmd('⌘→'), pan([-mapDimensions[0], 0]))
.on(iD.ui.cmd('⌘↓'), pan([0, -mapDimensions[1]]));
.on(cmd('⌘←'), pan([mapDimensions[0], 0]))
.on(cmd('⌘↑'), pan([0, mapDimensions[1]]))
.on(cmd('⌘→'), pan([-mapDimensions[0], 0]))
.on(cmd('⌘↓'), pan([0, -mapDimensions[1]]));
d3.select(document)
.call(keybinding);
context.enter(iD.modes.Browse(context));
context.enter(Browse(context));
context.container()
.call(iD.ui.Splash(context))
.call(iD.ui.Restore(context));
.call(Splash(context))
.call(Restore(context));
var authenticating = iD.ui.Loading(context)
var authenticating = Loading(context)
.message(t('loading_auth'));
context.connection()
@@ -223,17 +279,66 @@ export function ui(context) {
});
}
ui.sidebar = iD.ui.Sidebar(context);
//TODO: figure this sidebar
ui.sidebar = Sidebar(context);
return ui;
}
ui.tooltipHtml = function(text, key) {
var s = '<span>' + text + '</span>';
if (key) {
s += '<div class="keyhint-wrap">' +
'<span> ' + (t('tooltip_keyhint')) + ' </span>' +
'<span class="keyhint"> ' + key + '</span></div>';
}
return s;
};
//
// ui.preset = preset;
// Object.keys(fields).map(function(p) {
// ui.preset[p] = fields[p];
// });
//
// ui.intro = intro;
// ui.Account = Account;
// ui.Attribution = Attribution;
// ui.Background = Background;
// ui.cmd = cmd;
// ui.Commit = Commit;
// ui.confirm = confirm;
// ui.Conflicts = Conflicts;
// ui.Contributors = Contributors;
// ui.Disclosure = Disclosure;
// ui.EntityEditor = EntityEditor;
// ui.FeatureInfo = FeatureInfo;
// ui.FeatureList = FeatureList;
// ui.flash = flash;
// ui.FullScreen = FullScreen;
// ui.Geolocate = Geolocate;
// ui.Help = Help;
// ui.Info = Info;
// ui.Inspector = Inspector;
// ui.intro = intro;
// ui.Lasso = Lasso;
// ui.Loading = Loading;
// ui.MapData = MapData;
// ui.MapInMap = MapInMap;
// ui.modal = modal;
// ui.Modes = Modes;
// ui.Notice = Notice;
// ui.preset = preset;
// ui.PresetIcon = PresetIcon;
// ui.PresetList = PresetList;
// ui.RadialMenu = RadialMenu;
// ui.RawMemberEditor = RawMemberEditor;
// ui.RawMembershipEditor = RawMembershipEditor;
// ui.RawTagEditor = RawTagEditor;
// ui.Restore = Restore;
// ui.Save = Save;
// ui.Scale = Scale;
// ui.SelectionList = SelectionList;
// ui.Sidebar = Sidebar;
// ui.SourceSwitch = SourceSwitch;
// ui.Spinner = Spinner;
// ui.Splash = Splash;
// ui.Status = Status;
// ui.Success = Success;
// ui.TagReference = TagReference;
// ui.Toggle = Toggle;
// ui.tooltipHtml = tooltipHtml;
// ui.UndoRedo = UndoRedo;
// ui.ViewOnOSM = ViewOnOSM;
// ui.Zoom = Zoom;
+8 -6
View File
@@ -1,3 +1,5 @@
import { icon, pad } from './helper';
export function area(context, reveal) {
var event = d3.dispatch('done'),
timeout;
@@ -11,7 +13,7 @@ export function area(context, reveal) {
corner = [-85.63565411045074, 41.9417715536927];
context.map().centerZoom(playground, 19);
reveal('button.add-area',
t('intro.areas.add', { button: iD.ui.intro.icon('#icon-area', 'pre-text') }),
t('intro.areas.add', { button: icon('#icon-area', 'pre-text') }),
{ tooltipClass: 'intro-areas-add' });
context.on('enter.intro', addArea);
@@ -21,12 +23,12 @@ export function area(context, reveal) {
context.on('enter.intro', drawArea);
var padding = 120 * Math.pow(2, context.map().zoom() - 19);
var pointBox = iD.ui.intro.pad(corner, padding, context);
var pointBox = pad(corner, padding, context);
reveal(pointBox, t('intro.areas.corner'));
context.map().on('move.intro', function() {
padding = 120 * Math.pow(2, context.map().zoom() - 19);
pointBox = iD.ui.intro.pad(corner, padding, context);
pointBox = pad(corner, padding, context);
reveal(pointBox, t('intro.areas.corner'), {duration: 0});
});
}
@@ -36,12 +38,12 @@ export function area(context, reveal) {
context.on('enter.intro', enterSelect);
var padding = 150 * Math.pow(2, context.map().zoom() - 19);
var pointBox = iD.ui.intro.pad(playground, padding, context);
var pointBox = pad(playground, padding, context);
reveal(pointBox, t('intro.areas.place'));
context.map().on('move.intro', function() {
padding = 150 * Math.pow(2, context.map().zoom() - 19);
pointBox = iD.ui.intro.pad(playground, padding, context);
pointBox = pad(playground, padding, context);
reveal(pointBox, t('intro.areas.place'), {duration: 0});
});
}
@@ -70,7 +72,7 @@ export function area(context, reveal) {
function selectedPreset() {
reveal('.pane',
t('intro.areas.describe', { button: iD.ui.intro.icon('#icon-apply', 'pre-text') }));
t('intro.areas.describe', { button: icon('#icon-apply', 'pre-text') }));
context.on('exit.intro', event.done);
}
};
+32
View File
@@ -0,0 +1,32 @@
export function pointBox (point, context) {
var rect = context.surfaceRect();
point = context.projection(point);
return {
left: point[0] + rect.left - 30,
top: point[1] + rect.top - 50,
width: 60,
height: 70
};
}
export function pad (box, padding, context) {
if (box instanceof Array) {
var rect = context.surfaceRect();
box = context.projection(box);
box = {
left: box[0] + rect.left,
top: box[1] + rect.top
};
}
return {
left: box.left - padding,
top: box.top - padding,
width: (box.width || 0) + 2 * padding,
height: (box.width || 0) + 2 * padding
};
}
export function icon(name, svgklass) {
return '<svg class="icon ' + (svgklass || '') + '">' +
'<use xlink:href="' + name + '"></use></svg>';
}
+1 -5
View File
@@ -1,5 +1 @@
export { area } from './area';
export { line } from './line';
export { navigation } from './navigation';
export { point } from './point';
export { startEditing } from './start_editing';
export { intro } from './intro';
@@ -1,3 +1,20 @@
import { Icon } from '../../svg/index';
import { Entity, Graph } from '../../core/index';
import { Browse } from '../../modes/index';
import { area } from './area';
import { line } from './line';
import { navigation } from './navigation';
import { point } from './point';
import { startEditing } from './start_editing';
var sampleIntros = {
area: area,
line: line,
navigation: navigation,
point: point,
startEditing: startEditing
};
export function intro(context) {
var step;
@@ -50,7 +67,7 @@ export function intro(context) {
return features[id] && t('intro.graph.' + features[id]);
}
context.enter(iD.modes.Browse(context));
context.enter(Browse(context));
// Save current map state
var history = context.history().toJSON(),
@@ -72,13 +89,13 @@ export function intro(context) {
introGraph = JSON.parse(iD.introGraph);
for (var key in introGraph) {
introGraph[key] = iD.Entity(introGraph[key]);
introGraph[key] = Entity(introGraph[key]);
name = localizedName(key);
if (name) {
introGraph[key].tags.name = name;
}
}
context.history().merge(d3.values(iD.Graph().load(introGraph).entities));
context.history().merge(d3.values(Graph().load(introGraph).entities));
context.background().bing();
d3.selectAll('#map .layer-background').style('opacity', 1);
@@ -93,7 +110,7 @@ export function intro(context) {
}
var steps = ['navigation', 'point', 'area', 'line', 'startEditing'].map(function(step, i) {
var s = iD.ui.intro[step](context, reveal)
var s = sampleIntros[step](context, reveal)
.on('done', function() {
entered.filter(function(d) {
return d.title === s.title;
@@ -130,7 +147,7 @@ export function intro(context) {
.on('click', enter);
entered
.call(iD.svg.Icon('#icon-apply', 'pre-text'));
.call(Icon('#icon-apply', 'pre-text'));
entered
.append('label')
@@ -141,7 +158,7 @@ export function intro(context) {
function enter (newStep) {
if (step) { step.exit(); }
context.enter(iD.modes.Browse(context));
context.enter(Browse(context));
step = newStep;
step.enter();
+14 -10
View File
@@ -1,3 +1,7 @@
import { icon, pad } from './helper';
import { DeleteMultiple } from '../../actions/index';
export function line(context, reveal) {
var event = d3.dispatch('done'),
timeouts = [];
@@ -23,7 +27,7 @@ export function line(context, reveal) {
context.map().centerZoom(start, 18);
reveal('button.add-line',
t('intro.lines.add', { button: iD.ui.intro.icon('#icon-line', 'pre-text') }),
t('intro.lines.add', { button: icon('#icon-line', 'pre-text') }),
{ tooltipClass: 'intro-lines-add' });
context.on('enter.intro', addLine);
@@ -33,12 +37,12 @@ export function line(context, reveal) {
context.on('enter.intro', drawLine);
var padding = 150 * Math.pow(2, context.map().zoom() - 18);
var pointBox = iD.ui.intro.pad(start, padding, context);
var pointBox = pad(start, padding, context);
reveal(pointBox, t('intro.lines.start'));
context.map().on('move.intro', function() {
padding = 150 * Math.pow(2, context.map().zoom() - 18);
pointBox = iD.ui.intro.pad(start, padding, context);
pointBox = pad(start, padding, context);
reveal(pointBox, t('intro.lines.start'), {duration: 0});
});
}
@@ -49,12 +53,12 @@ export function line(context, reveal) {
context.on('enter.intro', retry);
var padding = 300 * Math.pow(2, context.map().zoom() - 19);
var pointBox = iD.ui.intro.pad(midpoint, padding, context);
var pointBox = pad(midpoint, padding, context);
reveal(pointBox, t('intro.lines.intersect', {name: t('intro.graph.flower_st')}));
context.map().on('move.intro', function() {
padding = 300 * Math.pow(2, context.map().zoom() - 19);
pointBox = iD.ui.intro.pad(midpoint, padding, context);
pointBox = pad(midpoint, padding, context);
reveal(pointBox, t('intro.lines.intersect', {name: t('intro.graph.flower_st')}), {duration: 0});
});
}
@@ -62,13 +66,13 @@ export function line(context, reveal) {
// ended line before creating intersection
function retry(mode) {
if (mode.id !== 'select') return;
var pointBox = iD.ui.intro.pad(intersection, 30, context),
var pointBox = pad(intersection, 30, context),
ids = mode.selectedIDs();
reveal(pointBox, t('intro.lines.restart', {name: t('intro.graph.flower_st')}));
d3.select(window).on('mousedown.intro', eventCancel, true);
timeout(function() {
context.replace(iD.actions.DeleteMultiple(ids));
context.replace(DeleteMultiple(ids));
step.exit();
step.enter();
}, 3000);
@@ -82,12 +86,12 @@ export function line(context, reveal) {
context.on('enter.intro', enterSelect);
var padding = 900 * Math.pow(2, context.map().zoom() - 19);
var pointBox = iD.ui.intro.pad(centroid, padding, context);
var pointBox = pad(centroid, padding, context);
reveal(pointBox, t('intro.lines.finish'));
context.map().on('move.intro', function() {
padding = 900 * Math.pow(2, context.map().zoom() - 19);
pointBox = iD.ui.intro.pad(centroid, padding, context);
pointBox = pad(centroid, padding, context);
reveal(pointBox, t('intro.lines.finish'), {duration: 0});
});
}
@@ -133,7 +137,7 @@ export function line(context, reveal) {
function roadDetails() {
reveal('.pane',
t('intro.lines.describe', { button: iD.ui.intro.icon('#icon-apply', 'pre-text') }));
t('intro.lines.describe', { button: icon('#icon-apply', 'pre-text') }));
context.on('exit.intro', event.done);
}
+6 -4
View File
@@ -1,3 +1,5 @@
import { icon, pointBox } from './helper';
export function navigation(context, reveal) {
var event = d3.dispatch('done'),
timeouts = [];
@@ -43,11 +45,11 @@ export function navigation(context, reveal) {
context.map().center(hall);
}
var box = iD.ui.intro.pointBox(hall, context);
var box = pointBox(hall, context);
reveal(box, t('intro.navigation.select'));
context.map().on('move.intro', function() {
var box = iD.ui.intro.pointBox(hall, context);
var box = pointBox(hall, context);
reveal(box, t('intro.navigation.select'), {duration: 0});
});
}
@@ -58,7 +60,7 @@ export function navigation(context, reveal) {
context.map().on('move.intro', null);
set(function() {
reveal('.entity-editor-pane',
t('intro.navigation.pane', { button: iD.ui.intro.icon('#icon-close', 'pre-text') }));
t('intro.navigation.pane', { button: icon('#icon-close', 'pre-text') }));
context.on('exit.intro', streetSearch);
}, 700);
}
@@ -92,7 +94,7 @@ export function navigation(context, reveal) {
reveal('.entity-editor-pane',
t('intro.navigation.chosen', {
name: t('intro.graph.spring_st'),
button: iD.ui.intro.icon('#icon-close', 'pre-text')
button: icon('#icon-close', 'pre-text')
}));
}, 400);
}
+13 -11
View File
@@ -1,3 +1,5 @@
import { icon, pad } from './helper';
export function point(context, reveal) {
var event = d3.dispatch('done'),
timeouts = [];
@@ -18,7 +20,7 @@ export function point(context, reveal) {
step.enter = function() {
context.map().centerZoom([-85.63279, 41.94394], 19);
reveal('button.add-point',
t('intro.points.add', { button: iD.ui.intro.icon('#icon-point', 'pre-text') }),
t('intro.points.add', { button: icon('#icon-point', 'pre-text') }),
{ tooltipClass: 'intro-points-add' });
var corner = [-85.632481,41.944094];
@@ -29,11 +31,11 @@ export function point(context, reveal) {
if (mode.id !== 'add-point') return;
context.on('enter.intro', enterSelect);
var pointBox = iD.ui.intro.pad(corner, 150, context);
var pointBox = pad(corner, 150, context);
reveal(pointBox, t('intro.points.place'));
context.map().on('move.intro', function() {
pointBox = iD.ui.intro.pad(corner, 150, context);
pointBox = pad(corner, 150, context);
reveal(pointBox, t('intro.points.place'), {duration: 0});
});
}
@@ -73,7 +75,7 @@ export function point(context, reveal) {
d3.select('.preset-search-input').on('keydown.intro', null);
context.history().on('change.intro', null);
reveal('.entity-editor-pane',
t('intro.points.close', { button: iD.ui.intro.icon('#icon-apply', 'pre-text') }));
t('intro.points.close', { button: icon('#icon-apply', 'pre-text') }));
}
function selectPoint() {
@@ -81,11 +83,11 @@ export function point(context, reveal) {
context.history().on('change.intro', null);
context.on('enter.intro', enterReselect);
var pointBox = iD.ui.intro.pad(corner, 150, context);
var pointBox = pad(corner, 150, context);
reveal(pointBox, t('intro.points.reselect'));
context.map().on('move.intro', function() {
pointBox = iD.ui.intro.pad(corner, 150, context);
pointBox = pad(corner, 150, context);
reveal(pointBox, t('intro.points.reselect'), {duration: 0});
});
}
@@ -97,7 +99,7 @@ export function point(context, reveal) {
setTimeout(function() {
reveal('.entity-editor-pane',
t('intro.points.fixname', { button: iD.ui.intro.icon('#icon-apply', 'pre-text') }));
t('intro.points.fixname', { button: icon('#icon-apply', 'pre-text') }));
context.on('exit.intro', deletePoint);
}, 500);
}
@@ -106,11 +108,11 @@ export function point(context, reveal) {
context.on('exit.intro', null);
context.on('enter.intro', enterDelete);
var pointBox = iD.ui.intro.pad(corner, 150, context);
var pointBox = pad(corner, 150, context);
reveal(pointBox, t('intro.points.reselect_delete'));
context.map().on('move.intro', function() {
pointBox = iD.ui.intro.pad(corner, 150, context);
pointBox = pad(corner, 150, context);
reveal(pointBox, t('intro.points.reselect_delete'), {duration: 0});
});
}
@@ -125,9 +127,9 @@ export function point(context, reveal) {
setTimeout(function() {
var node = d3.select('.radial-menu-item-delete').node();
var pointBox = iD.ui.intro.pad(node.getBoundingClientRect(), 50, context);
var pointBox = pad(node.getBoundingClientRect(), 50, context);
reveal(pointBox,
t('intro.points.delete', { button: iD.ui.intro.icon('#operation-delete', 'pre-text') }));
t('intro.points.delete', { button: icon('#operation-delete', 'pre-text') }));
}, 300);
}
+11 -8
View File
@@ -1,6 +1,9 @@
import { modal } from '../modal';
import { icon } from './helper';
export function startEditing(context, reveal) {
var event = d3.dispatch('done', 'startEditing'),
modal,
modalSelection,
timeouts = [];
var step = {
@@ -13,7 +16,7 @@ export function startEditing(context, reveal) {
step.enter = function() {
reveal('.map-control.help-control',
t('intro.startediting.help', { button: iD.ui.intro.icon('#icon-help', 'pre-text') }));
t('intro.startediting.help', { button: icon('#icon-help', 'pre-text') }));
timeout(function() {
reveal('#bar button.save', t('intro.startediting.save'));
@@ -24,19 +27,19 @@ export function startEditing(context, reveal) {
}, 10000);
timeout(function() {
modal = iD.ui.modal(context.container());
modalSelection = modal(context.container());
modal.select('.modal')
modalSelection.select('.modal')
.attr('class', 'modal-splash modal col6');
modal.selectAll('.close').remove();
modalSelection.selectAll('.close').remove();
var startbutton = modal.select('.content')
var startbutton = modalSelection.select('.content')
.attr('class', 'fillL')
.append('button')
.attr('class', 'modal-section huge-modal-button')
.on('click', function() {
modal.remove();
modalSelection.remove();
});
startbutton.append('div')
@@ -49,7 +52,7 @@ export function startEditing(context, reveal) {
};
step.exit = function() {
if (modal) modal.remove();
if (modalSelection) modalSelection.remove();
timeouts.forEach(window.clearTimeout);
};
@@ -1,3 +1,4 @@
import { Extent } from '../geo/index';
import { Toggle } from './toggle';
export function Lasso(context) {
@@ -28,8 +29,8 @@ export function Lasso(context) {
lasso.extent = function () {
return lasso.coordinates.reduce(function(extent, point) {
return extent.extend(iD.geo.Extent(point));
}, iD.geo.Extent());
return extent.extend(Extent(point));
}, Extent());
};
lasso.p = function(_) {
@@ -1,14 +1,14 @@
import { modal as modalModule } from './modal';
import { modal } from './modal';
export function Loading(context) {
var message = '',
blocking = false,
modal;
modalSelection;
var loading = function(selection) {
modal = modalModule(selection, blocking);
modalSelection = modal(selection, blocking);
var loadertext = modal.select('.content')
var loadertext = modalSelection.select('.content')
.classed('loading-modal', true)
.append('div')
.attr('class', 'modal-section fillL');
@@ -20,7 +20,7 @@ export function Loading(context) {
loadertext.append('h3')
.text(message);
modal.select('button.close')
modalSelection.select('button.close')
.attr('class', 'hide');
return loading;
@@ -39,7 +39,7 @@ export function Loading(context) {
};
loading.close = function() {
modal.remove();
modalSelection.remove();
};
return loading;
@@ -1,3 +1,6 @@
import { Icon } from '../svg/index';
import { tooltipHtml } from './tooltipHtml';
export function MapData(context) {
var key = 'F',
features = context.features().keys(),
@@ -184,7 +187,7 @@ export function MapData(context) {
d3.event.stopPropagation();
gpx.fitZoom();
})
.call(iD.svg.Icon('#icon-search'));
.call(Icon('#icon-search'));
enter.append('button')
.attr('class', 'list-item-gpx-browse')
@@ -199,7 +202,7 @@ export function MapData(context) {
})
.node().click();
})
.call(iD.svg.Icon('#icon-geolocate'));
.call(Icon('#icon-geolocate'));
var labelGpx = enter.append('label')
.call(bootstrap.tooltip()
@@ -247,7 +250,7 @@ export function MapData(context) {
if (name === 'feature' && autoHiddenFeature(d)) {
tip += '<div>' + t('map_data.autohidden') + '</div>';
}
return iD.ui.tooltipHtml(tip, key);
return tooltipHtml(tip, key);
})
.placement('top')
);
@@ -340,11 +343,11 @@ export function MapData(context) {
tooltip = bootstrap.tooltip()
.placement('left')
.html(true)
.title(iD.ui.tooltipHtml(t('map_data.description'), key)),
.title(tooltipHtml(t('map_data.description'), key)),
button = selection.append('button')
.attr('tabindex', -1)
.on('click', togglePanel)
.call(iD.svg.Icon('#icon-data', 'light'))
.call(Icon('#icon-data', 'light'))
.call(tooltip),
shown = false;
@@ -1,12 +1,17 @@
import { Gpx, Debug } from '../svg/index';
import { setTransform } from '../util/index';
import { RawMercator } from '../geo/index';
import { TileLayer } from '../renderer/index';
export function MapInMap(context) {
var key = '/';
function map_in_map(selection) {
var backgroundLayer = iD.TileLayer(context),
var backgroundLayer = TileLayer(context),
overlayLayers = {},
projection = iD.geo.RawMercator(),
gpxLayer = iD.svg.Gpx(projection, context).showLabels(false),
debugLayer = iD.svg.Debug(projection, context),
projection = RawMercator(),
gpxLayer = Gpx(projection, context).showLabels(false),
debugLayer = Debug(projection, context),
zoom = d3.behavior.zoom()
.scaleExtent([ztok(0.5), ztok(24)])
.on('zoom', zoomPan),
@@ -51,8 +56,8 @@ export function MapInMap(context) {
tX = (tCurr[0] / scale - tLast[0]) * scale,
tY = (tCurr[1] / scale - tLast[1]) * scale;
iD.util.setTransform(tiles, tX, tY, scale);
iD.util.setTransform(viewport, 0, 0, scale);
setTransform(tiles, tX, tY, scale);
setTransform(viewport, 0, 0, scale);
transformed = true;
queueRedraw();
@@ -112,8 +117,8 @@ export function MapInMap(context) {
kLast = kCurr = kMini;
if (transformed) {
iD.util.setTransform(tiles, 0, 0);
iD.util.setTransform(viewport, 0, 0);
setTransform(tiles, 0, 0);
setTransform(viewport, 0, 0);
transformed = false;
}
}
@@ -160,7 +165,7 @@ export function MapInMap(context) {
var activeOverlayLayers = [];
for (var i = 0; i < overlaySources.length; i++) {
if (overlaySources[i].validZoom(zMini)) {
if (!overlayLayers[i]) overlayLayers[i] = iD.TileLayer(context);
if (!overlayLayers[i]) overlayLayers[i] = TileLayer(context);
activeOverlayLayers.push(overlayLayers[i]
.source(overlaySources[i])
.projection(projection)
@@ -1,3 +1,4 @@
import { Icon } from '../svg/index';
export function modal(selection, blocking) {
var keybinding = d3.keybinding('modal');
var previous = selection.select('div.modal');
@@ -41,7 +42,7 @@ export function modal(selection, blocking) {
modal.append('button')
.attr('class', 'close')
.on('click', shaded.close)
.call(iD.svg.Icon('#icon-close'));
.call(Icon('#icon-close'));
keybinding
.on('⌫', shaded.close)
@@ -1,8 +1,12 @@
import { Icon } from '../svg/index';
import { AddPoint, AddLine, AddArea, Browse } from '../modes/index';
import { tooltipHtml } from './tooltipHtml';
export function Modes(context) {
var modes = [
iD.modes.AddPoint(context),
iD.modes.AddLine(context),
iD.modes.AddArea(context)];
AddPoint(context),
AddLine(context),
AddArea(context)];
function editable() {
return context.editable() && context.mode().id !== 'save';
@@ -17,7 +21,7 @@ export function Modes(context) {
.attr('class', function(mode) { return mode.id + ' add-button col4'; })
.on('click.mode-buttons', function(mode) {
if (mode.id === context.mode().id) {
context.enter(iD.modes.Browse(context));
context.enter(Browse(context));
} else {
context.enter(mode);
}
@@ -26,7 +30,7 @@ export function Modes(context) {
.placement('bottom')
.html(true)
.title(function(mode) {
return iD.ui.tooltipHtml(mode.description, mode.key);
return tooltipHtml(mode.description, mode.key);
}));
context.map()
@@ -37,7 +41,7 @@ export function Modes(context) {
buttons.each(function(d) {
d3.select(this)
.call(iD.svg.Icon('#icon-' + d.button, 'pre-text'));
.call(Icon('#icon-' + d.button, 'pre-text'));
});
buttons.append('span')
@@ -1,3 +1,4 @@
import { Icon } from '../svg/index';
export function Notice(context) {
return function(selection) {
var div = selection.append('div')
@@ -8,7 +9,7 @@ export function Notice(context) {
.on('click', function() { context.map().zoom(context.minEditableZoom()); });
button
.call(iD.svg.Icon('#icon-plus', 'pre-text'))
.call(Icon('#icon-plus', 'pre-text'))
.append('span')
.attr('class', 'label')
.text(t('zoom_in_edit'));
@@ -1,7 +1,13 @@
import { Icon } from '../svg/index';
import { TagReference } from './tag_reference';
import { Browse } from '../modes/index';
import { fields } from './fields/index';
import { Disclosure } from './disclosure';
export function preset(context) {
var event = d3.dispatch('change'),
state,
fields,
fieldsArr,
preset,
tags,
id;
@@ -9,7 +15,7 @@ export function preset(context) {
function UIField(field, entity, show) {
field = _.clone(field);
field.input = iD.ui.preset[field.type](field, context)
field.input = fields[field.type](field, context)
.on('change', event.change);
if (field.input.entity) field.input.entity(entity);
@@ -60,7 +66,7 @@ export function preset(context) {
}
function presets(selection) {
selection.call(iD.ui.Disclosure()
selection.call(Disclosure()
.title(t('inspector.all_fields'))
.expanded(context.storage('preset_fields.expanded') !== 'false')
.on('toggled', toggled)
@@ -72,31 +78,31 @@ export function preset(context) {
}
function content(selection) {
if (!fields) {
if (!fieldsArr) {
var entity = context.entity(id),
geometry = context.geometry(id);
fields = [UIField(context.presets().field('name'), entity)];
fieldsArr = [UIField(context.presets().field('name'), entity)];
preset.fields.forEach(function(field) {
if (field.matchGeometry(geometry)) {
fields.push(UIField(field, entity, true));
fieldsArr.push(UIField(field, entity, true));
}
});
if (entity.isHighwayIntersection(context.graph())) {
fields.push(UIField(context.presets().field('restrictions'), entity, true));
fieldsArr.push(UIField(context.presets().field('restrictions'), entity, true));
}
context.presets().universal().forEach(function(field) {
if (preset.fields.indexOf(field) < 0) {
fields.push(UIField(field, entity));
fieldsArr.push(UIField(field, entity));
}
});
}
var shown = fields.filter(function(field) { return field.shown(); }),
notShown = fields.filter(function(field) { return !field.shown(); });
var shown = fieldsArr.filter(function(field) { return field.shown(); }),
notShown = fieldsArr.filter(function(field) { return !field.shown(); });
var $form = selection.selectAll('.preset-form')
.data([0]);
@@ -126,12 +132,12 @@ export function preset(context) {
wrap.append('button')
.attr('class', 'remove-icon')
.attr('tabindex', -1)
.call(iD.svg.Icon('#operation-delete'));
.call(Icon('#operation-delete'));
wrap.append('button')
.attr('class', 'modified-icon')
.attr('tabindex', -1)
.call(iD.svg.Icon('#icon-undo'));
.call(Icon('#icon-undo'));
// Update
@@ -150,7 +156,7 @@ export function preset(context) {
return field.present();
})
.each(function(field) {
var reference = iD.ui.TagReference(field.reference || {key: field.key}, context);
var reference = TagReference(field.reference || {key: field.key}, context);
if (state === 'hover') {
reference.showing(false);
@@ -162,7 +168,7 @@ export function preset(context) {
.on('keydown', function() {
// if user presses enter, and combobox is not active, accept edits..
if (d3.event.keyCode === 13 && d3.select('.combobox').empty()) {
context.enter(iD.modes.Browse(context));
context.enter(Browse(context));
}
})
.call(reference.body)
@@ -240,7 +246,7 @@ export function preset(context) {
if (!arguments.length) return preset;
if (preset && preset.id === _.id) return presets;
preset = _;
fields = null;
fieldsArr = null;
return presets;
};
@@ -253,7 +259,7 @@ export function preset(context) {
presets.tags = function(_) {
if (!arguments.length) return tags;
tags = _;
// Don't reset fields here.
// Don't reset fieldsArr here.
return presets;
};
@@ -261,7 +267,7 @@ export function preset(context) {
if (!arguments.length) return id;
if (id === _) return presets;
id = _;
fields = null;
fieldsArr = null;
return presets;
};
-13
View File
@@ -1,13 +0,0 @@
export { access } from './access';
export { address } from './address';
export { check, defaultcheck} from './check';
export { combo, typeCombo, multiCombo } from './combo';
export { cycleway } from './cycleway';
export { text, url, number, email, tel } from './input';
export { localized } from './localized';
export { lanes } from './lanes';
export { maxspeed } from './maxspeed';
export { radio } from './radio';
export { restrictions } from './restrictions';
export { textarea } from './textarea';
export { wikipedia } from './wikipedia';
@@ -1,3 +1,4 @@
import { Icon } from '../svg/index';
export function PresetIcon() {
var preset, geometry;
@@ -39,7 +40,7 @@ export function PresetIcon() {
$frame.enter()
.append('div')
.call(iD.svg.Icon('#preset-icon-frame'));
.call(Icon('#preset-icon-frame'));
$frame.attr('class', function() {
return 'preset-icon-frame ' + (geom === 'area' ? '' : 'hide');
@@ -52,7 +53,7 @@ export function PresetIcon() {
$icon.enter()
.append('div')
.attr('class', 'preset-icon')
.call(iD.svg.Icon(''));
.call(Icon(''));
$icon
.attr('class', 'preset-icon preset-icon-' + (maki ? '32' : (geom === 'area' ? '44' : '60')));
@@ -1,3 +1,7 @@
import { Icon } from '../svg/index';
import { Browse } from '../modes/index';
import { ChangePreset } from '../actions/index';
import { Delete } from '../operations/index';
import { PresetIcon } from './preset_icon';
import { TagReference } from './tag_reference';
@@ -29,9 +33,9 @@ export function PresetList(context) {
messagewrap.append('button')
.attr('class', 'close')
.on('click', function() {
context.enter(iD.modes.Browse(context));
context.enter(Browse(context));
})
.call(iD.svg.Icon('#icon-close'));
.call(Icon('#icon-close'));
}
function keydown() {
@@ -41,7 +45,7 @@ export function PresetList(context) {
d3.event.keyCode === d3.keybinding.keyCodes['⌦'])) {
d3.event.preventDefault();
d3.event.stopPropagation();
iD.operations.Delete([id], context)();
Delete([id], context)();
} else if (search.property('value').length === 0 &&
(d3.event.ctrlKey || d3.event.metaKey) &&
d3.event.keyCode === d3.keybinding.keyCodes.z) {
@@ -89,7 +93,7 @@ export function PresetList(context) {
.on('input', inputevent);
searchWrap
.call(iD.svg.Icon('#icon-search', 'pre-text'));
.call(Icon('#icon-search', 'pre-text'));
if (autofocus) {
search.node().focus();
@@ -214,7 +218,7 @@ export function PresetList(context) {
context.presets().choose(preset);
context.perform(
iD.actions.ChangePreset(id, currentPreset, preset),
ChangePreset(id, currentPreset, preset),
t('operations.change_tags.annotation'));
event.choose(preset);
@@ -1,3 +1,6 @@
import { roundCoords } from '../geo/index';
import { tooltipHtml } from './tooltipHtml';
export function RadialMenu(context, operations) {
var menu,
center = [0, 0],
@@ -47,7 +50,7 @@ export function RadialMenu(context, operations) {
.attr('class', function(d) { return 'radial-menu-item radial-menu-item-' + d.id; })
.classed('disabled', function(d) { return d.disabled(); })
.attr('transform', function(d, i) {
return 'translate(' + iD.geo.roundCoords([
return 'translate(' + roundCoords([
r * Math.sin(a0 + i * a),
r * Math.cos(a0 + i * a)]).join(',') + ')';
});
@@ -87,7 +90,7 @@ export function RadialMenu(context, operations) {
.style('bottom', null)
.style('right', null)
.style('display', 'block')
.html(iD.ui.tooltipHtml(d.tooltip(), d.keys[0]));
.html(tooltipHtml(d.tooltip(), d.keys[0]));
if (i === 0) {
tooltip
@@ -1,3 +1,8 @@
import { Icon } from '../svg/index';
import { Entity } from '../core/index';
import { displayName } from '../util/index';
import { Select, Browse } from '../modes/index';
import { ChangeMember, DeleteMember } from '../actions/index';
import { Disclosure } from './disclosure';
export function RawMemberEditor(context) {
@@ -5,24 +10,24 @@ export function RawMemberEditor(context) {
function selectMember(d) {
d3.event.preventDefault();
context.enter(iD.modes.Select(context, [d.id]));
context.enter(Select(context, [d.id]));
}
function changeRole(d) {
var role = d3.select(this).property('value');
var member = {id: d.id, type: d.type, role: role};
context.perform(
iD.actions.ChangeMember(d.relation.id, member, d.index),
ChangeMember(d.relation.id, member, d.index),
t('operations.change_role.annotation'));
}
function deleteMember(d) {
context.perform(
iD.actions.DeleteMember(d.relation.id, d.index),
DeleteMember(d.relation.id, d.index),
t('operations.delete_member.annotation'));
if (!context.hasEntity(d.relation.id)) {
context.enter(iD.modes.Browse(context));
context.enter(Browse(context));
}
}
@@ -62,8 +67,8 @@ export function RawMemberEditor(context) {
var $items = $list.selectAll('li')
.data(memberships, function(d) {
return iD.Entity.key(d.relation) + ',' + d.index + ',' +
(d.member ? iD.Entity.key(d.member) : 'incomplete');
return Entity.key(d.relation) + ',' + d.index + ',' +
(d.member ? Entity.key(d.member) : 'incomplete');
});
var $enter = $items.enter().append('li')
@@ -84,7 +89,7 @@ export function RawMemberEditor(context) {
$label.append('span')
.attr('class', 'member-entity-name')
.text(function(d) { return iD.util.displayName(d.member); });
.text(function(d) { return displayName(d.member); });
} else {
d3.select(this).append('label')
@@ -105,7 +110,7 @@ export function RawMemberEditor(context) {
.attr('tabindex', -1)
.attr('class', 'remove button-input-action member-delete minor')
.on('click', deleteMember)
.call(iD.svg.Icon('#operation-delete'));
.call(Icon('#operation-delete'));
$items.exit()
.remove();
@@ -1,3 +1,8 @@
import { Icon } from '../svg/index';
import { Relation, Entity } from '../core/index';
import { displayName } from '../util/index';
import { Select } from '../modes/index';
import { ChangeMember, AddMember, AddEntity, DeleteMember } from '../actions/index';
import { Disclosure } from './disclosure';
export function RawMembershipEditor(context) {
@@ -5,13 +10,13 @@ export function RawMembershipEditor(context) {
function selectRelation(d) {
d3.event.preventDefault();
context.enter(iD.modes.Select(context, [d.relation.id]));
context.enter(Select(context, [d.relation.id]));
}
function changeRole(d) {
var role = d3.select(this).property('value');
context.perform(
iD.actions.ChangeMember(d.relation.id, _.extend({}, d.member, {role: role}), d.index),
ChangeMember(d.relation.id, _.extend({}, d.member, {role: role}), d.index),
t('operations.change_role.annotation'));
}
@@ -20,24 +25,24 @@ export function RawMembershipEditor(context) {
if (d.relation) {
context.perform(
iD.actions.AddMember(d.relation.id, {id: id, type: context.entity(id).type, role: role}),
AddMember(d.relation.id, {id: id, type: context.entity(id).type, role: role}),
t('operations.add_member.annotation'));
} else {
var relation = iD.Relation();
var relation = Relation();
context.perform(
iD.actions.AddEntity(relation),
iD.actions.AddMember(relation.id, {id: id, type: context.entity(id).type, role: role}),
AddEntity(relation),
AddMember(relation.id, {id: id, type: context.entity(id).type, role: role}),
t('operations.add.annotation.relation'));
context.enter(iD.modes.Select(context, [relation.id]));
context.enter(Select(context, [relation.id]));
}
}
function deleteMembership(d) {
context.perform(
iD.actions.DeleteMember(d.relation.id, d.index),
DeleteMember(d.relation.id, d.index),
t('operations.delete_member.annotation'));
}
@@ -54,7 +59,7 @@ export function RawMembershipEditor(context) {
return;
var presetName = context.presets().match(entity, graph).name(),
entityName = iD.util.displayName(entity) || '';
entityName = displayName(entity) || '';
var value = presetName + ' ' + entityName;
if (q && value.toLowerCase().indexOf(q.toLowerCase()) === -1)
@@ -67,7 +72,7 @@ export function RawMembershipEditor(context) {
});
result.sort(function(a, b) {
return iD.Relation.creationOrder(a.relation, b.relation);
return Relation.creationOrder(a.relation, b.relation);
});
// Dedupe identical names by appending relation id - see #2891
@@ -119,7 +124,7 @@ export function RawMembershipEditor(context) {
.attr('class', 'member-list');
var $items = $list.selectAll('li.member-row-normal')
.data(memberships, function(d) { return iD.Entity.key(d.relation) + ',' + d.index; });
.data(memberships, function(d) { return Entity.key(d.relation) + ',' + d.index; });
var $enter = $items.enter().append('li')
.attr('class', 'member-row member-row-normal form-field');
@@ -136,7 +141,7 @@ export function RawMembershipEditor(context) {
$label.append('span')
.attr('class', 'member-entity-name')
.text(function(d) { return iD.util.displayName(d.relation); });
.text(function(d) { return displayName(d.relation); });
$enter.append('input')
.attr('class', 'member-role')
@@ -150,7 +155,7 @@ export function RawMembershipEditor(context) {
.attr('tabindex', -1)
.attr('class', 'remove button-input-action member-delete minor')
.on('click', deleteMembership)
.call(iD.svg.Icon('#operation-delete'));
.call(Icon('#operation-delete'));
$items.exit()
.remove();
@@ -185,7 +190,7 @@ export function RawMembershipEditor(context) {
.attr('tabindex', -1)
.attr('class', 'remove button-input-action member-delete minor')
.on('click', deleteMembership)
.call(iD.svg.Icon('#operation-delete'));
.call(Icon('#operation-delete'));
} else {
$list.selectAll('.member-row-new')
@@ -198,7 +203,7 @@ export function RawMembershipEditor(context) {
$add.enter()
.append('button')
.attr('class', 'add-relation')
.call(iD.svg.Icon('#icon-plus', 'light'));
.call(Icon('#icon-plus', 'light'));
$wrap.selectAll('.add-relation')
.on('click', function() {
@@ -1,3 +1,4 @@
import { Icon } from '../svg/index';
import { Disclosure } from './disclosure';
import { TagReference } from './tag_reference';
@@ -46,7 +47,7 @@ export function RawTagEditor(context) {
$newTag.enter()
.append('button')
.attr('class', 'add-tag')
.call(iD.svg.Icon('#icon-plus', 'light'));
.call(Icon('#icon-plus', 'light'));
$newTag.on('click', addTag);
@@ -75,7 +76,7 @@ export function RawTagEditor(context) {
$enter.append('button')
.attr('tabindex', -1)
.attr('class', 'remove minor')
.call(iD.svg.Icon('#operation-delete'));
.call(Icon('#operation-delete'));
if (context.taginfo()) {
$enter.each(bindTypeahead);
@@ -1,16 +1,16 @@
import { modal as modalModule } from './modal';
import { modal } from './modal';
export function Restore(context) {
return function(selection) {
if (!context.history().lock() || !context.history().restorableChanges())
return;
var modal = modalModule(selection, true);
var modalSelection = modal(selection, true);
modal.select('.modal')
modalSelection.select('.modal')
.attr('class', 'modal fillL col6');
var introModal = modal.select('.content');
var introModal = modalSelection.select('.content');
introModal.attr('class','cf');
@@ -32,7 +32,7 @@ export function Restore(context) {
.text(t('restore.restore'))
.on('click', function() {
context.history().restore();
modal.remove();
modalSelection.remove();
});
buttonWrap.append('button')
@@ -40,7 +40,7 @@ export function Restore(context) {
.text(t('restore.reset'))
.on('click', function() {
context.history().clearSaved();
modal.remove();
modalSelection.remove();
});
restore.node().focus();
@@ -1,4 +1,6 @@
import { Save as SaveMode } from '../modes/index';
import { cmd } from './cmd';
import { tooltipHtml } from './tooltipHtml';
export function Save(context) {
var history = context.history(),
@@ -12,7 +14,7 @@ export function Save(context) {
function save() {
d3.event.preventDefault();
if (!context.inIntro() && !saving() && history.hasChanges()) {
context.enter(iD.modes.Save(context));
context.enter(SaveMode(context));
}
}
@@ -33,7 +35,7 @@ export function Save(context) {
var tooltip = bootstrap.tooltip()
.placement('bottom')
.html(true)
.title(iD.ui.tooltipHtml(t('save.no_changes'), key));
.title(tooltipHtml(t('save.no_changes'), key));
var button = selection.append('button')
.attr('class', 'save col12 disabled')
@@ -63,7 +65,7 @@ export function Save(context) {
return;
numChanges = _;
tooltip.title(iD.ui.tooltipHtml(t(numChanges > 0 ?
tooltip.title(tooltipHtml(t(numChanges > 0 ?
'save.help' : 'save.no_changes'), key));
var background = getBackground(numChanges);
@@ -1,3 +1,4 @@
import { lonToMeters, metersToLon } from '../geo/index';
export function Scale(context) {
var projection = context.projection,
imperial = (iD.detect().locale.toLowerCase() === 'en-us'),
@@ -7,7 +8,7 @@ export function Scale(context) {
function scaleDefs(loc1, loc2) {
var lat = (loc2[1] + loc1[1]) / 2,
conversion = (imperial ? 3.28084 : 1),
dist = iD.geo.lonToMeters(loc2[0] - loc1[0], lat) * conversion,
dist = lonToMeters(loc2[0] - loc1[0], lat) * conversion,
scale = { dist: 0, px: 0, text: '' },
buckets, i, val, dLon;
@@ -26,7 +27,7 @@ export function Scale(context) {
}
}
dLon = iD.geo.metersToLon(scale.dist / conversion, lat);
dLon = metersToLon(scale.dist / conversion, lat);
scale.px = Math.round(projection([loc1[0] + dLon, loc1[1]])[0]);
if (imperial) {
@@ -1,7 +1,11 @@
import { Icon } from '../svg/index';
import { Entity } from '../core/index';
import { displayName } from '../util/index';
import { Select } from '../modes/index';
export function SelectionList(context, selectedIDs) {
function selectEntity(entity) {
context.enter(iD.modes.Select(context, [entity.id]).suppressMenu(true));
context.enter(Select(context, [entity.id]).suppressMenu(true));
}
@@ -29,7 +33,7 @@ export function SelectionList(context, selectedIDs) {
.filter(function(entity) { return entity; });
var items = list.selectAll('.feature-list-item')
.data(entities, iD.Entity.key);
.data(entities, Entity.key);
var enter = items.enter().append('button')
.attr('class', 'feature-list-item')
@@ -38,7 +42,7 @@ export function SelectionList(context, selectedIDs) {
// Enter
var label = enter.append('div')
.attr('class', 'label')
.call(iD.svg.Icon('', 'pre-text'));
.call(Icon('', 'pre-text'));
label.append('span')
.attr('class', 'entity-type');
@@ -57,7 +61,7 @@ export function SelectionList(context, selectedIDs) {
.text(function(entity) { return context.presets().match(entity, context.graph()).name(); });
items.selectAll('.entity-name')
.text(function(entity) { return iD.util.displayName(entity); });
.text(function(entity) { return displayName(entity); });
// Exit
items.exit()
@@ -1,3 +1,4 @@
import { Browse } from '../modes/index';
export function SourceSwitch(context) {
var keys;
@@ -13,7 +14,7 @@ export function SourceSwitch(context) {
context.connection()
.switch(live ? keys[1] : keys[0]);
context.enter(iD.modes.Browse(context));
context.enter(Browse(context));
context.flush();
d3.select(this)
@@ -1,4 +1,4 @@
import { modal as modalModule } from './modal';
import { modal } from './modal';
import { intro } from './intro';
export function Splash(context) {
@@ -8,12 +8,12 @@ export function Splash(context) {
context.storage('sawSplash', true);
var modal = modalModule(selection);
var modalSelection = modal(selection);
modal.select('.modal')
modalSelection.select('.modal')
.attr('class', 'modal-splash modal col6');
var introModal = modal.select('.content')
var introModal = modalSelection.select('.content')
.append('div')
.attr('class', 'fillL');
@@ -37,15 +37,15 @@ export function Splash(context) {
.text(t('splash.walkthrough'))
.on('click', function() {
d3.select(document.body).call(intro(context));
modal.close();
modalSelection.close();
});
buttons.append('button')
.attr('class', 'col6 start')
.text(t('splash.start'))
.on('click', modal.close);
.on('click', modalSelection.close);
modal.select('button.close').attr('class','hide');
modalSelection.select('button.close').attr('class','hide');
};
}
@@ -1,3 +1,4 @@
import { Icon } from '../svg/index';
export function Success(context) {
var dispatch = d3.dispatch('cancel'),
changeset;
@@ -12,7 +13,7 @@ export function Success(context) {
header.append('button')
.attr('class', 'fr')
.on('click', function() { dispatch.cancel(); })
.call(iD.svg.Icon('#icon-close'));
.call(Icon('#icon-close'));
header.append('h3')
.text(t('success.just_edited'));
@@ -27,7 +28,7 @@ export function Success(context) {
.attr('class', 'details')
.attr('target', '_blank')
.attr('tabindex', -1)
.call(iD.svg.Icon('#icon-out-link', 'inline'))
.call(Icon('#icon-out-link', 'inline'))
.attr('href', t('success.help_link_url'))
.append('span')
.text(t('success.help_link_text'));
@@ -56,7 +57,7 @@ export function Success(context) {
.call(bootstrap.tooltip()
.title(function(d) { return t('success.' + d.key); })
.placement('bottom'))
.each(function(d) { d3.select(this).call(iD.svg.Icon('#logo-' + d.key, 'social')); });
.each(function(d) { d3.select(this).call(Icon('#logo-' + d.key, 'social')); });
}
success.changeset = function(_) {
@@ -1,3 +1,4 @@
import { Icon } from '../svg/index';
export function TagReference(tag, context) {
var tagReference = {},
button,
@@ -71,7 +72,7 @@ export function TagReference(tag, context) {
.attr('target', '_blank')
.attr('tabindex', -1)
.attr('href', 'https://wiki.openstreetmap.org/wiki/' + docs.title)
.call(iD.svg.Icon('#icon-out-link', 'inline'))
.call(Icon('#icon-out-link', 'inline'))
.append('span')
.text(t('inspector.reference'));
});
@@ -108,7 +109,7 @@ export function TagReference(tag, context) {
.append('button')
.attr('class', 'tag-reference-button')
.attr('tabindex', -1)
.call(iD.svg.Icon('#icon-inspect'));
.call(Icon('#icon-inspect'));
button.on('click', function () {
d3.event.stopPropagation();
+9
View File
@@ -0,0 +1,9 @@
export function tooltipHtml(text, key) {
var s = '<span>' + text + '</span>';
if (key) {
s += '<div class="keyhint-wrap">' +
'<span> ' + (t('tooltip_keyhint')) + ' </span>' +
'<span class="keyhint"> ' + key + '</span></div>';
}
return s;
}
@@ -1,4 +1,6 @@
import { Icon } from '../svg/index';
import { cmd } from './cmd';
import { tooltipHtml } from './tooltipHtml';
export function UndoRedo(context) {
var commands = [{
@@ -22,7 +24,7 @@ export function UndoRedo(context) {
.placement('bottom')
.html(true)
.title(function (d) {
return iD.ui.tooltipHtml(d.annotation() ?
return tooltipHtml(d.annotation() ?
t(d.id + '.tooltip', {action: d.annotation()}) :
t(d.id + '.nothing'), d.cmd);
});
@@ -36,7 +38,7 @@ export function UndoRedo(context) {
buttons.each(function(d) {
d3.select(this)
.call(iD.svg.Icon('#icon-' + d.id));
.call(Icon('#icon-' + d.id));
});
var keybinding = d3.keybinding('undo')
@@ -1,3 +1,4 @@
import { Icon } from '../svg/index';
export function ViewOnOSM(context) {
var id;
@@ -13,7 +14,7 @@ export function ViewOnOSM(context) {
.append('a')
.attr('class', 'view-on-osm')
.attr('target', '_blank')
.call(iD.svg.Icon('#icon-out-link', 'inline'))
.call(Icon('#icon-out-link', 'inline'))
.append('span')
.text(t('inspector.view_on_osm'));
@@ -1,4 +1,6 @@
import { Icon } from '../svg/index';
import { cmd } from './cmd';
import { tooltipHtml } from './tooltipHtml';
export function Zoom(context) {
var zooms = [{
@@ -47,12 +49,12 @@ export function Zoom(context) {
.placement('left')
.html(true)
.title(function(d) {
return iD.ui.tooltipHtml(d.title, d.key);
return tooltipHtml(d.title, d.key);
}));
button.each(function(d) {
d3.select(this)
.call(iD.svg.Icon('#icon-' + d.icon, 'light'));
.call(Icon('#icon-' + d.icon, 'light'));
});
var keybinding = d3.keybinding('zoom');
+3 -3
View File
@@ -8,9 +8,9 @@ function readFiles(dirname, outdir) {
processFile(fileData, outdir + filename);
});
}
var POSSIBLE_MODULES = [ 'actions', 'geo', 'modes', 'util', 'core', 'behavior' ];
var POSSIBLE_MODULES = [ 'actions', 'geo', 'modes', 'util', 'core', 'behavior', 'svg' ];
function findData(data) {
var modules = { 'actions': [], 'geo': [], 'modes': [], 'util': [], 'core': [], 'behavior': [] };
var modules = { 'actions': [], 'geo': [], 'modes': [], 'util': [], 'core': [], 'behavior': [], 'svg': [] };
var cores = [ 'Entity', 'Way', 'Relation', 'Node', 'Graph', 'Tree', 'Difference', 'History' ];
var ret = data.map(function(lineArg) {
var line = lineArg;
@@ -43,7 +43,7 @@ function findData(data) {
POSSIBLE_MODULES.forEach(function(mod) {
if (modules[mod].length > 0) {
var importStuff = modules[mod].join(', ');
ret.unshift(`import { ${importStuff} } from '../${mod}/index';`);
ret.unshift(`import { ${importStuff} } from '../../${mod}/index';`);
/*eslint-disable */
/*eslint-enable */
}
+3 -8
View File
@@ -44,11 +44,6 @@
<script src='../js/lib/id/svg.js'></script>
<script src='../js/lib/id/services.js'></script>
<script src='../js/lib/id/ui/index.js'></script>
<script src='../js/lib/id/ui/core.js'></script>
<script src='../js/lib/id/ui/preset.js'></script>
<script src='../js/lib/locale.js'></script>
<script src='../data/data_dev.js'></script>
@@ -128,9 +123,9 @@
<script src='spec/ui/confirm.js'></script>
<script src='spec/ui/cmd.js'></script>
<script src='spec/ui/preset/access.js'></script>
<script src='spec/ui/preset/localized.js'></script>
<script src='spec/ui/preset/wikipedia.js'></script>
<script src='spec/ui/fields/access.js'></script>
<script src='spec/ui/fields/localized.js'></script>
<script src='spec/ui/fields/wikipedia.js'></script>
<script src='spec/services/mapillary.js'></script>
<script src='spec/services/nominatim.js'></script>
@@ -1,13 +1,12 @@
describe('iD.ui.preset.access', function() {
describe('access', function() {
var selection, field;
beforeEach(function() {
selection = d3.select(document.createElement('div'));
field = iD().presets(iD.data.presets).presets().field('access');
});
it('creates inputs for a variety of modes of access', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
selection.call(access);
expect(selection.selectAll('.preset-access-access')[0].length).to.equal(1);
expect(selection.selectAll('.preset-access-foot')[0].length).to.equal(1);
@@ -17,20 +16,20 @@ describe('iD.ui.preset.access', function() {
});
it('does not include "yes", "designated", "dismount" options for general access (#934), (#2213)', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
expect(_.map(access.options('access'), 'value')).not.to.include('yes');
expect(_.map(access.options('access'), 'value')).not.to.include('designated');
expect(_.map(access.options('access'), 'value')).not.to.include('dismount');
});
it('does include a "dismount" option for bicycles (#2726)', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
expect(_.map(access.options('bicycle'), 'value')).to.include('dismount');
expect(_.map(access.options('foot'), 'value')).not.to.include('dismount');
});
it('sets foot placeholder to "yes" for steps and pedestrian', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
selection.call(access);
access.tags({highway: 'steps'});
@@ -41,7 +40,7 @@ describe('iD.ui.preset.access', function() {
});
it('sets foot placeholder to "designated" for footways', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
selection.call(access);
access.tags({highway: 'footway'});
@@ -49,7 +48,7 @@ describe('iD.ui.preset.access', function() {
});
it('sets bicycle placeholder to "designated" for cycleways', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
selection.call(access);
access.tags({highway: 'cycleway'});
@@ -57,7 +56,7 @@ describe('iD.ui.preset.access', function() {
});
it('sets horse placeholder to "designated" for bridleways', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
selection.call(access);
access.tags({highway: 'bridleway'});
@@ -65,7 +64,7 @@ describe('iD.ui.preset.access', function() {
});
it('sets motor_vehicle placeholder to "no" for footways, steps, pedestrian, cycleway, bridleway, and path', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
selection.call(access);
['footway', 'steps', 'pedestrian', 'cycleway', 'bridleway', 'path'].forEach(function(value) {
access.tags({highway: value});
@@ -74,7 +73,7 @@ describe('iD.ui.preset.access', function() {
});
it('sets motor_vehicle placeholder to "yes" for various other highway tags', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
selection.call(access);
['residential', 'motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'service',
'unclassified', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link'].forEach(function(value) {
@@ -84,7 +83,7 @@ describe('iD.ui.preset.access', function() {
});
it('overrides a "yes" or "designated" placeholder with more specific access tag (#2213)', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
selection.call(access);
access.tags({highway: 'service', access: 'emergency'});
@@ -95,7 +94,7 @@ describe('iD.ui.preset.access', function() {
});
it('overrides a "no" placeholder with more specific access tag (#2763)', function() {
var access = iD.ui.preset.access(field);
var access = iD.ui.fields.access(field);
selection.call(access);
access.tags({highway: 'cycleway', access: 'destination'});
@@ -1,4 +1,4 @@
describe('iD.ui.preset.localized', function() {
describe('localized', function() {
var selection, field;
beforeEach(function() {
@@ -7,7 +7,7 @@ describe('iD.ui.preset.localized', function() {
});
it('adds a blank set of fields when the + button is clicked', function() {
var localized = iD.ui.preset.localized(field, {});
var localized = iD.ui.fields.localized(field, {});
selection.call(localized);
happen.click(selection.selectAll('.localized-add').node());
expect(selection.selectAll('.localized-lang').size()).to.equal(1);
@@ -15,7 +15,7 @@ describe('iD.ui.preset.localized', function() {
});
it('doesn\'t create a tag when the value is empty', function() {
var localized = iD.ui.preset.localized(field, {});
var localized = iD.ui.fields.localized(field, {});
selection.call(localized);
happen.click(selection.selectAll('.localized-add').node());
@@ -29,7 +29,7 @@ describe('iD.ui.preset.localized', function() {
});
it('doesn\'t create a tag when the name is empty', function() {
var localized = iD.ui.preset.localized(field, {});
var localized = iD.ui.fields.localized(field, {});
selection.call(localized);
happen.click(selection.selectAll('.localized-add').node());
@@ -43,7 +43,7 @@ describe('iD.ui.preset.localized', function() {
});
it('creates a tag after setting language then value', function() {
var localized = iD.ui.preset.localized(field, {});
var localized = iD.ui.fields.localized(field, {});
selection.call(localized);
happen.click(selection.selectAll('.localized-add').node());
@@ -59,7 +59,7 @@ describe('iD.ui.preset.localized', function() {
});
it('creates a tag after setting value then language', function() {
var localized = iD.ui.preset.localized(field, {});
var localized = iD.ui.fields.localized(field, {});
selection.call(localized);
happen.click(selection.selectAll('.localized-add').node());
@@ -75,7 +75,7 @@ describe('iD.ui.preset.localized', function() {
});
it('changes an existing language', function() {
var localized = iD.ui.preset.localized(field, {});
var localized = iD.ui.fields.localized(field, {});
selection.call(localized);
localized.tags({'name:de': 'Value'});
@@ -90,7 +90,7 @@ describe('iD.ui.preset.localized', function() {
});
it('ignores similar keys like `old_name`', function() {
var localized = iD.ui.preset.localized(field, {});
var localized = iD.ui.fields.localized(field, {});
selection.call(localized);
localized.tags({'old_name:de': 'Value'});
@@ -99,7 +99,7 @@ describe('iD.ui.preset.localized', function() {
});
it('removes the tag when the language is emptied', function() {
var localized = iD.ui.preset.localized(field, {});
var localized = iD.ui.fields.localized(field, {});
selection.call(localized);
localized.tags({'name:de': 'Value'});
@@ -112,7 +112,7 @@ describe('iD.ui.preset.localized', function() {
});
it('removes the tag when the value is emptied', function() {
var localized = iD.ui.preset.localized(field, {});
var localized = iD.ui.fields.localized(field, {});
selection.call(localized);
localized.tags({'name:de': 'Value'});
@@ -1,4 +1,4 @@
describe('iD.ui.preset.wikipedia', function() {
describe('wikipedia', function() {
var entity, context, selection, field, wikiDelay, selectedId;
function wikidataStub() {
@@ -38,9 +38,8 @@ describe('iD.ui.preset.wikipedia', function() {
context.selectedIDs.restore();
});
it('recognizes lang:title format', function() {
var wikipedia = iD.ui.preset.wikipedia(field, context);
var wikipedia = iD.ui.fields.wikipedia(field, context);
selection.call(wikipedia);
wikipedia.tags({wikipedia: 'en:Title'});
expect(selection.selectAll('.wiki-lang').value()).to.equal('English');
@@ -49,7 +48,7 @@ describe('iD.ui.preset.wikipedia', function() {
});
it('sets language, value, wikidata', function() {
var wikipedia = iD.ui.preset.wikipedia(field, context).entity(entity);
var wikipedia = iD.ui.fields.wikipedia(field, context).entity(entity);
wikipedia.on('change', changeTags);
selection.call(wikipedia);
@@ -74,7 +73,7 @@ describe('iD.ui.preset.wikipedia', function() {
});
it('recognizes pasted URLs', function() {
var wikipedia = iD.ui.preset.wikipedia(field, context).entity(entity);
var wikipedia = iD.ui.fields.wikipedia(field, context).entity(entity);
wikipedia.on('change', changeTags);
selection.call(wikipedia);
@@ -85,10 +84,10 @@ describe('iD.ui.preset.wikipedia', function() {
});
it('preserves existing language', function() {
selection.call(iD.ui.preset.wikipedia(field, context));
selection.call(iD.ui.fields.wikipedia(field, context));
selection.selectAll('.wiki-lang').value('Deutsch');
var wikipedia = iD.ui.preset.wikipedia(field, context);
var wikipedia = iD.ui.fields.wikipedia(field, context);
selection.call(wikipedia);
wikipedia.tags({});
@@ -96,7 +95,7 @@ describe('iD.ui.preset.wikipedia', function() {
});
it('does not set delayed wikidata tag if wikipedia field has changed', function(done) {
var wikipedia = iD.ui.preset.wikipedia(field, context).entity(entity);
var wikipedia = iD.ui.fields.wikipedia(field, context).entity(entity);
wikipedia.on('change', changeTags);
selection.call(wikipedia);
wikiDelay = 20;
@@ -127,7 +126,7 @@ describe('iD.ui.preset.wikipedia', function() {
});
it('does not set delayed wikidata tag if selected entity has changed', function(done) {
var wikipedia = iD.ui.preset.wikipedia(field, context).entity(entity);
var wikipedia = iD.ui.fields.wikipedia(field, context).entity(entity);
wikipedia.on('change', changeTags);
selection.call(wikipedia);
wikiDelay = 20;