mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-25 17:37:49 +02:00
Move the edit menu logic to uiInit
Make context the first argument of operation objects Add Paste operation to edit menu when opening the context menu on a blank area of the map (close #2508)
This commit is contained in:
@@ -14,6 +14,7 @@ import { utilGetDimensions } from '../util/dimensions';
|
||||
import { uiAccount } from './account';
|
||||
import { uiAttribution } from './attribution';
|
||||
import { uiContributors } from './contributors';
|
||||
import { uiEditMenu } from './edit_menu';
|
||||
import { uiFeatureInfo } from './feature_info';
|
||||
import { uiFlash } from './flash';
|
||||
import { uiFullScreen } from './full_screen';
|
||||
@@ -548,6 +549,48 @@ export function uiInit(context) {
|
||||
};
|
||||
|
||||
|
||||
var _editMenu; // uiEditMenu
|
||||
|
||||
ui.showEditMenu = function(anchorPoint, triggerType, operations) {
|
||||
|
||||
// remove any displayed menu
|
||||
ui.closeEditMenu();
|
||||
|
||||
if (!operations && context.mode().operations) operations = context.mode().operations();
|
||||
if (!operations || !operations.length) return;
|
||||
|
||||
// disable menu if in wide selection, for example
|
||||
if (!context.map().editableDataEnabled()) return;
|
||||
|
||||
var surfaceNode = context.surface().node();
|
||||
if (surfaceNode.focus) { // FF doesn't support it
|
||||
// focus the surface or else clicking off the menu may not trigger modeBrowse
|
||||
surfaceNode.focus();
|
||||
}
|
||||
|
||||
// don't load the menu until it's needed
|
||||
if (!_editMenu) _editMenu = uiEditMenu(context);
|
||||
|
||||
operations.forEach(function(operation) {
|
||||
if (operation.point) operation.point(anchorPoint);
|
||||
});
|
||||
|
||||
_editMenu
|
||||
.anchorLoc(anchorPoint)
|
||||
.triggerType(triggerType)
|
||||
.operations(operations);
|
||||
|
||||
// render the menu
|
||||
context.map().supersurface.call(_editMenu);
|
||||
};
|
||||
|
||||
ui.closeEditMenu = function() {
|
||||
// remove any existing menu no matter how it was added
|
||||
context.map().supersurface
|
||||
.select('.edit-menu').remove();
|
||||
};
|
||||
|
||||
|
||||
var _saveLoading = d3_select(null);
|
||||
|
||||
context.uploader()
|
||||
|
||||
Reference in New Issue
Block a user