page.replace_html :sidebar_content, :partial => 'start'
page << <<EOJ
var browseBoxControl;
- var browseActive;
var browseMode = "auto";
var browseBounds;
var browseFeatureList;
OpenLayers.Feature.Vector.style['default'].cursor = "pointer";
function startBrowse() {
- browseActive = true;
+ map.dataLayer.active = true;
openSidebar({ onclose: stopBrowse });
}
function stopBrowse() {
- if (browseActive) {
- browseActive = false;
+ if (map.dataLayer.active) {
+ map.dataLayer.active = false;
if (browseSelectControl) {
browseSelectControl.destroy();
}
function startDrag() {
- $("browse_select_box").innerHTML='#{I18n.t('browse.start_rjs.drag_a_box')}';
+ $("browse_select_box").innerHTML="#{I18n.t('browse.start_rjs.drag_a_box')}";
browseBoxControl.activate();
}
function customDataLoader(request) {
- if (browseActive) {
+ if (this.map.dataLayer.active) {
var doc = request.responseXML;
if (!doc || !doc.documentElement) {
}
function dataLoaded() {
- if (browseActive) {
+ if (this.map.dataLayer.active) {
clearStatus();
-
+
browseObjectList = document.createElement("div")
var heading = document.createElement("p");
// Link, for viewing in the tab
var link = document.createElement("a");
link.href = "/browse/" + type + "/" + feature.osm_id;
- var name = feature.attributes.name || feature.osm_id;
+ var name = featureName(feature);
link.appendChild(document.createTextNode(name));
link.feature = feature;
link.onclick = OpenLayers.Function.bind(viewFeatureLink, link);
}
}
+ function featureName(feature) {
+ if (feature.attributes['name:#{I18n.locale}']) {
+ return feature.attributes['name:#{I18n.locale}'];
+ } else if (feature.attributes.name) {
+ return feature.attributes.name;
+ } else {
+ return feature.osm_id;
+ }
+ }
+
function featureNameSelect(feature) {
- if (feature.attributes.name) {
+ if (feature.attributes['name:#{I18n.locale}']) {
+ return feature.attributes['name:#{I18n.locale}'];
+ } else if (feature.attributes.name) {
return feature.attributes.name;
} else if (featureType(feature) == "node") {
return i18n("#{I18n.t('browse.start_rjs.object_list.selected.type.node')}", { id: feature.osm_id });
}
function featureNameHistory(feature) {
- if (feature.attributes.name) {
+ if (feature.attributes['name:#{I18n.locale}']) {
+ return feature.attributes['name:#{I18n.locale}'];
+ } else if (feature.attributes.name) {
return feature.attributes.name;
} else if (featureType(feature) == "node") {
return i18n("#{I18n.t('browse.start_rjs.object_list.history.type.node')}", { id: feature.osm_id });