mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Adds hover-highlighting for relations in the raw membership list
Moves hover-highlighting behavior to its own function Hover-highlighting now correctly highlights all members of the target relation
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import _forEach from 'lodash-es/forEach';
|
||||
|
||||
export function highlightEntity(context, entity, highlighted) {
|
||||
|
||||
// highlight the member feature in the map while hovering on the list item
|
||||
var selectorPrefix = entity.type === 'node' ? 'g.' : 'path.';
|
||||
context.surface().selectAll(selectorPrefix+entity.id).classed('highlighted', highlighted);
|
||||
if (entity.members) {
|
||||
// recursively highlight members so that relations will appear highlighted
|
||||
_forEach(entity.members, function(member){
|
||||
if (member.id && context.hasEntity(member.id)) {
|
||||
highlightEntity(context, context.entity(member.id), highlighted);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { d3combobox as d3_combobox } from '../lib/d3.combobox.js';
|
||||
|
||||
import { t } from '../util/locale';
|
||||
import { actionChangeMember, actionDeleteMember } from '../actions';
|
||||
import { highlightEntity } from './entity_highlight';
|
||||
import { modeBrowse, modeSelect } from '../modes';
|
||||
import { osmEntity } from '../osm';
|
||||
import { svgIcon } from '../svg';
|
||||
@@ -37,8 +38,7 @@ export function uiRawMemberEditor(context) {
|
||||
context.map().zoomTo(entity);
|
||||
|
||||
// highlight the feature in case it wasn't previously on-screen
|
||||
var selectorPrefix = d.type === 'node' ? 'g.' : 'path.';
|
||||
context.surface().selectAll(selectorPrefix+d.id).classed('highlighted', true);
|
||||
highlightEntity(context, d.member, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,13 +134,11 @@ export function uiRawMemberEditor(context) {
|
||||
.each(function(d) {
|
||||
if (d.member) {
|
||||
|
||||
// highlight the member feature in the map while hovering on the list item
|
||||
var selectorPrefix = d.type === 'node' ? 'g.' : 'path.';
|
||||
d3_select(this).on('mouseover', function() {
|
||||
context.surface().selectAll(selectorPrefix+d.id).classed('highlighted', true);
|
||||
highlightEntity(context, d.member, true);
|
||||
});
|
||||
d3_select(this).on('mouseout', function() {
|
||||
context.surface().selectAll(selectorPrefix+d.id).classed('highlighted', false);
|
||||
highlightEntity(context, d.member, false);
|
||||
});
|
||||
|
||||
var label = d3_select(this).append('label')
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
actionDeleteMember
|
||||
} from '../actions';
|
||||
|
||||
import { highlightEntity } from './entity_highlight';
|
||||
import { modeSelect } from '../modes';
|
||||
import { osmEntity, osmRelation } from '../osm';
|
||||
import { services } from '../services';
|
||||
@@ -173,6 +174,15 @@ export function uiRawMembershipEditor(context) {
|
||||
.append('li')
|
||||
.attr('class', 'member-row member-row-normal form-field');
|
||||
|
||||
enter.each(function(d){
|
||||
d3_select(this).on('mouseover', function() {
|
||||
highlightEntity(context, d.relation, true);
|
||||
});
|
||||
d3_select(this).on('mouseout', function() {
|
||||
highlightEntity(context, d.relation, false);
|
||||
});
|
||||
});
|
||||
|
||||
var label = enter
|
||||
.append('label')
|
||||
.attr('class', 'form-label')
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
} from 'd3-selection';
|
||||
|
||||
import { t } from '../util/locale';
|
||||
import { highlightEntity } from './entity_highlight';
|
||||
import { modeSelect } from '../modes';
|
||||
import { osmEntity } from '../osm';
|
||||
import { svgIcon } from '../svg';
|
||||
@@ -69,13 +70,12 @@ export function uiSelectionList(context, selectedIDs) {
|
||||
|
||||
enter
|
||||
.each(function(d) {
|
||||
// highlight the feature in the map while hovering on the list item
|
||||
var selectorPrefix = d.type === 'node' ? 'g.' : 'path.';
|
||||
|
||||
d3_select(this).on('mouseover', function() {
|
||||
context.surface().selectAll(selectorPrefix+d.id).classed('highlighted', true);
|
||||
highlightEntity(context, d, true);
|
||||
});
|
||||
d3_select(this).on('mouseout', function() {
|
||||
context.surface().selectAll(selectorPrefix+d.id).classed('highlighted', false);
|
||||
highlightEntity(context, d, false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user