X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/3b55494c8c948b475353d1b12793accecbdb2121..e7cd90f4b4d431b32a92ca68c3df817e8e765d09:/public/javascripts/openstreetbugs.js diff --git a/public/javascripts/openstreetbugs.js b/public/javascripts/openstreetbugs.js index 378c2ce32..6d2f62b35 100644 --- a/public/javascripts/openstreetbugs.js +++ b/public/javascripts/openstreetbugs.js @@ -294,8 +294,8 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, var marker = feature.createMarker(); marker.feature = feature; marker.events.register("click", feature, this.markerClick); - marker.events.register("mouseover", feature, this.markerMouseOver); - marker.events.register("mouseout", feature, this.markerMouseOut); + //marker.events.register("mouseover", feature, this.markerMouseOver); + //marker.events.register("mouseout", feature, this.markerMouseOut); this.addMarker(marker); this.bugs[id] = feature; @@ -317,7 +317,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, var newContent = document.createElement("div"); el1 = document.createElement("h3"); - el1.appendChild(document.createTextNode(closed ? i18n("javascripts.osb.Fixed Error") : i18n("javascripts.osb.Unresolved Error"))); + el1.appendChild(document.createTextNode(putAJAXMarker.bugs[id][2] ? i18n("javascripts.osb.Fixed Error") : i18n("javascripts.osb.Unresolved Error"))); el1.appendChild(document.createTextNode(" [")); el2 = document.createElement("a"); @@ -367,6 +367,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el2.className = (i == 0 ? "osb-description" : "osb-comment"); el2.appendChild(document.createTextNode(putAJAXMarker.bugs[id][1][i])); el1.appendChild(el2); + if (i == 0) { el2 = document.createElement("br"); el1.appendChild(el2);}; } containerDescription.appendChild(el1); @@ -375,7 +376,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el1 = document.createElement("p"); el1.className = "osb-fixed"; el2 = document.createElement("em"); - el2.appendChild(document.createTextNode(i18n("javascripts.osb.Has been fixed."))); + el2.appendChild(document.createTextNode(i18n("javascripts.osb.Has been fixed"))); el1.appendChild(el2); containerDescription.appendChild(el1); } @@ -420,7 +421,9 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el1.appendChild(el2); el2 = document.createElement("dd"); var inputComment = document.createElement("textarea"); - inputComment.setAttribute("cols",40); + inputComment.setAttribute("cols",40); + inputComment.setAttribute("rows",3); + el2.appendChild(inputComment); el1.appendChild(el2); @@ -430,7 +433,8 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, el1.className = "buttons"; el2 = document.createElement("li"); el3 = document.createElement("input"); - el3.setAttribute("type", "submit"); + el3.setAttribute("type", "button"); + el3.onclick = function(){ this.form.onsubmit(); return false; }; el3.value = i18n("javascripts.osb.Add comment"); el2.appendChild(el3); el1.appendChild(el2); @@ -634,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) { + var lonlat = this.map.getLonLatFromViewPortPx(e.xy); + this.addTemporaryMarker(lonlat); + }, + + addTemporaryMarker: function(lonlat) { 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; @@ -646,14 +654,41 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, { 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); + 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"); - el_form.onsubmit = function() { control.osbLayer.createBug(lonlatApi, inputDescription.value); marker.feature = null; feature.destroy(); return false; }; el1 = document.createElement("dl"); el2 = document.createElement("dt"); @@ -677,6 +712,8 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, { el3.appendChild(document.createTextNode(i18n("javascripts.osb.Login"))); el2.appendChild(el3); el1.appendChild(el2); + el2 = document.createElement("br"); + el1.appendChild(el2); el2 = document.createElement("dt"); el2.appendChild(document.createTextNode(i18n("javascripts.osb.Bug description"))); @@ -684,23 +721,38 @@ OpenLayers.Control.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Control, { el2 = document.createElement("dd"); var inputDescription = document.createElement("textarea"); inputDescription.setAttribute("cols",40); + inputDescription.setAttribute("rows",3); el2.appendChild(inputDescription); el1.appendChild(el2); el_form.appendChild(el1); el1 = document.createElement("div"); el2 = document.createElement("input"); - el2.setAttribute("type", "submit"); + el2.setAttribute("type", "button"); el2.value = i18n("javascripts.osb.Create"); + el2.onclick = function() { control.osbLayer.createBug(lonlatApi, inputDescription.value); marker.feature = null; feature.destroy(); return false; }; + el1.appendChild(el2); + el2 = document.createElement("input"); + el2.setAttribute("type", "button"); + el2.value = i18n("javascripts.osb.Cancel"); + el2.onclick = function(){ feature.destroy(); }; el1.appendChild(el2); el_form.appendChild(el1); newContent.appendChild(el_form); + el2 = document.createElement("hr"); + el1.appendChild(el2); + el2 = document.createElement("a"); + el2.setAttribute("href","edit"); + el2.appendChild(document.createTextNode(i18n("javascripts.osb.edityourself"))); + el1.appendChild(el2); + feature.data.popupContentHTML = newContent; var popup = feature.createPopup(true); popup.events.register("close", this, function(){ feature.destroy(); }); this.map.addPopup(popup); popup.updateSize(); + marker.popup = popup; }, CLASS_NAME: "OpenLayers.Control.OpenStreetBugs"