]> git.openstreetmap.org Git - rails.git/blobdiff - public/javascripts/openstreetbugs.js
Merge branch 'master' into openstreetbugs
[rails.git] / public / javascripts / openstreetbugs.js
index a8aba9be711c2ba2c51684881df015805fb4d12a..12bd7d8594f9a83b3785bf3f16a67d3e1972b453 100644 (file)
@@ -248,7 +248,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers,
                if(!bounds) return false;
                bounds.transform(this.map.getProjectionObject(), this.apiProjection);
 
                if(!bounds) return false;
                bounds.transform(this.map.getProjectionObject(), this.apiProjection);
 
-               this.apiRequest("bugs"
+               this.apiRequest("notes"
                        + "?bbox="+this.round(bounds.left, 5)
             + ","+this.round(bounds.bottom, 5)
                    + ","+this.round(bounds.right, 5)                   
                        + "?bbox="+this.round(bounds.left, 5)
             + ","+this.round(bounds.bottom, 5)
                    + ","+this.round(bounds.right, 5)                   
@@ -467,7 +467,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers,
         * @param String description
        */
        createBug: function(lonlat, description) {
         * @param String description
        */
        createBug: function(lonlat, description) {
-               this.apiRequest("bug/create"
+               this.apiRequest("note/create"
                        + "?lat="+encodeURIComponent(lonlat.lat)
                        + "&lon="+encodeURIComponent(lonlat.lon)
                        + "&text="+encodeURIComponent(description)
                        + "?lat="+encodeURIComponent(lonlat.lat)
                        + "&lon="+encodeURIComponent(lonlat.lon)
                        + "&text="+encodeURIComponent(description)
@@ -482,7 +482,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers,
         * @param String comment
        */
        submitComment: function(id, comment) {
         * @param String comment
        */
        submitComment: function(id, comment) {
-               this.apiRequest("bug/"+encodeURIComponent(id)+"/comment"
+               this.apiRequest("note/"+encodeURIComponent(id)+"/comment"
                        + "?text="+encodeURIComponent(comment)
                        + "&name="+encodeURIComponent(this.getUserName())
                        + "&format=js"
                        + "?text="+encodeURIComponent(comment)
                        + "&name="+encodeURIComponent(this.getUserName())
                        + "&format=js"
@@ -494,7 +494,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers,
         * @param Number id
        */
        closeBug: function(id) {
         * @param Number id
        */
        closeBug: function(id) {
-               this.apiRequest("bug/"+encodeURIComponent(id)+"/close"
+               this.apiRequest("note/"+encodeURIComponent(id)+"/close"
                        + "?format=js"
                );
        },
                        + "?format=js"
                );
        },
@@ -638,11 +638,15 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, {
         * Map clicking event handler. Adds a temporary marker with a popup to the map, the popup contains the form to add a bug.
        */
        click: function(e) {
         * Map clicking event handler. Adds a temporary marker with a popup to the map, the popup contains the form to add a bug.
        */
        click: function(e) {
+               var lonlat = this.map.getLonLatFromViewPortPx(e.xy);
+               this.addTemporaryMarker(lonlat);
+       },
+
+       addTemporaryMarker: function(lonlat) {
                if(!this.map) return true;
                deactivateControl();
 
                var control = this;
                if(!this.map) return true;
                deactivateControl();
 
                var control = this;
-               var lonlat = this.map.getLonLatFromViewPortPx(e.xy);
                var lonlatApi = lonlat.clone().transform(this.map.getProjectionObject(), this.osbLayer.apiProjection);
                var feature = new OpenLayers.Feature(this.osbLayer, lonlat, { icon: this.icon.clone(), autoSize: true });
                feature.popupClass = OpenLayers.Popup.FramedCloud.OpenStreetBugs;
                var lonlatApi = lonlat.clone().transform(this.map.getProjectionObject(), this.osbLayer.apiProjection);
                var feature = new OpenLayers.Feature(this.osbLayer, lonlat, { icon: this.icon.clone(), autoSize: true });
                feature.popupClass = OpenLayers.Popup.FramedCloud.OpenStreetBugs;
@@ -650,11 +654,39 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, {
                marker.feature = feature;
                this.osbLayer.addMarker(marker);
 
                marker.feature = feature;
                this.osbLayer.addMarker(marker);
 
+
+               /** Implement a drag and drop for markers */
+               /* TODO: veryfy that the scoping of variables works correctly everywhere */             
+               var dragging = false;
+               var dragFunction = function(e) {
+                       map.events.unregister("mouseup",map,dragFunction);
+                       lonlat = map.getLonLatFromViewPortPx(e.xy);
+                       lonlatApi = lonlat.clone().transform(map.getProjectionObject(), map.osbLayer.apiProjection);
+                       marker.moveTo(map.getLayerPxFromViewPortPx(e.xy));
+                       marker.popup.moveTo(map.getLayerPxFromViewPortPx(e.xy));                        
+                       marker.popup.updateRelativePosition();
+                       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;});
+               
+
                var newContent = document.createElement("div");
                var el1,el2,el3;
                el1 = document.createElement("h3");
                el1.appendChild(document.createTextNode(i18n("javascripts.osb.Create bug")));
                newContent.appendChild(el1);
                var newContent = document.createElement("div");
                var el1,el2,el3;
                el1 = document.createElement("h3");
                el1.appendChild(document.createTextNode(i18n("javascripts.osb.Create bug")));
                newContent.appendChild(el1);
+               newContent.appendChild(document.createTextNode(i18n("javascripts.osb.draghelp1")));
+               newContent.appendChild(document.createElement("br"));
+               newContent.appendChild(document.createTextNode(i18n("javascripts.osb.draghelp2")));
+               newContent.appendChild(document.createElement("br"));
+               newContent.appendChild(document.createElement("br"));
 
                var el_form = document.createElement("form");
 
 
                var el_form = document.createElement("form");
 
@@ -720,6 +752,7 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, {
                popup.events.register("close", this, function(){ feature.destroy(); });
                this.map.addPopup(popup);
                popup.updateSize();
                popup.events.register("close", this, function(){ feature.destroy(); });
                this.map.addPopup(popup);
                popup.updateSize();
+               marker.popup = popup;
        },
 
        CLASS_NAME: "OpenLayers.Control.OpenStreetBugs"
        },
 
        CLASS_NAME: "OpenLayers.Control.OpenStreetBugs"