mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-31 01:09:22 +02:00
Underscore function scope variables in modeSelectNote
This commit is contained in:
@@ -24,18 +24,17 @@ export function modeSelectNote(context, selectedNoteID) {
|
||||
button: 'browse'
|
||||
};
|
||||
|
||||
var osm = services.osm;
|
||||
var keybinding = utilKeybinding('select-note');
|
||||
var noteEditor = uiNoteEditor(context)
|
||||
var _keybinding = utilKeybinding('select-note');
|
||||
var _noteEditor = uiNoteEditor(context)
|
||||
.on('change', function() {
|
||||
context.map().pan([0,0]); // trigger a redraw
|
||||
var note = checkSelectedID();
|
||||
if (!note) return;
|
||||
context.ui().sidebar
|
||||
.show(noteEditor.note(note));
|
||||
.show(_noteEditor.note(note));
|
||||
});
|
||||
|
||||
var behaviors = [
|
||||
var _behaviors = [
|
||||
behaviorBreathe(context),
|
||||
behaviorHover(context),
|
||||
behaviorSelect(context),
|
||||
@@ -44,12 +43,12 @@ export function modeSelectNote(context, selectedNoteID) {
|
||||
modeDragNote(context).behavior
|
||||
];
|
||||
|
||||
var newFeature = false;
|
||||
var _newFeature = false;
|
||||
|
||||
|
||||
function checkSelectedID() {
|
||||
if (!osm) return;
|
||||
var note = osm.getNote(selectedNoteID);
|
||||
if (!services.osm) return;
|
||||
var note = services.osm.getNote(selectedNoteID);
|
||||
if (!note) {
|
||||
context.enter(modeBrowse(context));
|
||||
}
|
||||
@@ -87,8 +86,8 @@ export function modeSelectNote(context, selectedNoteID) {
|
||||
|
||||
|
||||
mode.zoomToSelected = function() {
|
||||
if (!osm) return;
|
||||
var note = osm.getNote(selectedNoteID);
|
||||
if (!services.osm) return;
|
||||
var note = services.osm.getNote(selectedNoteID);
|
||||
if (note) {
|
||||
context.map().centerZoomEase(note.loc, 20);
|
||||
}
|
||||
@@ -96,8 +95,8 @@ export function modeSelectNote(context, selectedNoteID) {
|
||||
|
||||
|
||||
mode.newFeature = function(val) {
|
||||
if (!arguments.length) return newFeature;
|
||||
newFeature = val;
|
||||
if (!arguments.length) return _newFeature;
|
||||
_newFeature = val;
|
||||
return mode;
|
||||
};
|
||||
|
||||
@@ -106,19 +105,19 @@ export function modeSelectNote(context, selectedNoteID) {
|
||||
var note = checkSelectedID();
|
||||
if (!note) return;
|
||||
|
||||
behaviors.forEach(context.install);
|
||||
_behaviors.forEach(context.install);
|
||||
|
||||
keybinding
|
||||
_keybinding
|
||||
.on(t('inspector.zoom_to.key'), mode.zoomToSelected)
|
||||
.on('⎋', esc, true);
|
||||
|
||||
d3_select(document)
|
||||
.call(keybinding);
|
||||
.call(_keybinding);
|
||||
|
||||
selectNote();
|
||||
|
||||
var sidebar = context.ui().sidebar;
|
||||
sidebar.show(noteEditor.note(note));
|
||||
sidebar.show(_noteEditor.note(note));
|
||||
|
||||
// expand the sidebar, avoid obscuring the note if needed
|
||||
sidebar.expand(sidebar.intersects(note.extent()));
|
||||
@@ -129,10 +128,10 @@ export function modeSelectNote(context, selectedNoteID) {
|
||||
|
||||
|
||||
mode.exit = function() {
|
||||
behaviors.forEach(context.uninstall);
|
||||
_behaviors.forEach(context.uninstall);
|
||||
|
||||
d3_select(document)
|
||||
.call(keybinding.unbind);
|
||||
.call(_keybinding.unbind);
|
||||
|
||||
context.surface()
|
||||
.selectAll('.layer-notes .selected')
|
||||
|
||||
Reference in New Issue
Block a user