OpenLayers.Feature.Vector.style['default'].strokeWidth = 3;
OpenLayers.Feature.Vector.style['default'].cursor = "pointer";
-function startBrowse() {
+function startBrowse(sidebarHtml) {
map.dataLayer.active = true;
- $("#sidebar_title").html("<%=j t 'browse.start_rjs.data_frame_title' %>");
- $("#sidebar_content").html("<%=j render :partial => "sidebar" %>");
+ $("#sidebar_title").html(I18n.t('browse.start_rjs.data_frame_title'));
+ $("#sidebar_content").html(sidebarHtml);
openSidebar({ onclose: stopBrowse });
$("#browse_select_box").click(startDrag);
- $("#browse_hide_areas_box").html("<%=j t 'browse.start_rjs.hide_areas' %>");
+ $("#browse_hide_areas_box").html(I18n.t('browse.start_rjs.hide_areas'));
$("#browse_hide_areas_box").show();
$("#browse_hide_areas_box").click(hideAreas);
}
if (map.getZoom() >= 15) {
useMap(false);
} else {
- setStatus("<%=j t 'browse.start_rjs.zoom_or_select' %>");
+ setStatus(I18n.t('browse.start_rjs.zoom_or_select'));
}
}
}
}
function startDrag() {
- $("#browse_select_box").html("<%=j t 'browse.start_rjs.drag_a_box' %>");
+ $("#browse_select_box").html(I18n.t('browse.start_rjs.drag_a_box'));
browseBoxControl.activate();
}
function hideAreas() {
- $("#browse_hide_areas_box").html("<%=j t 'browse.start_rjs.show_areas' %>");
+ $("#browse_hide_areas_box").html(I18n.t('browse.start_rjs.show_areas'));
$("#browse_hide_areas_box").show();
$("#browse_hide_areas_box").click(showAreas);
}
function showAreas() {
- $("#browse_hide_areas_box").html("<%=j t 'browse.start_rjs.hide_areas' %>");
+ $("#browse_hide_areas_box").html(I18n.t('browse.start_rjs.hide_areas'));
$("#browse_hide_areas_box").show();
$("#browse_hide_areas_box").click(hideAreas);
browseMode = "manual";
- $("#browse_select_box").html("<%=j t 'browse.start_rjs.manually_select' %>");
+ $("#browse_select_box").html(I18n.t('browse.start_rjs.manually_select'));
$("#browse_select_view").show();
}
var input = document.createElement("input");
input.type = "submit";
- input.value = "<%=j t 'browse.start_rjs.load_data' %>";
+ input.value = I18n.t('browse.start_rjs.load_data');
input.onclick = callback;
div.appendChild(input);
var projected = bounds.clone().transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));
var size = projected.getWidth() * projected.getHeight();
- if (size > <%= MAX_REQUEST_AREA %>) {
- setStatus(I18n.t("browse.start_rjs.unable_to_load_size", { max_bbox_size: <%= MAX_REQUEST_AREA %>, bbox_size: size }));
+ if (size > OSM.MAX_REQUEST_AREA) {
+ setStatus(I18n.t("browse.start_rjs.unable_to_load_size", { max_bbox_size: OSM.MAX_REQUEST_AREA, bbox_size: size }));
} else {
- loadData("/api/<%= API_VERSION %>/map?bbox=" + projected.toBBOX(), reload);
+ loadData("/api/" + OSM.API_VERSION + "/map?bbox=" + projected.toBBOX(), reload);
}
}
function loadData(url, reload) {
- setStatus("<%=j t 'browse.start_rjs.loading' %>");
+ setStatus(I18n.t('browse.start_rjs.loading'));
$("#browse_content").empty();
if (browseDataLayer) browseDataLayer.destroyFeatures();
+ var maxFeatures = 2000;
+
+ /*@cc_on
+ if (navigator.appVersion < 8) {
+ maxFeatures = 100;
+ } else if (navigator.appVersion < 9) {
+ maxFeatures = 500;
+ }
+ @*/
+
browseDataLayer = new OpenLayers.Layer.Vector("Data", {
strategies: [
new OpenLayers.Strategy.Fixed()
protocol: new OpenLayers.Protocol.HTTP({
url: url,
format: new OpenLayers.Format.OSM(formatOptions),
- maxFeatures: <%= @max_features %>,
+ maxFeatures: maxFeatures,
handleRead: customDataLoader
}),
projection: new OpenLayers.Projection("EPSG:4326"),
var heading = document.createElement("p");
heading.className = "browse_heading";
- heading.appendChild(document.createTextNode("<%=j t 'browse.start_rjs.object_list.heading' %>"));
+ heading.appendChild(document.createTextNode(I18n.t('browse.start_rjs.object_list.heading')));
browseObjectList.appendChild(heading);
var list = document.createElement("ul");
var link = document.createElement("a");
link.href = this.protocol.url;
- link.appendChild(document.createTextNode("<%=j t 'browse.start_rjs.object_list.api' %>"));
+ link.appendChild(document.createTextNode(I18n.t('browse.start_rjs.object_list.api')));
browseObjectList.appendChild(link);
$("#browse_content").html(browseObjectList);
var link = document.createElement("a");
link.href = "#";
link.onclick = loadObjectList;
- link.appendChild(document.createTextNode("<%=j t 'browse.start_rjs.object_list.back' %>"));
+ link.appendChild(document.createTextNode(I18n.t('browse.start_rjs.object_list.back')));
div.appendChild(link);
var table = document.createElement("table");
var type = featureType(feature);
var link = document.createElement("a");
link.href = "/browse/" + type + "/" + feature.osm_id;
- link.appendChild(document.createTextNode("<%=j t 'browse.start_rjs.object_list.details' %>"));
+ link.appendChild(document.createTextNode(I18n.t('browse.start_rjs.object_list.details')));
td.appendChild(link);
var div = document.createElement("div");
var link = document.createElement("a");
link.href = "/browse/" + type + "/" + feature.osm_id + "/history";
- link.appendChild(document.createTextNode("<%=j t 'browse.start_rjs.show_history' %>"));
+ link.appendChild(document.createTextNode(I18n.t('browse.start_rjs.show_history')));
link.onclick = OpenLayers.Function.bind(loadHistory, {
type: type, feature: feature, link: link
});
function loadHistory() {
this.link.href = "";
- this.link.innerHTML = "<%=j t 'browse.start_rjs.wait' %>";
+ this.link.innerHTML = I18n.t('browse.start_rjs.wait');
- $.ajax("/api/<%= API_VERSION %>/" + this.type + "/" + this.feature.osm_id + "/history", {
+ $.ajax("/api/" + OSM.API_VERSION + "/" + this.type + "/" + this.feature.osm_id + "/history", {
complete: OpenLayers.Function.bind(displayHistory, this)
});
var link = document.createElement("a");
link.href = "/browse/" + this.type + "/" + this.feature.osm_id + "/history";
- link.appendChild(document.createTextNode("<%=j t 'browse.start_rjs.details' %>"));
+ link.appendChild(document.createTextNode(I18n.t('browse.start_rjs.details')));
td.appendChild(link);
var div = document.createElement("div");
var nodes = doc.getElementsByTagName(this.type);
var history = document.createElement("ul");
for (var i = nodes.length - 1; i >= 0; i--) {
- var user = nodes[i].getAttribute("user") || "<%=j t 'browse.start_rjs.private_user' %>";
+ var user = nodes[i].getAttribute("user") || I18n.t('browse.start_rjs.private_user');
var timestamp = nodes[i].getAttribute("timestamp");
var item = document.createElement("li");
item.appendChild(document.createTextNode(I18n.t("browse.start_rjs.edited_by_user_at_timestamp", { user: user, timestamp: timestamp })));
function featureTypeName(feature) {
if (featureType(feature) == "node") {
- return "<%=j t 'browse.start_rjs.object_list.type.node' %>";
+ return I18n.t('browse.start_rjs.object_list.type.node');
} else if (featureType(feature) == "way") {
- return "<%=j t 'browse.start_rjs.object_list.type.way' %>";
+ return I18n.t('browse.start_rjs.object_list.type.way');
}
}
function featureName(feature) {
- if (feature.attributes['name:<%= I18n.locale %>']) {
- return feature.attributes['name:<%= I18n.locale %>'];
+ var lang = $('html').attr('lang');
+ if (feature.attributes['name:' + lang]) {
+ return feature.attributes['name:' + lang];
} else if (feature.attributes.name) {
return feature.attributes.name;
} else {
}
function featureNameSelect(feature) {
- if (feature.attributes['name:<%= I18n.locale %>']) {
- return feature.attributes['name:<%= I18n.locale %>'];
+ var lang = $('html').attr('lang');
+ if (feature.attributes['name:' + lang]) {
+ return feature.attributes['name:' + lang];
} else if (feature.attributes.name) {
return feature.attributes.name;
} else if (featureType(feature) == "node") {
}
function featureNameHistory(feature) {
- if (feature.attributes['name:<%= I18n.locale %>']) {
- return feature.attributes['name:<%= I18n.locale %>'];
+ var lang = $('html').attr('lang');
+ if (feature.attributes['name:' + lang]) {
+ return feature.attributes['name:' + lang];
} else if (feature.attributes.name) {
return feature.attributes.name;
} else if (featureType(feature) == "node") {
$("#browse_status").hide();
}
-startBrowse();
+startBrowse("<%=j render :partial => "sidebar" %>");