}
};
+var SYJPathLength = (function(){
+ return {
+ update: function() {
+ var pathLength = 0, unit;
+ if (SYJView.mode === 'view') {
+ if (SYJView.viewLayer.features.length) {
+ pathLength = SYJView.viewLayer.features[0].geometry.getGeodesicLength(Mercator);
+ }
+ } else {
+ pathLength = SYJView.editControl.handler.line.geometry.getGeodesicLength(Mercator);
+ }
+
+ if (pathLength === 0) {
+ $("path-length").hide();
+ return;
+ }
+ $("path-length").show();
+
+ if (pathLength < 1000) {
+ // precision: 1 cm
+ pathLength = Math.round(pathLength * 100) / 100;
+ unit = 'm';
+ } else {
+ // precision: 1 m
+ pathLength = Math.round(pathLength) / 1000;
+ unit = 'km';
+ }
+ $("path-length-content").update(pathLength + ' ' + unit);
+ }
+ };
+}());
+
var SYJDataUi = (function() {
var deck = null,
+ infotoggler = null,
getdeck = function() {
- if (!deck) {
- deck = new Deck("data_controls");
- }
- return deck;
- };
+ if (!deck) {
+ deck = new Deck("data_controls");
+ }
+ return deck;
+ },
+ getinfotoggler = function() {
+ if (!infotoggler) {
+ infotoggler = new Toggler('path-infos-content');
+ $("path-infos-toggler").insert({bottom: infotoggler.element});
+ $("path-infos-anchor").observe('click', function(evt) {
+ evt.stop();
+ infotoggler.toggle(evt);
+ });
+ document.observe('toggler:open', function(evt) {
+ if (evt.memo === infotoggler) {
+ // XXX: update informations
+ }
+ });
+ }
+ return infotoggler;
+ };
return {
viewmode: function() {
getdeck().setIndex(0);
+ if ($("path-infos")) {
+ getinfotoggler();
+ getinfotoggler().close();
+ $("path-infos").show();
+ }
},
editmode: function() {
getdeck().setIndex(1);
+ if ($("path-infos")) {
+ $("path-infos").hide();
+ }
}
};
}());
}
this.map.zoomToExtent(extent);
document.observe('simplebox:shown', this.observer.bindAsEventListener(this));
+ SYJPathLength.update();
},
observer: function(evt) {
this.editControl = new OpenLayers.Control.DrawFeature(new OpenLayers.Layer.Vector(), OpenLayers.Handler.SyjModifiablePath, {
callbacks: {
modify: function(f, line) {
+ SYJPathLength.update();
if (!SYJView.unsavedRoute) {
SYJView.unsavedRoute = {};
}
});
anchor.observe('click', clickhandler(item.boundingbox));
+ Element.text(anchor, item.display_name);
- var text = document.createTextNode(item.display_name);
var icon = new Element("img", {
className: "nominatim-suggestions-icon",
src: item.icon || 'icons/world.png'
});
- anchor.appendChild(text); // insert does not work; see prototype #1125
li.insert(icon).insert(anchor);
$("nominatim-suggestions-list").insert(li);
if ($("nominatim-suggestions-list").childNodes.length >= 6) {
}
if ($("nominatim-suggestions-list").childNodes.length > 1) {
- $("nominatim-suggestions").show();
+ var bottomOffset = $('data_controls').measure('height') + 3;
+ $("nominatim-suggestions").setStyle({
+ bottom: (document.viewport.getHeight() - $('data_controls').cumulativeOffset().top + 3).toString() + 'px'
+ }).show();
$("nominatim-suggestions-list").select("li:first-child")[0].addClassName('current');
} else {
$("nominatim-suggestions").hide();