From f5036db97894bdca33f02349e93dd55f8bfb195d Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 1 Feb 2013 17:28:50 -0500 Subject: [PATCH] Start iD.operations.Merge (#435) It's currently limited to merging (joining) exactly two lines. Fixes #370. --- index.html | 1 + js/id/operations/merge.js | 27 +++++++++++++++++++++++++++ locale/en.js | 6 ++++++ test/index.html | 1 + 4 files changed, 35 insertions(+) create mode 100644 js/id/operations/merge.js diff --git a/index.html b/index.html index 07063cf81..d8be52dcd 100644 --- a/index.html +++ b/index.html @@ -114,6 +114,7 @@ + diff --git a/js/id/operations/merge.js b/js/id/operations/merge.js new file mode 100644 index 000000000..08517e9b2 --- /dev/null +++ b/js/id/operations/merge.js @@ -0,0 +1,27 @@ +iD.operations.Merge = function(selection, context) { + var action = iD.actions.Join(selection[0], selection[1]); + + var operation = function() { + context.perform( + action, + t('operations.merge.annotation', {n: selection.length})); + }; + + operation.available = function() { + return selection.length === 2 && + _.all(selection, function (id) { + return context.geometry(id) === 'line'; + }); + }; + + operation.enabled = function() { + return action.enabled(context.graph()); + }; + + operation.id = "merge"; + operation.key = t('operations.merge.key'); + operation.title = t('operations.merge.title'); + operation.description = t('operations.merge.description'); + + return operation; +}; diff --git a/locale/en.js b/locale/en.js index 7d1bed947..9e4eb5b2a 100644 --- a/locale/en.js +++ b/locale/en.js @@ -83,6 +83,12 @@ locale.en = { key: "D", annotation: "Disconnected ways." }, + merge: { + title: "Merge", + description: "Merge these lines.", + key: "C", + annotation: "Merged {n} lines." + }, move: { title: "Move", description: "Move this to a different location.", diff --git a/test/index.html b/test/index.html index 524894c36..da3cd475c 100644 --- a/test/index.html +++ b/test/index.html @@ -110,6 +110,7 @@ +