mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 05:49:16 +02:00
Put presetData in context
This commit is contained in:
+7
-5
@@ -187,12 +187,14 @@
|
||||
var id = iD();
|
||||
|
||||
iD.util.asyncMap(['keys.json', 'presets/presets.json'], d3.json, function(err, data) {
|
||||
id.connection()
|
||||
.keys(data[0])
|
||||
.presetData(iD.presetData().data(data[1]));
|
||||
id.connection()
|
||||
.keys(data[0]);
|
||||
|
||||
d3.select("#iD")
|
||||
.call(id.ui())
|
||||
id.presetData()
|
||||
.data(data[1]);
|
||||
|
||||
d3.select("#iD")
|
||||
.call(id.ui());
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ iD.Connection = function(context) {
|
||||
url = 'http://api06.dev.openstreetmap.org',
|
||||
connection = {},
|
||||
user = {},
|
||||
version,
|
||||
presetData = iD.presetData(),
|
||||
keys,
|
||||
inflight = {},
|
||||
loadedTiles = {},
|
||||
@@ -329,12 +327,6 @@ iD.Connection = function(context) {
|
||||
return connection;
|
||||
};
|
||||
|
||||
connection.presetData = function(_) {
|
||||
if (!arguments.length) return presetData;
|
||||
presetData = _;
|
||||
return connection;
|
||||
};
|
||||
|
||||
connection.authenticate = function(callback) {
|
||||
function done(err, res) {
|
||||
event.auth();
|
||||
|
||||
@@ -95,6 +95,13 @@ window.iD = function () {
|
||||
context.zoomIn = map.zoomIn;
|
||||
context.zoomOut = map.zoomOut;
|
||||
|
||||
/* Presets */
|
||||
var presetData = iD.presetData();
|
||||
|
||||
context.presetData = function() {
|
||||
return presetData;
|
||||
};
|
||||
|
||||
context.container = function(_) {
|
||||
if (!arguments.length) return container;
|
||||
container = _;
|
||||
|
||||
@@ -83,9 +83,6 @@ iD.modes.Select = function(context, selection, initial) {
|
||||
}), true));
|
||||
|
||||
if (entity) {
|
||||
inspector
|
||||
.presetData(context.connection().presetData());
|
||||
|
||||
context.container()
|
||||
.select('.inspector-wrap')
|
||||
.style('display', 'block')
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
iD.ui.Inspector = function(context) {
|
||||
var event = d3.dispatch('changeTags', 'close', 'change'),
|
||||
presetData = iD.presetData(),
|
||||
initial = false,
|
||||
inspectorbody,
|
||||
entity,
|
||||
@@ -19,7 +18,6 @@ iD.ui.Inspector = function(context) {
|
||||
.attr('class', 'fillL'),
|
||||
|
||||
presetGrid = iD.ui.PresetGrid(context)
|
||||
.presetData(presetData)
|
||||
.entity(entity)
|
||||
.on('message', changeMessage)
|
||||
.on('choose', function(preset) {
|
||||
@@ -27,7 +25,6 @@ iD.ui.Inspector = function(context) {
|
||||
});
|
||||
|
||||
tagEditor = iD.ui.TagEditor(context)
|
||||
.presetData(presetData)
|
||||
.tags(entity.tags)
|
||||
.on('message', changeMessage)
|
||||
.on('changeTags', function() {
|
||||
@@ -66,10 +63,5 @@ iD.ui.Inspector = function(context) {
|
||||
return inspector;
|
||||
};
|
||||
|
||||
inspector.presetData = function(_) {
|
||||
presetData = _;
|
||||
return inspector;
|
||||
};
|
||||
|
||||
return d3.rebind(inspector, event, 'on');
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
iD.ui.PresetGrid = function(context) {
|
||||
var event = d3.dispatch('choose', 'message'),
|
||||
entity,
|
||||
presetData,
|
||||
presetData = context.presetData(),
|
||||
taginfo = iD.taginfo();
|
||||
|
||||
function presetgrid(selection, preset) {
|
||||
@@ -184,12 +184,6 @@ iD.ui.PresetGrid = function(context) {
|
||||
.text(t('commit.cancel'));
|
||||
}
|
||||
|
||||
presetgrid.presetData = function(_) {
|
||||
if (!arguments.length) return presetData;
|
||||
presetData = _;
|
||||
return presetgrid;
|
||||
};
|
||||
|
||||
presetgrid.entity = function(_) {
|
||||
if (!arguments.length) return entity;
|
||||
entity = _;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
iD.ui.TagEditor = function(context) {
|
||||
var event = d3.dispatch('changeTags', 'choose', 'close', 'message'),
|
||||
presetData = iD.presetData(),
|
||||
presetData = context.presetData(),
|
||||
entity,
|
||||
tags,
|
||||
name,
|
||||
@@ -167,10 +167,5 @@ iD.ui.TagEditor = function(context) {
|
||||
}
|
||||
};
|
||||
|
||||
tageditor.presetData = function(_) {
|
||||
presetData = _;
|
||||
return tageditor;
|
||||
};
|
||||
|
||||
return d3.rebind(tageditor, event, 'on');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user