From 6be53b0f5f0b8514461460341d6ff16801be9abc Mon Sep 17 00:00:00 2001 From: Richard Fairhurst Date: Thu, 12 Jul 2012 08:33:00 +0100 Subject: [PATCH] Show rudimentary name in the tooltip dialog --- js/iD/Entity.js | 30 ++++++++++++++++++++---- js/iD/controller/edit/EditBaseState.js | 14 +++++------ js/iD/controller/edit/SelectedPOINode.js | 2 +- js/iD/controller/edit/SelectedWay.js | 2 +- js/iD/controller/edit/SelectedWayNode.js | 2 +- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/js/iD/Entity.js b/js/iD/Entity.js index 553ab0234..0af9e7fe8 100755 --- a/js/iD/Entity.js +++ b/js/iD/Entity.js @@ -17,6 +17,7 @@ declare("iD.Entity", null, { parents: null, modified: false, deleted: false, + MAINKEYS: ['highway','amenity','railway','waterway'], constructor:function() { this.tags={}; @@ -27,10 +28,6 @@ declare("iD.Entity", null, { return this.entityType==_type; }, - getTagsHash:function() { - return this.tags; - }, - toString:function() { return this.entityType+"."+this.id; }, @@ -53,6 +50,31 @@ declare("iD.Entity", null, { within:function(left,right,top,bottom) { return !this.deleted; }, + // Tag functions + + getTagsHash:function() { + return this.tags; + }, + + numTags:function() { + var c=0; + for (var i in this.tags) { c++; } + return c; + }, + + friendlyName:function() { + 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"+ - " "+ - " ", + openEditorTooltip:function(x,y,entity) { + var h=entity.friendlyName(); h = (h=='') ? h : h+"
"; + this.editortooltip = new dijit.TooltipDialog({ + content: h+" " + +" ", autoFocus: false }); - dijit.popup.open({ popup: editortooltip, x: x, y: y }); + dijit.popup.open({ popup: this.editortooltip, x: x, y: y }); }, closeEditorTooltip:function() { - if (this.editortooltip) { dijit.popup.close(editortooltip); } + if (this.editortooltip) { dijit.popup.close(this.editortooltip); } }, }); diff --git a/js/iD/controller/edit/SelectedPOINode.js b/js/iD/controller/edit/SelectedPOINode.js index cb8752944..4adffda66 100755 --- a/js/iD/controller/edit/SelectedPOINode.js +++ b/js/iD/controller/edit/SelectedPOINode.js @@ -19,7 +19,7 @@ declare("iD.controller.edit.SelectedPOINode", [iD.controller.edit.EditBaseState] this.nodeUI.setStateClass('selected'); this.nodeUI.redraw(); this.openEditorTooltip(map.lon2screen(this.node.lon), - map.lat2screen(this.node.lat)); + map.lat2screen(this.node.lat), this.node); }, exitState:function() { this.nodeUI.resetStateClass('selected'); diff --git a/js/iD/controller/edit/SelectedWay.js b/js/iD/controller/edit/SelectedWay.js index 3c6902cc6..c0541e559 100755 --- a/js/iD/controller/edit/SelectedWay.js +++ b/js/iD/controller/edit/SelectedWay.js @@ -19,7 +19,7 @@ declare("iD.controller.edit.SelectedWay", [iD.controller.edit.EditBaseState], { this.wayUI=this.controller.map.getUI(this.way); this.wayUI.setStateClass('selected'); this.wayUI.setStateClass('shownodes'); - if (this.entryevent) { this.openEditorTooltip(this.entryevent.clientX, this.entryevent.clientY); } + if (this.entryevent) { this.openEditorTooltip(this.entryevent.clientX, this.entryevent.clientY, this.way); } this.wayUI.redraw(); }, exitState:function() { diff --git a/js/iD/controller/edit/SelectedWayNode.js b/js/iD/controller/edit/SelectedWayNode.js index cb3ce6fd7..70cfe8eed 100755 --- a/js/iD/controller/edit/SelectedWayNode.js +++ b/js/iD/controller/edit/SelectedWayNode.js @@ -19,7 +19,7 @@ declare("iD.controller.edit.SelectedWayNode", [iD.controller.edit.EditBaseState] map.getUI(this.way ).setStateClass('shownodes').redraw(); map.getUI(this.node).setStateClass('selected' ).redraw(); this.openEditorTooltip(map.lon2screen(this.node.lon), - map.lat2screen(this.node.lat)); + map.lat2screen(this.node.lat), this.node); }, exitState:function() { var map=this.controller.map;