mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-17 22:24:49 +02:00
Preserve backward compability with radial menu
Old menu behavior can be restored with 2 cookies: - `edit-menu-style=radial` - Display menu as a radial menu, limited to 8 items - `edit-menu-show-always=1` - Show menu on all clicks, not just contextmenu/right
This commit is contained in:
@@ -44,6 +44,9 @@ export function behaviorSelect(context) {
|
||||
if (!p1) p1 = point();
|
||||
d3.select(window)
|
||||
.on('mouseup.select', mouseup, true);
|
||||
|
||||
var isShowAlways = +context.storage('edit-menu-show-always') === 1;
|
||||
suppressMenu = !isShowAlways;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +68,9 @@ export function behaviorSelect(context) {
|
||||
return;
|
||||
}
|
||||
|
||||
var datum = d3.event.target.__data__,
|
||||
isMultiselect = d3.event.shiftKey || d3.select('#surface .lasso').node(),
|
||||
var isMultiselect = d3.event.shiftKey || d3.select('#surface .lasso').node(),
|
||||
isShowAlways = +context.storage('edit-menu-show-always') === 1,
|
||||
datum = d3.event.target.__data__,
|
||||
mode = context.mode();
|
||||
|
||||
|
||||
@@ -84,7 +88,7 @@ export function behaviorSelect(context) {
|
||||
var selectedIDs = context.selectedIDs();
|
||||
|
||||
if (!isMultiselect) {
|
||||
if (selectedIDs.length > 1 && !suppressMenu) {
|
||||
if (selectedIDs.length > 1 && (!suppressMenu && !isShowAlways)) {
|
||||
// multiple things already selected, just show the menu...
|
||||
mode.suppressMenu(false).reselect();
|
||||
} else {
|
||||
@@ -95,7 +99,7 @@ export function behaviorSelect(context) {
|
||||
} else {
|
||||
if (selectedIDs.indexOf(datum.id) !== -1) {
|
||||
// clicked entity is already in the selectedIDs list..
|
||||
if (!suppressMenu) {
|
||||
if (!suppressMenu && !isShowAlways) {
|
||||
// don't deselect clicked entity, just show the menu.
|
||||
mode.suppressMenu(false).reselect();
|
||||
} else {
|
||||
|
||||
+20
-5
@@ -28,9 +28,12 @@ import {
|
||||
import { modeBrowse } from './browse';
|
||||
import { modeDragNode } from './drag_node';
|
||||
import * as Operations from '../operations/index';
|
||||
import { uiEditMenu, uiSelectionList } from '../ui/index';
|
||||
import { uiEditMenu, uiSelectionList } from '../ui';
|
||||
import { uiCmd } from '../ui/cmd';
|
||||
import { utilEntityOrMemberSelector, utilEntitySelector } from '../util/index';
|
||||
import { utilEntityOrMemberSelector, utilEntitySelector } from '../util';
|
||||
|
||||
// deprecation warning - Radial Menu to be removed in iD v3
|
||||
import { uiRadialMenu } from '../ui';
|
||||
|
||||
|
||||
var relatedParent;
|
||||
@@ -171,7 +174,8 @@ export function modeSelect(context, selectedIDs) {
|
||||
|
||||
|
||||
function toggleMenu() {
|
||||
if (d3.select('.edit-menu').empty()) {
|
||||
// deprecation warning - Radial Menu to be removed in iD v3
|
||||
if (d3.select('.edit-menu, .radial-menu').empty()) {
|
||||
showMenu();
|
||||
} else {
|
||||
closeMenu();
|
||||
@@ -401,7 +405,14 @@ export function modeSelect(context, selectedIDs) {
|
||||
.map(function(o) { return o(selectedIDs, context); })
|
||||
.filter(function(o) { return o.available(); });
|
||||
|
||||
operations.unshift(Operations.operationDelete(selectedIDs, context));
|
||||
// deprecation warning - Radial Menu to be removed in iD v3
|
||||
var isRadialMenu = context.storage('edit-menu-style') === 'radial';
|
||||
if (isRadialMenu) {
|
||||
operations = operations.slice(0,7);
|
||||
operations.unshift(Operations.operationDelete(selectedIDs, context));
|
||||
} else {
|
||||
operations.push(Operations.operationDelete(selectedIDs, context));
|
||||
}
|
||||
|
||||
operations.forEach(function(operation) {
|
||||
if (operation.behavior) {
|
||||
@@ -425,7 +436,11 @@ export function modeSelect(context, selectedIDs) {
|
||||
d3.select(document)
|
||||
.call(keybinding);
|
||||
|
||||
editMenu = uiEditMenu(context, operations);
|
||||
|
||||
// deprecation warning - Radial Menu to be removed in iD v3
|
||||
editMenu = isRadialMenu
|
||||
? uiRadialMenu(context, operations)
|
||||
: uiEditMenu(context, operations);
|
||||
|
||||
context.ui().sidebar
|
||||
.select(singular() ? singular().id : null, newFeature);
|
||||
|
||||
@@ -309,7 +309,8 @@ export function rendererMap(context) {
|
||||
function resetTransform() {
|
||||
if (!transformed) return false;
|
||||
|
||||
surface.selectAll('.edit-menu').interrupt().remove();
|
||||
// deprecation warning - Radial Menu to be removed in iD v3
|
||||
surface.selectAll('.edit-menu, .radial-menu').interrupt().remove();
|
||||
utilSetTransform(supersurface, 0, 0);
|
||||
transformed = false;
|
||||
return true;
|
||||
|
||||
@@ -31,7 +31,7 @@ export function uiIntroPoint(context, reveal) {
|
||||
t('intro.points.add', { button: icon('#icon-point', 'pre-text') }),
|
||||
{ tooltipClass: 'intro-points-add' });
|
||||
|
||||
var corner = [-85.632481,41.944094];
|
||||
var corner = [-85.632481, 41.944094];
|
||||
|
||||
context.on('enter.intro', addPoint);
|
||||
|
||||
@@ -143,7 +143,8 @@ export function uiIntroPoint(context, reveal) {
|
||||
context.history().on('change.intro', deleted);
|
||||
|
||||
setTimeout(function() {
|
||||
var node = d3.select('.edit-menu-item-delete').node();
|
||||
// deprecation warning - Radial Menu to be removed in iD v3
|
||||
var node = d3.select('.edit-menu-item-delete, .radial-menu-item-delete').node();
|
||||
var pointBox = pad(node.getBoundingClientRect(), 50, context);
|
||||
reveal(pointBox,
|
||||
t('intro.points.delete', { button: icon('#operation-delete', 'pre-text') }));
|
||||
|
||||
Reference in New Issue
Block a user