mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
add defaultcheck input type
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"key": "bridge",
|
||||
"type": "check"
|
||||
}
|
||||
"type": "defaultcheck"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"key": "tunnel",
|
||||
"type": "check"
|
||||
}
|
||||
"type": "defaultcheck"
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
iD.ui.preset = function(context) {
|
||||
var event = d3.dispatch('change', 'setTags', 'close'),
|
||||
entity,
|
||||
type,
|
||||
hidden,
|
||||
sections,
|
||||
tags,
|
||||
keys,
|
||||
preset;
|
||||
|
||||
// generate form fields for a given field.
|
||||
function input(d) {
|
||||
var i = iD.ui.preset[d.type](d, context)
|
||||
.on('close', event.close)
|
||||
@@ -30,7 +26,7 @@ iD.ui.preset = function(context) {
|
||||
selection.html('');
|
||||
keys = [];
|
||||
|
||||
sections = selection.selectAll('div.preset-section')
|
||||
var sections = selection.selectAll('div.preset-section')
|
||||
.data(preset.form)
|
||||
.enter()
|
||||
.append('div')
|
||||
@@ -72,7 +68,6 @@ iD.ui.preset = function(context) {
|
||||
presets.entity = function(_) {
|
||||
if (!arguments.length) return entity;
|
||||
entity = _;
|
||||
type = entity.type === 'node' ? entity.type : entity.geometry();
|
||||
return presets;
|
||||
};
|
||||
|
||||
|
||||
23
js/id/ui/preset/defaultcheck.js
Normal file
23
js/id/ui/preset/defaultcheck.js
Normal file
@@ -0,0 +1,23 @@
|
||||
iD.ui.preset.defaultcheck = function(form) {
|
||||
|
||||
var event = d3.dispatch('change', 'close'),
|
||||
input;
|
||||
|
||||
var check = function(selection) {
|
||||
|
||||
input = selection.append('input')
|
||||
.attr('type', 'checkbox')
|
||||
.attr('id', 'input-' + form.key)
|
||||
.on('change', function() {
|
||||
var t = {};
|
||||
t[form.key] = input.property('checked') ? form.value || 'yes' : undefined;
|
||||
event.change(t);
|
||||
});
|
||||
};
|
||||
|
||||
check.tags = function(tags) {
|
||||
input.property('checked', !!tags[form.key] && tags[form.key] !== 'no');
|
||||
};
|
||||
|
||||
return d3.rebind(check, event, 'on');
|
||||
};
|
||||
Reference in New Issue
Block a user