Improve preset form display

This commit is contained in:
Tom MacWright
2013-01-31 13:07:21 -05:00
parent 4e7ed7250b
commit e6e0306953
4 changed files with 386 additions and 358 deletions

View File

@@ -1267,3 +1267,8 @@ a.success-action {
.icon.icon-pre-text { margin-right: 0px;}
.save .label, .apply .label { display: block;}
}
.preset-section.cf,
.preset-section-input.cf {
width: 100%;
}

View File

@@ -26,7 +26,7 @@ iD.ui.inspector = function() {
if (possiblePresets.length) {
var inspectorpreset = inspectorwrap.append('div')
.attr('class', 'inspector-preset')
.attr('class', 'inspector-preset cf')
.call(iD.ui.preset()
.preset(possiblePresets[0]));
}
@@ -46,7 +46,7 @@ iD.ui.inspector = function() {
});
newTag.append('span').attr('class', 'icon icon-pre-text plus');
newTag.append('span').attr('class','label').text('New tag')
newTag.append('span').attr('class','label').text('New tag');
drawTags(entity.tags);

View File

@@ -3,8 +3,15 @@ iD.ui.preset = function() {
// generate form fields for a given field.
function input(d) {
switch (d.type) {
case 'text':
this.append('input')
.attr('type', 'text')
.attr('placeholder', d['default'] || '');
break;
case 'tel':
this.append('input')
.attr('type', 'tel')
@@ -23,9 +30,19 @@ iD.ui.preset = function() {
.attr('placeholder', 'http://example.com/');
break;
case 'check':
this.append('input')
.attr('type', 'checkbox')
.each(function() {
if (d['default']) {
this.attr('checked', 'checked');
}
});
break;
case 'select':
var select = this.append('select');
var options = d.option.slice();
var options = d.values.slice();
options.unshift('');
select.selectAll('option')
.data(options)
@@ -41,15 +58,21 @@ iD.ui.preset = function() {
.data(preset.main)
.enter()
.append('div')
.attr('class', 'preset-section');
.attr('class', 'preset-section cf');
sections.each(function(d) {
var s = d3.select(this);
s.append('h4')
.text(d.title || d.tag);
var wrap = s.append('div')
.attr('class', 'preset-section-input cf');
input.call(s, d);
wrap
.append('div')
.attr('class', 'col6')
.text(d.text);
input.call(wrap.append('div')
.attr('class', 'col6'), d);
});
}

File diff suppressed because it is too large Load Diff