]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/assets/iD/iD.js
Update to iD v2.18.4
[rails.git] / vendor / assets / iD / iD.js
index 3ce4ca9bed5370baab3d0a8d1675f6219e1361d5..ba3246b5f48ac1bb3616031fa6be2bbb6407686c 100644 (file)
                return new osmNode({
                    id:  uid,
                    visible: typeof obj.visible === 'boolean' ? obj.visible : true,
-                   version: obj.version.toString(),
-                   changeset: obj.changeset.toString(),
+                   version: obj.version && obj.version.toString(),
+                   changeset: obj.changeset && obj.changeset.toString(),
                    timestamp: obj.timestamp,
                    user: obj.user,
-                   uid: obj.uid.toString(),
+                   uid: obj.uid && obj.uid.toString(),
                    loc: [parseFloat(obj.lon), parseFloat(obj.lat)],
                    tags: obj.tags
                });
                return new osmWay({
                    id:  uid,
                    visible: typeof obj.visible === 'boolean' ? obj.visible : true,
-                   version: obj.version.toString(),
-                   changeset: obj.changeset.toString(),
+                   version: obj.version && obj.version.toString(),
+                   changeset: obj.changeset && obj.changeset.toString(),
                    timestamp: obj.timestamp,
                    user: obj.user,
-                   uid: obj.uid.toString(),
+                   uid: obj.uid && obj.uid.toString(),
                    tags: obj.tags,
                    nodes: getNodesJSON(obj)
                });
                return new osmRelation({
                    id:  uid,
                    visible: typeof obj.visible === 'boolean' ? obj.visible : true,
-                   version: obj.version.toString(),
-                   changeset: obj.changeset.toString(),
+                   version: obj.version && obj.version.toString(),
+                   changeset: obj.changeset && obj.changeset.toString(),
                    timestamp: obj.timestamp,
                    user: obj.user,
-                   uid: obj.uid.toString(),
+                   uid: obj.uid && obj.uid.toString(),
                    tags: obj.tags,
                    members: getMembersJSON(obj)
                });
 
                    var loc = extent.center();
                    context.map().centerEase(loc);
+                   // we could enter the mode multiple times, so reset follow for next time
+                   _follow = false;
                }
 
 
                // Guess a type based on the tokens present in the template
                // (This is for 'custom' source, where we don't know)
                if (!source.type) {
-                   if (/\{(proj|wkid|bbox)\}/.test(_template)) {
+                   if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(_template)) {
                        source.type = 'wms';
                        source.projection = 'EPSG:3857';  // guess
                    } else if (/\{(x|y)\}/.test(_template)) {
                      switch (key) {
                        case 'width':
                        case 'height':
-                         return tileSize;
+                           return tileSize;
                        case 'proj':
-                         return projection;
+                           return projection;
                        case 'wkid':
-                         return projection.replace(/^EPSG:/, '');
+                           return projection.replace(/^EPSG:/, '');
                        case 'bbox':
-                         return minXmaxY.x + ',' + maxXminY.y + ',' + maxXminY.x + ',' + minXmaxY.y;
+                           // WMS 1.3 flips x/y for some coordinate systems including EPSG:4326 - #7557
+                           if (projection === 'EPSG:4326' &&
+                               // The CRS parameter implies version 1.3 (prior versions use SRS)
+                               /VERSION=1.3|CRS={proj}/.test(source.template())) {
+                               return maxXminY.y + ',' + minXmaxY.x + ',' + minXmaxY.y + ',' + maxXminY.x;
+                           } else {
+                               return minXmaxY.x + ',' + maxXminY.y + ',' + maxXminY.x + ',' + minXmaxY.y;
+                           }
                        case 'w':
-                         return minXmaxY.x;
+                           return minXmaxY.x;
                        case 's':
-                         return maxXminY.y;
+                           return maxXminY.y;
                        case 'n':
-                         return maxXminY.x;
+                           return maxXminY.x;
                        case 'e':
-                         return minXmaxY.y;
+                           return minXmaxY.y;
                        default:
-                         return token;
+                           return token;
                      }
                    });
 
                point: _t('modes.add_point.title'),
                line: _t('modes.add_line.title'),
                area: _t('modes.add_area.title'),
-               note: _t('modes.add_note.title'),
+               note: _t('modes.add_note.label'),
                delete: _t('operations.delete.title'),
                move: _t('operations.move.title'),
                orthogonalize: _t('operations.orthogonalize.title'),
                _base = context.graph();
                _coalesceChanges = false;
 
-               loadActivePresets();
+               loadActivePresets(true);
 
                return entityEditor
                    .modified(false);
            };
 
 
-           function loadActivePresets() {
+           function loadActivePresets(isForNewSelection) {
 
                var graph = context.graph();
 
                    return _mainPresetIndex.item(pID);
                });
 
-               // A "weak" preset doesn't set any tags. (e.g. "Address")
-               var weakPreset = _activePresets.length === 1 &&
-                   Object.keys(_activePresets[0].addTags || {}).length === 0;
-               // Don't replace a weak preset with a fallback preset (e.g. "Point")
-               if (weakPreset && matches.length === 1 && matches[0].isFallback()) { return; }
+               if (!isForNewSelection) {
+                   // A "weak" preset doesn't set any tags. (e.g. "Address")
+                   var weakPreset = _activePresets.length === 1 &&
+                       !_activePresets[0].isFallback() &&
+                       Object.keys(_activePresets[0].addTags || {}).length === 0;
+                   // Don't replace a weak preset with a fallback preset (e.g. "Point")
+                   if (weakPreset && matches.length === 1 && matches[0].isFallback()) { return; }
+               }
 
                entityEditor.presets(matches);
            }
 
                        // some targets have default click events we don't want to override
                        var isOkayTarget = event.composedPath().some(function(node) {
-                           // clicking <label> affects its <input> by default
-                           return node.nodeName === 'LABEL' ||
+                           // we only care about element nodes
+                           return node.nodeType === 1 &&
+                               // clicking <input> focuses it and/or changes a value
+                               (node.nodeName === 'INPUT' ||
+                               // clicking <label> affects its <input> by default
+                               node.nodeName === 'LABEL' ||
                                // clicking <a> opens a hyperlink by default
-                               node.nodeName === 'A';
+                               node.nodeName === 'A');
                        });
                        if (isOkayTarget) { return; }
 
          var context = utilRebind({}, dispatch$1, 'on');
          var _deferred = new Set();
 
-         context.version = '2.18.1';
+         context.version = '2.18.4';
          context.privacyVersion = '20200407';
 
          // iD will alter the hash so cache the parameters intended to setup the session
 
 
          /* Straight accessors. Avoid using these if you can. */
-         var _connection;
+         // Instantiate the connection here because it doesn't require passing in
+         // `context` and it's needed for pre-init calls like `preauth`
+         var _connection = services.osm;
          var _history;
          var _validator;
          var _uploader;
              _photos = rendererPhotos(context);
 
              _ui = uiInit(context);
-
-             _connection = services.osm;
            }
 
            // Set up objects that might need to access properties of `context`. The order