mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-21 15:56:56 +02:00
32 lines
790 B
JavaScript
32 lines
790 B
JavaScript
iD.ui.preset.textarea = function(field) {
|
|
|
|
var event = d3.dispatch('change', 'close'),
|
|
input;
|
|
|
|
function i(selection) {
|
|
input = selection.append('textarea')
|
|
.attr('id', 'preset-input-' + field.id)
|
|
.attr('placeholder', field.placeholder || '')
|
|
.attr('maxlength', 255)
|
|
.on('blur', change)
|
|
.on('change', change)
|
|
.call(iD.behavior.accept().on('accept', event.close));
|
|
}
|
|
|
|
function change() {
|
|
var t = {};
|
|
t[field.key] = input.property('value');
|
|
event.change(t);
|
|
}
|
|
|
|
i.tags = function(tags) {
|
|
input.property('value', tags[field.key] || '');
|
|
};
|
|
|
|
i.focus = function() {
|
|
input.node().focus();
|
|
};
|
|
|
|
return d3.rebind(i, event, 'on');
|
|
};
|