Pass context directly

This commit is contained in:
John Firebaugh
2013-02-26 17:21:25 -08:00
parent 2b7cba145e
commit 89ee4244ff
8 changed files with 16 additions and 63 deletions

View File

@@ -4,7 +4,7 @@ iD.modes.Select = function(context, selection, initial) {
button: 'browse'
};
var inspector = iD.ui.Inspector().initial(!!initial),
var inspector = iD.ui.Inspector(context).initial(!!initial),
keybinding = d3.keybinding('select'),
timeout = null,
behaviors = [
@@ -84,7 +84,6 @@ iD.modes.Select = function(context, selection, initial) {
if (entity) {
inspector
.context(context)
.presetData(context.connection().presetData());
context.container()

View File

@@ -1,12 +1,11 @@
iD.ui.Inspector = function() {
iD.ui.Inspector = function(context) {
var event = d3.dispatch('changeTags', 'close', 'change'),
presetData = iD.presetData(),
initial = false,
inspectorbody,
entity,
presetGrid,
tagEditor,
context;
tagEditor;
function inspector(selection) {
@@ -19,19 +18,17 @@ iD.ui.Inspector = function() {
inspectorbody = selection.append('div')
.attr('class', 'fillL'),
presetGrid = iD.ui.PresetGrid()
presetGrid = iD.ui.PresetGrid(context)
.presetData(presetData)
.entity(entity)
.context(context)
.on('message', changeMessage)
.on('choose', function(preset) {
inspectorbody.call(tagEditor, preset);
});
tagEditor = iD.ui.TagEditor()
tagEditor = iD.ui.TagEditor(context)
.presetData(presetData)
.tags(entity.tags)
.context(context)
.on('message', changeMessage)
.on('changeTags', function() {
event.changeTags(entity, inspector.tags());
@@ -74,10 +71,5 @@ iD.ui.Inspector = function() {
return inspector;
};
inspector.context = function(_) {
context = _;
return inspector;
};
return d3.rebind(inspector, event, 'on');
};

View File

@@ -1,7 +1,6 @@
iD.ui.preset = function() {
iD.ui.preset = function(context) {
var event = d3.dispatch('change', 'setTags'),
taginfo = iD.taginfo(),
context,
entity,
type,
hidden,
@@ -151,8 +150,7 @@ iD.ui.preset = function() {
if (d.type === 'address') {
wrap.append('div')
.attr('class', 'col9 preset-input', d)
.call(iD.ui.preset.address()
.context(context)
.call(iD.ui.preset.address(context)
.on('change', key)
.entity(entity));
}
@@ -178,12 +176,6 @@ iD.ui.preset = function() {
return clean(getTags());
};
presets.context = function(_) {
if (!arguments.length) return context;
context = _;
return presets;
};
presets.entity = function(_) {
if (!arguments.length) return entity;
entity = _;

View File

@@ -1,7 +1,6 @@
iD.ui.preset.address = function() {
iD.ui.preset.address = function(context) {
var event = d3.dispatch('change'),
context,
entity;
function getStreets() {
@@ -74,11 +73,5 @@ iD.ui.preset.address = function() {
return address;
};
address.context = function(_) {
if (!arguments.length) return context;
context = _;
return address;
};
return d3.rebind(address, event, 'on');
};

View File

@@ -1,7 +1,6 @@
iD.ui.PresetGrid = function() {
iD.ui.PresetGrid = function(context) {
var event = d3.dispatch('choose', 'message'),
entity,
context,
presetData;
function presetgrid(selection, preset) {
@@ -171,19 +170,11 @@ iD.ui.PresetGrid = function() {
return presetgrid;
};
presetgrid.context = function(_) {
if (!arguments.length) return context;
context = _;
return presetgrid;
};
presetgrid.entity = function(_) {
if (!arguments.length) return entity;
entity = _;
return presetgrid;
};
return d3.rebind(presetgrid, event, 'on');
};

View File

@@ -1,4 +1,4 @@
iD.ui.TagEditor = function() {
iD.ui.TagEditor = function(context) {
var event = d3.dispatch('changeTags', 'choose', 'close', 'message'),
presetData = iD.presetData(),
entity,
@@ -7,8 +7,7 @@ iD.ui.TagEditor = function() {
presetMatch,
selection_,
presetUI,
tagList,
context;
tagList;
function tageditor(selection, preset) {
@@ -88,15 +87,13 @@ iD.ui.TagEditor = function() {
event.changeTags();
});
presetUI = iD.ui.preset()
.context(context)
presetUI = iD.ui.preset(context)
.entity(entity)
.on('change', function(tags) {
event.changeTags();
});
tagList = iD.ui.Taglist()
.context(context)
tagList = iD.ui.Taglist(context)
.on('change', function(tags) {
event.changeTags();
});
@@ -175,10 +172,5 @@ iD.ui.TagEditor = function() {
return tageditor;
};
tageditor.context = function(_) {
context = _;
return tageditor;
};
return d3.rebind(tageditor, event, 'on');
};

View File

@@ -1,10 +1,9 @@
iD.ui.Taglist = function() {
iD.ui.Taglist = function(context) {
var event = d3.dispatch('change'),
taginfo = iD.taginfo(),
initial = false,
collapsebutton,
list,
context;
list;
function taglist(selection, expanded) {
@@ -271,10 +270,5 @@ iD.ui.Taglist = function() {
}
};
taglist.context = function(_) {
context = _;
return taglist;
};
return d3.rebind(taglist, event, 'on');
};

View File

@@ -4,7 +4,7 @@ describe("iD.ui.Inspector", function () {
entity, graph, context;
function render() {
inspector = iD.ui.Inspector().context(context);
inspector = iD.ui.Inspector(context);
element = d3.select('body')
.append('div')
.attr('id', 'inspector-wrap')