]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/assets/iD/iD.js
Update to iD v1.5.2
[rails.git] / vendor / assets / iD / iD.js
index cbda33878f441ae7e4e799aa652ccfd6fa03b21c..85e8adcef4ae0f92b485638c68ded08a622f5779 100644 (file)
@@ -16407,7 +16407,7 @@ window.iD = function () {
     return d3.rebind(context, dispatch, 'on');
 };
 
-iD.version = '1.5.1';
+iD.version = '1.5.2';
 
 (function() {
     var detected = {};
@@ -17161,6 +17161,18 @@ _.extend(iD.geo.Extent.prototype, {
                                   Math.min(obj[1][1], this[1][1])]);
     },
 
+    percentContainedIn: function(obj) {
+        if (!(obj instanceof iD.geo.Extent)) obj = new iD.geo.Extent(obj);
+        var a1 = this.intersection(obj).area(),
+            a2 = this.area();
+
+        if (a1 === Infinity || a2 === Infinity || a1 === 0 || a2 === 0) {
+            return 0;
+        } else {
+            return a1 / a2;
+        }
+    },
+
     padByMeters: function(meters) {
         var dLat = iD.geo.metersToLat(meters),
             dLon = iD.geo.metersToLon(meters, this.center()[1]);
@@ -17172,6 +17184,7 @@ _.extend(iD.geo.Extent.prototype, {
     toParam: function() {
         return [this[0][0], this[0][1], this[1][0], this[1][1]].join(',');
     }
+
 });
 iD.geo.Turn = function(turn) {
     if (!(this instanceof iD.geo.Turn))
@@ -19166,6 +19179,9 @@ iD.behavior.drag = function() {
             var p = point(),
                 dx = p[0] - origin_[0],
                 dy = p[1] - origin_[1];
+            
+            if (dx === 0 && dy === 0)
+                return;
 
             if (!started) {
                 started = true;
@@ -21056,6 +21072,8 @@ iD.modes.Select = function(context, selectedIDs) {
 iD.operations = {};
 iD.operations.Circularize = function(selectedIDs, context) {
     var entityId = selectedIDs[0],
+        entity = context.entity(entityId),
+        extent = entity.extent(context.graph()),
         geometry = context.geometry(entityId),
         action = iD.actions.Circularize(entityId, context.projection);
 
@@ -21065,24 +21083,17 @@ iD.operations.Circularize = function(selectedIDs, context) {
     };
 
     operation.available = function() {
-        var entity = context.entity(entityId);
         return selectedIDs.length === 1 &&
             entity.type === 'way' &&
             _.uniq(entity.nodes).length > 1;
     };
 
     operation.disabled = function() {
-        var way = context.entity(entityId),
-            wayExtent = way.extent(context.graph()),
-            mapExtent = context.extent(),
-            intersection = mapExtent.intersection(wayExtent),
-            pctVisible = intersection.area() / wayExtent.area();
-
-        if (pctVisible < 0.8) {
-            return 'too_large';
-        } else {
-            return action.disabled(context.graph());
+        var reason;
+        if (extent.percentContainedIn(context.extent()) < 0.8) {
+            reason = 'too_large';
         }
+        return action.disabled(context.graph()) || reason;
     };
 
     operation.tooltip = function() {
@@ -21310,6 +21321,10 @@ iD.operations.Merge = function(selectedIDs, context) {
     return operation;
 };
 iD.operations.Move = function(selectedIDs, context) {
+    var extent = selectedIDs.reduce(function(extent, id) {
+            return extent.extend(context.entity(id).extent(context.graph()));
+        }, iD.geo.Extent());
+
     var operation = function() {
         context.enter(iD.modes.Move(context, selectedIDs));
     };
@@ -21320,8 +21335,11 @@ iD.operations.Move = function(selectedIDs, context) {
     };
 
     operation.disabled = function() {
-        return iD.actions.Move(selectedIDs)
-            .disabled(context.graph());
+        var reason;
+        if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
+            reason = 'too_large';
+        }
+        return iD.actions.Move(selectedIDs).disabled(context.graph()) || reason;
     };
 
     operation.tooltip = function() {
@@ -21339,16 +21357,17 @@ iD.operations.Move = function(selectedIDs, context) {
 };
 iD.operations.Orthogonalize = function(selectedIDs, context) {
     var entityId = selectedIDs[0],
+        entity = context.entity(entityId),
+        extent = entity.extent(context.graph()),
         geometry = context.geometry(entityId),
         action = iD.actions.Orthogonalize(entityId, context.projection);
 
-    function operation() {
+    var operation = function() {
         var annotation = t('operations.orthogonalize.annotation.' + geometry);
         context.perform(action, annotation);
-    }
+    };
 
     operation.available = function() {
-        var entity = context.entity(entityId);
         return selectedIDs.length === 1 &&
             entity.type === 'way' &&
             entity.isClosed() &&
@@ -21356,17 +21375,11 @@ iD.operations.Orthogonalize = function(selectedIDs, context) {
     };
 
     operation.disabled = function() {
-        var way = context.entity(entityId),
-            wayExtent = way.extent(context.graph()),
-            mapExtent = context.extent(),
-            intersection = mapExtent.intersection(wayExtent),
-            pctVisible = intersection.area() / wayExtent.area();
-
-        if (pctVisible < 0.8) {
-            return 'too_large';
-        } else {
-            return action.disabled(context.graph());
+        var reason;
+        if (extent.percentContainedIn(context.extent()) < 0.8) {
+            reason = 'too_large';
         }
+        return action.disabled(context.graph()) || reason;
     };
 
     operation.tooltip = function() {
@@ -21411,33 +21424,39 @@ iD.operations.Reverse = function(selectedIDs, context) {
     return operation;
 };
 iD.operations.Rotate = function(selectedIDs, context) {
-    var entityId = selectedIDs[0];
+    var entityId = selectedIDs[0],
+        entity = context.entity(entityId),
+        extent = entity.extent(context.graph()),
+        geometry = context.geometry(entityId);
 
     var operation = function() {
         context.enter(iD.modes.RotateWay(context, entityId));
     };
 
     operation.available = function() {
-        var graph = context.graph(),
-            entity = graph.entity(entityId);
-
-        if (selectedIDs.length !== 1 ||
-            entity.type !== 'way')
+        if (selectedIDs.length !== 1 || entity.type !== 'way')
             return false;
-        if (context.geometry(entityId) === 'area')
+        if (geometry === 'area')
             return true;
         if (entity.isClosed() &&
-            graph.parentRelations(entity).some(function(r) { return r.isMultipolygon(); }))
+            context.graph().parentRelations(entity).some(function(r) { return r.isMultipolygon(); }))
             return true;
         return false;
     };
 
     operation.disabled = function() {
-        return false;
+        if (extent.percentContainedIn(context.extent()) < 0.8) {
+            return 'too_large';
+        } else {
+            return false;
+        }
     };
 
     operation.tooltip = function() {
-        return t('operations.rotate.description');
+        var disable = operation.disabled();
+        return disable ?
+            t('operations.rotate.' + disable) :
+            t('operations.rotate.description');
     };
 
     operation.id = 'rotate';
@@ -30748,7 +30767,7 @@ iD.ui.preset.defaultcheck = function(field) {
     if (options) {
         for (var k in options) {
             values.push(k === 'undefined' ? undefined : k);
-            texts.push(field.t('check.' + k, { 'default': options[k] }));
+            texts.push(field.t('options.' + k, { 'default': options[k] }));
         }
     } else {
         values = [undefined, 'yes'];
@@ -30765,8 +30784,7 @@ iD.ui.preset.defaultcheck = function(field) {
         if (field.id === 'oneway') {
             for (var key in entity.tags) {
                 if (key in iD.oneWayTags && (entity.tags[key] in iD.oneWayTags[key])) {
-                    texts.shift();
-                    texts.unshift(t('presets.fields.oneway_yes.check.undefined', { 'default': 'Assumed to be Yes' }));
+                    texts[0] = t('presets.fields.oneway_yes.options.undefined');
                     break;
                 }
             }
@@ -101894,7 +101912,6 @@ iD.introGraph = '{"n185954700":{"id":"n185954700","loc":[-85.642244,41.939081],"
             "oneway_yes": {
                 "key": "oneway",
                 "type": "check",
-                "default": "yes",
                 "label": "One Way",
                 "strings": {
                     "options": {
@@ -114493,7 +114510,8 @@ iD.introGraph = '{"n185954700":{"id":"n185954700","loc":[-85.642244,41.939081],"
                     "area": "Moved an area.",
                     "multiple": "Moved multiple objects."
                 },
-                "incomplete_relation": "This feature can't be moved because it hasn't been fully downloaded."
+                "incomplete_relation": "This feature can't be moved because it hasn't been fully downloaded.",
+                "too_large": "This can't be moved because not enough of it is currently visible."
             },
             "rotate": {
                 "title": "Rotate",
@@ -114502,7 +114520,8 @@ iD.introGraph = '{"n185954700":{"id":"n185954700","loc":[-85.642244,41.939081],"
                 "annotation": {
                     "line": "Rotated a line.",
                     "area": "Rotated an area."
-                }
+                },
+                "too_large": "This can't be rotated because not enough of it is currently visible."
             },
             "reverse": {
                 "title": "Reverse",