From f37475fad99bc324f59291c94977811b4d47dd96 Mon Sep 17 00:00:00 2001 From: Jon D Date: Sat, 5 Nov 2016 19:27:52 +0000 Subject: [PATCH] Add flip horizontal/vertical operations --- data/core.yaml | 7 ++-- dist/locales/en.json | 8 +++-- .../operations/{flip.js => flipHorizontal.js} | 18 ++++------- modules/operations/flipVertical.js | 32 +++++++++++++++++++ modules/operations/index.js | 3 +- 5 files changed, 51 insertions(+), 17 deletions(-) rename modules/operations/{flip.js => flipHorizontal.js} (61%) create mode 100644 modules/operations/flipVertical.js diff --git a/data/core.yaml b/data/core.yaml index a817bb1cd..549015ff9 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -106,11 +106,14 @@ en: not_connected: There aren't enough lines/areas here to disconnect. connected_to_hidden: This can't be disconnected because it is connected to a hidden feature. relation: This can't be disconnected because it connects members of a relation. - flip: + flipHorizontal: title: Flip Horizontal description: Flip this area horizontally. - key: F annotation: Flipped an area horizontally. + flipVertical: + title: Flip Vertical + description: Flip this area vertically. + annotation: Flipped an area vertically. merge: title: Merge description: Merge these features. diff --git a/dist/locales/en.json b/dist/locales/en.json index 542c66816..8fdca99ec 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -137,12 +137,16 @@ "connected_to_hidden": "This can't be disconnected because it is connected to a hidden feature.", "relation": "This can't be disconnected because it connects members of a relation." }, - "flip": { + "flipHorizontal": { "title": "Flip Horizontal", "description": "Flip this area horizontally.", - "key": "F", "annotation": "Flipped an area horizontally." }, + "flipVertical": { + "title": "Flip Vertical", + "description": "Flip this area vertically.", + "annotation": "Flipped an area vertically." + }, "merge": { "title": "Merge", "description": "Merge these features.", diff --git a/modules/operations/flip.js b/modules/operations/flipHorizontal.js similarity index 61% rename from modules/operations/flip.js rename to modules/operations/flipHorizontal.js index 846dfbaed..dcf076551 100644 --- a/modules/operations/flip.js +++ b/modules/operations/flipHorizontal.js @@ -1,38 +1,32 @@ import { t } from '../util/locale'; import { actionFlip } from '../actions/index'; - -export function operationFlip(selectedIDs, context) { +export function operationFlipHorizontal(selectedIDs, context) { var entityId = selectedIDs[0]; var operation = function() { context.perform( actionFlip(entityId, false, context.projection), - t('operations.flip.annotation') + t('operations.flipHorizontal.annotation') ); }; - operation.available = function() { return selectedIDs.length === 1 && context.geometry(entityId) === 'area'; }; - operation.disabled = function() { return false; }; - operation.tooltip = function() { - return t('operations.flip.description'); + return t('operations.flipHorizontal.description'); }; - - operation.id = 'flip'; - operation.keys = [t('operations.flip.key')]; - operation.title = t('operations.flip.title'); - + operation.id = 'flipHorizontal'; + operation.keys = [t('operations.flipHorizontal.key')]; + operation.title = t('operations.flipHorizontal.title'); return operation; } diff --git a/modules/operations/flipVertical.js b/modules/operations/flipVertical.js new file mode 100644 index 000000000..a08097c04 --- /dev/null +++ b/modules/operations/flipVertical.js @@ -0,0 +1,32 @@ +import { t } from '../util/locale'; +import { actionFlip } from '../actions/index'; + +export function operationFlipVertical(selectedIDs, context) { + var entityId = selectedIDs[0]; + + var operation = function() { + context.perform( + actionFlip(entityId, true, context.projection), + t('operations.flipVertical.annotation') + ); + }; + + operation.available = function() { + return selectedIDs.length === 1 && + context.geometry(entityId) === 'area'; + }; + + operation.disabled = function() { + return false; + }; + + operation.tooltip = function() { + return t('operations.flipVertical.description'); + }; + + operation.id = 'flipVertical'; + operation.keys = [t('operations.flipVertical.key')]; + operation.title = t('operations.flipVertical.title'); + + return operation; +} diff --git a/modules/operations/index.js b/modules/operations/index.js index 8022c87f5..6f1f17aac 100644 --- a/modules/operations/index.js +++ b/modules/operations/index.js @@ -9,4 +9,5 @@ export { operationReverse } from './reverse'; export { operationRotate } from './rotate'; export { operationSplit } from './split'; export { operationStraighten } from './straighten'; -export { operationFlip } from './flip'; \ No newline at end of file +export { operationFlipHorizontal } from './flipHorizontal'; +export { operationFlipVertical } from './flipVertical'; \ No newline at end of file