mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Add "zoom to this" quicklink and keybind for keepright editor
(re #5169)
This commit is contained in:
@@ -1166,6 +1166,7 @@ img.tag-reference-wiki-image {
|
||||
}
|
||||
|
||||
.data-editor .quick-links,
|
||||
.keepRight-editor .quick-links,
|
||||
.note-editor .quick-links {
|
||||
padding: 5px 0 0 0;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
behaviorSelect
|
||||
} from '../behavior';
|
||||
|
||||
import { t } from '../util/locale';
|
||||
import { services } from '../services';
|
||||
import { modeBrowse, modeDragNode, modeDragNote } from '../modes';
|
||||
import { uiKeepRightEditor } from '../ui';
|
||||
@@ -53,7 +54,35 @@ export function modeSelectError(context, selectedErrorID) {
|
||||
}
|
||||
|
||||
|
||||
mode.zoomToSelected = function() {
|
||||
if (!keepRight) return;
|
||||
var error = keepRight.getError(selectedErrorID);
|
||||
if (error) {
|
||||
context.map().centerZoom(error.loc, 20);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
mode.enter = function() {
|
||||
var error = checkSelectedID();
|
||||
if (!error) return;
|
||||
|
||||
behaviors.forEach(context.install);
|
||||
keybinding
|
||||
.on(t('inspector.zoom_to.key'), mode.zoomToSelected)
|
||||
.on('⎋', esc, true);
|
||||
|
||||
d3_select(document)
|
||||
.call(keybinding);
|
||||
|
||||
selectError();
|
||||
|
||||
var sidebar = context.ui().sidebar;
|
||||
sidebar.show(keepRightEditor.error(error));
|
||||
|
||||
context.map()
|
||||
.on('drawn.select-error', selectError);
|
||||
|
||||
|
||||
// class the error as selected, or return to browse mode if the error is gone
|
||||
function selectError(drawn) {
|
||||
@@ -82,23 +111,6 @@ export function modeSelectError(context, selectedErrorID) {
|
||||
if (d3_select('.combobox').size()) return;
|
||||
context.enter(modeBrowse(context));
|
||||
}
|
||||
|
||||
var error = checkSelectedID();
|
||||
if (!error) return;
|
||||
|
||||
behaviors.forEach(context.install);
|
||||
keybinding.on('⎋', esc, true);
|
||||
|
||||
d3_select(document)
|
||||
.call(keybinding);
|
||||
|
||||
selectError();
|
||||
|
||||
var sidebar = context.ui().sidebar;
|
||||
sidebar.show(keepRightEditor.error(error));
|
||||
|
||||
context.map()
|
||||
.on('drawn.select-error', selectError);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,15 @@ import { t } from '../util/locale';
|
||||
import { services } from '../services';
|
||||
import { modeBrowse } from '../modes';
|
||||
import { svgIcon } from '../svg';
|
||||
import { uiKeepRightDetails, uiKeepRightHeader, uiViewOnKeepRight } from './index';
|
||||
|
||||
import {
|
||||
uiKeepRightDetails,
|
||||
uiKeepRightHeader,
|
||||
uiQuickLinks,
|
||||
uiTooltipHtml,
|
||||
uiViewOnKeepRight
|
||||
} from './index';
|
||||
|
||||
import { utilNoAuto, utilRebind } from '../util';
|
||||
|
||||
|
||||
@@ -13,11 +21,25 @@ export function uiKeepRightEditor(context) {
|
||||
var dispatch = d3_dispatch('change');
|
||||
var keepRightDetails = uiKeepRightDetails(context);
|
||||
var keepRightHeader = uiKeepRightHeader(context);
|
||||
var quickLinks = uiQuickLinks();
|
||||
|
||||
var _error;
|
||||
|
||||
|
||||
function keepRightEditor(selection) {
|
||||
// quick links
|
||||
var choices = [{
|
||||
id: 'zoom_to',
|
||||
label: 'inspector.zoom_to.title',
|
||||
tooltip: function() {
|
||||
return uiTooltipHtml(t('inspector.zoom_to.tooltip_issue'), t('inspector.zoom_to.key'));
|
||||
},
|
||||
click: function zoomTo() {
|
||||
context.mode().zoomToSelected();
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
var header = selection.selectAll('.header')
|
||||
.data([0]);
|
||||
|
||||
@@ -46,7 +68,7 @@ export function uiKeepRightEditor(context) {
|
||||
.attr('class', 'body')
|
||||
.merge(body);
|
||||
|
||||
var editor = body.selectAll('.error-editor')
|
||||
var editor = body.selectAll('.keepRight-editor')
|
||||
.data([0]);
|
||||
|
||||
editor.enter()
|
||||
@@ -54,6 +76,7 @@ export function uiKeepRightEditor(context) {
|
||||
.attr('class', 'modal-section keepRight-editor')
|
||||
.merge(editor)
|
||||
.call(keepRightHeader.error(_error))
|
||||
.call(quickLinks.choices(choices))
|
||||
.call(keepRightDetails.error(_error))
|
||||
.call(keepRightSaveSection);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user