From: Tom Hughes Date: Sat, 13 Aug 2011 18:11:05 +0000 (+0100) Subject: Tidy up some insanity in the creating of new notes X-Git-Tag: live~5068^2~137 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/e48837fb260d624042c2498dfc5b7842a160d5c3 Tidy up some insanity in the creating of new notes --- diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index fa790dbb1..0205e79a6 100644 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@ -288,7 +288,6 @@ end } function addNote() { - map.noteControl.activate(); map.noteControl.addTemporaryMarker(map.getCenter()); } diff --git a/public/javascripts/notes.js b/public/javascripts/notes.js index 473498582..796b1d8d7 100644 --- a/public/javascripts/notes.js +++ b/public/javascripts/notes.js @@ -689,8 +689,7 @@ OpenLayers.Control.Notes = new OpenLayers.Class(OpenLayers.Control, { addTemporaryMarker: function(lonlat) { if(!this.map) return true; - deactivateControl(); - + var control = this; var lonlatApi = lonlat.clone().transform(this.map.getProjectionObject(), this.noteLayer.apiProjection); var feature = new OpenLayers.Feature(this.noteLayer, lonlat, { icon: this.icon.clone(), autoSize: true }); @@ -713,15 +712,20 @@ OpenLayers.Control.Notes = new OpenLayers.Class(OpenLayers.Control, { dragging = false; return false; }; - - marker.events.register("mouseover", this, - function(){ document.getElementById("OpenLayers.Map_18_OpenLayers_Container").style.cursor = "move"; }); - marker.events.register("mouseout", this, - function(){ if (!dragging) {document.getElementById("OpenLayers.Map_18_OpenLayers_Container").style.cursor = "default"; }}); - marker.events.register("mousedown", this, - function() { dragging = true; map.events.register("mouseup",map, dragFunction); return false;}); - - + + marker.events.register("mouseover", this, function() { + control.map.viewPortDiv.style.cursor = "move"; + }); + marker.events.register("mouseout", this, function() { + if (!dragging) + control.map.viewPortDiv.style.cursor = "default"; + }); + marker.events.register("mousedown", this, function() { + dragging = true; + control.map.events.register("mouseup", control.map, dragFunction); + return false; + }); + var newContent = document.createElement("div"); var el1,el2,el3; el1 = document.createElement("h3"); @@ -919,8 +923,3 @@ function osbResponse(error) putAJAXMarker.layers = [ ]; putAJAXMarker.notes = { }; - -function deactivateControl() { - map.noteControl.deactivate(); - document.getElementById("OpenLayers.Map_18_OpenLayers_Container").style.cursor = "default"; -}