mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 09:42:56 +00:00
Fix issue 1594: replace keyup event with keypress event and input event
This commit is contained in:
committed by
John Firebaugh
parent
5ee24ec623
commit
0d4e8fa32e
@@ -6,22 +6,25 @@ iD.ui.FeatureList = function(context) {
|
||||
header.append('h3')
|
||||
.text(t('inspector.feature_list'));
|
||||
|
||||
function keyup() {
|
||||
function keypress() {
|
||||
var q = search.property('value');
|
||||
if (d3.event.keyCode === 13 && q.length) {
|
||||
click(list.selectAll('.feature-list-item:first-child').datum());
|
||||
} else {
|
||||
drawList();
|
||||
}
|
||||
}
|
||||
|
||||
function inputevent() {
|
||||
drawList();
|
||||
}
|
||||
|
||||
var searchWrap = selection.append('div')
|
||||
.attr('class', 'search-header');
|
||||
|
||||
var search = searchWrap.append('input')
|
||||
.attr('placeholder', t('inspector.search'))
|
||||
.attr('type', 'search')
|
||||
.on('keyup', keyup);
|
||||
.on('keypress', keypress)
|
||||
.on('input', inputevent);
|
||||
|
||||
searchWrap.append('span')
|
||||
.attr('class', 'icon search');
|
||||
|
||||
@@ -51,23 +51,26 @@ iD.ui.PresetList = function(context) {
|
||||
}
|
||||
}
|
||||
|
||||
function keyup() {
|
||||
function keypress() {
|
||||
// enter
|
||||
var value = search.property('value');
|
||||
if (d3.event.keyCode === 13 && value.length) {
|
||||
list.selectAll('.preset-list-item:first-child').datum().choose();
|
||||
}
|
||||
}
|
||||
|
||||
function inputevent() {
|
||||
var value = search.property('value');
|
||||
list.classed('filtered', value.length);
|
||||
if (value.length) {
|
||||
var results = presets.search(value, geometry);
|
||||
message.text(t('inspector.results', {
|
||||
n: results.collection.length,
|
||||
search: value
|
||||
}));
|
||||
list.call(drawList, results);
|
||||
} else {
|
||||
list.classed('filtered', value.length);
|
||||
if (value.length) {
|
||||
var results = presets.search(value, geometry);
|
||||
message.text(t('inspector.results', {
|
||||
n: results.collection.length,
|
||||
search: value
|
||||
}));
|
||||
list.call(drawList, results);
|
||||
} else {
|
||||
list.call(drawList, context.presets().defaults(geometry, 36));
|
||||
}
|
||||
list.call(drawList, context.presets().defaults(geometry, 36));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +82,8 @@ iD.ui.PresetList = function(context) {
|
||||
.attr('placeholder', t('inspector.search'))
|
||||
.attr('type', 'search')
|
||||
.on('keydown', keydown)
|
||||
.on('keyup', keyup);
|
||||
.on('keypress', keypress)
|
||||
.on('input', inputevent);
|
||||
|
||||
searchWrap.append('span')
|
||||
.attr('class', 'icon search');
|
||||
|
||||
Reference in New Issue
Block a user