Put presetData in context

This commit is contained in:
John Firebaugh
2013-02-28 16:05:04 -08:00
parent 65cfb6b69b
commit c02531fe21
7 changed files with 16 additions and 37 deletions
+7 -5
View File
@@ -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>
-8
View File
@@ -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();
+7
View File
@@ -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 = _;
-3
View File
@@ -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')
-8
View File
@@ -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
View File
@@ -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
View File
@@ -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');
};