mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-18 14:45:12 +02:00
Fix sidebar UI behaviors
* Restore preset search autofocus (fixes #1566) * Should show hover in draw modes, not preset list
This commit is contained in:
@@ -2,7 +2,9 @@ iD.behavior.Draw = function(context) {
|
||||
var event = d3.dispatch('move', 'click', 'clickWay',
|
||||
'clickNode', 'undo', 'cancel', 'finish'),
|
||||
keybinding = d3.keybinding('draw'),
|
||||
hover = iD.behavior.Hover(context).altDisables(true),
|
||||
hover = iD.behavior.Hover(context)
|
||||
.altDisables(true)
|
||||
.on('hover', context.ui().sidebar.hover),
|
||||
tail = iD.behavior.Tail(),
|
||||
closeTolerance = 4,
|
||||
tolerance = 12;
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
have the .hover class.
|
||||
*/
|
||||
iD.behavior.Hover = function(context) {
|
||||
var selection,
|
||||
var dispatch = d3.dispatch('hover'),
|
||||
selection,
|
||||
altDisables,
|
||||
target;
|
||||
|
||||
function keydown() {
|
||||
if (altDisables && d3.event.keyCode === d3.keybinding.modifierCodes.alt) {
|
||||
context.hover(null);
|
||||
dispatch.hover(null);
|
||||
selection.selectAll('.hover')
|
||||
.classed('hover-suppressed', true)
|
||||
.classed('hover', false);
|
||||
@@ -23,7 +24,7 @@ iD.behavior.Hover = function(context) {
|
||||
|
||||
function keyup() {
|
||||
if (altDisables && d3.event.keyCode === d3.keybinding.modifierCodes.alt) {
|
||||
context.hover(target);
|
||||
dispatch.hover(target ? target.id : null);
|
||||
selection.selectAll('.hover-suppressed')
|
||||
.classed('hover-suppressed', false)
|
||||
.classed('hover', true);
|
||||
@@ -50,12 +51,12 @@ iD.behavior.Hover = function(context) {
|
||||
selection.selectAll(selector)
|
||||
.classed(suppressed ? 'hover-suppressed' : 'hover', true);
|
||||
|
||||
context.hover(target);
|
||||
dispatch.hover(target.id);
|
||||
}
|
||||
}
|
||||
|
||||
function mouseout() {
|
||||
context.hover(null);
|
||||
dispatch.hover(null);
|
||||
target = null;
|
||||
|
||||
selection.selectAll('.hover')
|
||||
@@ -94,5 +95,5 @@ iD.behavior.Hover = function(context) {
|
||||
return hover;
|
||||
};
|
||||
|
||||
return hover;
|
||||
return d3.rebind(hover, dispatch, 'on');
|
||||
};
|
||||
|
||||
+1
-3
@@ -17,7 +17,7 @@ window.iD = function () {
|
||||
};
|
||||
|
||||
var history = iD.History(context),
|
||||
dispatch = d3.dispatch('enter', 'exit', 'hover', 'select', 'toggleFullscreen'),
|
||||
dispatch = d3.dispatch('enter', 'exit', 'select', 'toggleFullscreen'),
|
||||
mode,
|
||||
container,
|
||||
ui = iD.ui(context),
|
||||
@@ -127,8 +127,6 @@ window.iD = function () {
|
||||
}
|
||||
};
|
||||
|
||||
context.hover = dispatch.hover;
|
||||
|
||||
/* Behaviors */
|
||||
context.install = function(behavior) {
|
||||
context.surface().call(behavior);
|
||||
|
||||
@@ -8,7 +8,8 @@ iD.modes.Browse = function(context) {
|
||||
};
|
||||
|
||||
var behaviors = [
|
||||
iD.behavior.Hover(context),
|
||||
iD.behavior.Hover(context)
|
||||
.on('hover', context.ui().sidebar.hover),
|
||||
iD.behavior.Select(context),
|
||||
iD.behavior.Lasso(context),
|
||||
iD.modes.DragNode(context).behavior];
|
||||
@@ -17,6 +18,8 @@ iD.modes.Browse = function(context) {
|
||||
behaviors.forEach(function(behavior) {
|
||||
context.install(behavior);
|
||||
});
|
||||
|
||||
context.ui().sidebar.select(null);
|
||||
};
|
||||
|
||||
mode.exit = function() {
|
||||
|
||||
@@ -9,7 +9,9 @@ iD.modes.DragNode = function(context) {
|
||||
wasMidpoint,
|
||||
cancelled,
|
||||
selectedIDs = [],
|
||||
hover = iD.behavior.Hover(context).altDisables(true);
|
||||
hover = iD.behavior.Hover(context)
|
||||
.altDisables(true)
|
||||
.on('hover', context.ui().sidebar.hover);
|
||||
|
||||
function edge(point, size) {
|
||||
var pad = [30, 100, 30, 100];
|
||||
|
||||
@@ -104,6 +104,11 @@ iD.modes.Select = function(context, selectedIDs) {
|
||||
}), true));
|
||||
}
|
||||
|
||||
if (singular()) {
|
||||
context.ui().sidebar
|
||||
.select(singular().id, newFeature);
|
||||
}
|
||||
|
||||
context.history()
|
||||
.on('undone.select', update)
|
||||
.on('redone.select', update);
|
||||
|
||||
+11
-12
@@ -6,41 +6,40 @@ iD.ui.Sidebar = function(context) {
|
||||
var wrap = selection.append('div')
|
||||
.attr('class', 'inspector-hidden inspector-wrap fr');
|
||||
|
||||
context.on('hover.sidebar', function(entity) {
|
||||
if (context.selectedIDs().length === 1) return;
|
||||
|
||||
if (!current && entity) {
|
||||
sidebar.hover = function(id) {
|
||||
if (!current && id) {
|
||||
wrap.classed('inspector-hidden', false)
|
||||
.classed('inspector-hover', true);
|
||||
|
||||
if (inspector.entityID() !== entity.id || inspector.state() !== 'hover') {
|
||||
if (inspector.entityID() !== id || inspector.state() !== 'hover') {
|
||||
inspector
|
||||
.state('hover')
|
||||
.entityID(entity.id);
|
||||
.entityID(id);
|
||||
|
||||
wrap.call(inspector);
|
||||
}
|
||||
} else {
|
||||
wrap.classed('inspector-hidden', true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
context.on('select.sidebar', function(selectedIDs) {
|
||||
if (!current && selectedIDs.length === 1) {
|
||||
sidebar.select = function(id, newFeature) {
|
||||
if (!current && id) {
|
||||
wrap.classed('inspector-hidden', false)
|
||||
.classed('inspector-hover', false);
|
||||
|
||||
if (inspector.entityID() !== selectedIDs[0] || inspector.state() !== 'select') {
|
||||
if (inspector.entityID() !== id || inspector.state() !== 'select') {
|
||||
inspector
|
||||
.state('select')
|
||||
.entityID(selectedIDs[0]);
|
||||
.entityID(id)
|
||||
.newFeature(newFeature);
|
||||
|
||||
wrap.call(inspector);
|
||||
}
|
||||
} else {
|
||||
wrap.classed('inspector-hidden', true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
sidebar.show = function(component) {
|
||||
wrap.classed('inspector-hidden', true);
|
||||
|
||||
Reference in New Issue
Block a user