mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Get Selection working again
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
<script type="text/javascript" src="js/lib/underscore-min.js"></script>
|
||||
<script type="text/javascript" src="js/lib/jshashtable.js"></script>
|
||||
<script type="text/javascript" src="js/lib/jquery-1.8.2.min.js"></script>
|
||||
<script type="text/javascript" src="js/iD/Util.js"></script>
|
||||
<script type="text/javascript" src="js/iD/Node.js"></script>
|
||||
<script type="text/javascript" src="js/iD/Relation.js"></script>
|
||||
<script type="text/javascript" src="js/iD/Entity.js"></script>
|
||||
|
||||
@@ -3,7 +3,6 @@ if (typeof iD === 'undefined') iD = {};
|
||||
iD._id = 0;
|
||||
|
||||
iD.Entity = function() {
|
||||
this.tags = {};
|
||||
this.parents = {};
|
||||
// The ID locally
|
||||
this._id = iD._id++;
|
||||
@@ -14,7 +13,6 @@ iD.Entity = function() {
|
||||
this.entityType = '';
|
||||
this.modified = false;
|
||||
this.deleted = false;
|
||||
this.MAINKEYS = ['highway','amenity','railway','waterway'];
|
||||
};
|
||||
|
||||
iD.Entity.prototype = {
|
||||
@@ -42,28 +40,7 @@ iD.Entity.prototype = {
|
||||
return !this.deleted; // Boolean
|
||||
},
|
||||
|
||||
// -------------
|
||||
// Tag functions
|
||||
numTags:function() {
|
||||
// summary: Count how many tags this entity has.
|
||||
return Object.keys(this.tags).length;
|
||||
},
|
||||
|
||||
friendlyName:function() {
|
||||
// summary: Rough-and-ready function to return a human-friendly name
|
||||
// for the object. Really just a placeholder for something better.
|
||||
// returns: A string such as 'river' or 'Fred's House'.
|
||||
if (this.numTags()===0) { return ''; }
|
||||
var n=[];
|
||||
if (this.tags.name) { n.push(this.tags.name); }
|
||||
if (this.tags.ref) { n.push(this.tags.ref); }
|
||||
if (n.length===0) {
|
||||
for (var i=0; i<this.MAINKEYS.length; i++) {
|
||||
if (this.tags[this.MAINKEYS[i]]) { n.push(this.tags[this.MAINKEYS[i]]); break; }
|
||||
}
|
||||
}
|
||||
return n.length===0 ? 'unknown' : n.join('; '); // String
|
||||
},
|
||||
|
||||
// ---------------
|
||||
// Parent-handling
|
||||
|
||||
22
js/iD/Util.js
Normal file
22
js/iD/Util.js
Normal file
@@ -0,0 +1,22 @@
|
||||
if (typeof iD === 'undefined') iD = {};
|
||||
|
||||
iD.Util = {};
|
||||
|
||||
iD.Util.friendlyName = function(entity) {
|
||||
// summary: Rough-and-ready function to return a human-friendly name
|
||||
// for the object. Really just a placeholder for something better.
|
||||
// returns: A string such as 'river' or 'Fred's House'.
|
||||
if (_.isEmpty(entity.tags)) { return ''; }
|
||||
|
||||
var mainkeys = ['highway','amenity','railway','waterway'];
|
||||
var n = _.compact([entity.tags.name, entity.tags.ref]);
|
||||
|
||||
if (!n.length) {
|
||||
var k = _.find(mainkeys, function(m) {
|
||||
return !!entity.tags[m];
|
||||
});
|
||||
if (k) n.push(entity.tags[k]);
|
||||
}
|
||||
|
||||
return n.length === 0 ? 'unknown' : n.join('; ');
|
||||
};
|
||||
@@ -19,7 +19,7 @@ declare("iD.controller.edit.EditBaseState", [iD.controller.ControllerState], {
|
||||
// x: Number Screen co-ordinate.
|
||||
// y: Number Screen co-ordinate.
|
||||
// entity: iD.Entity The entity to be edited.
|
||||
var h=entity.friendlyName();
|
||||
var h = iD.Util.friendlyName(entity);
|
||||
if (h !== '') h = h + "<br/>";
|
||||
this.editortooltip = new dijit.TooltipDialog({
|
||||
content: h+"<button data-dojo-type='dijit.form.Button' type='submit'>Edit tags</button> " +
|
||||
|
||||
@@ -194,9 +194,9 @@ declare("iD.renderer.Map", null, {
|
||||
|
||||
getUI:function(entity) {
|
||||
// summary: Return the UI for an entity, if it exists.
|
||||
if (entity.nodeType === 'node') {
|
||||
if (entity.entityType === 'node') {
|
||||
return this.nodeuis[entity.id]; // iD.renderer.EntityUI
|
||||
} else if (entity.nodeType === 'way') {
|
||||
} else if (entity.entityType === 'way') {
|
||||
return this.wayuis[entity.id]; // iD.renderer.EntityUI
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user