- function viewFeatureLink() {
- var layer = layersById[$(this).data("feature-id")];
-
- onSelect(layer);
-
- if (locationFilter.isEnabled()) {
- map.panTo(layer.getBounds().getCenter());
- }
-
- return false;
- }
-
- function loadObjectList() {
- $("#browse_content").html(browseObjectList);
- $("#browse_content").find("a[data-feature-id]").click(viewFeatureLink);
-
- return false;
- }
-
- function onSelect(layer) {
- // Unselect previously selected feature
- if (selectedLayer) {
- selectedLayer.setStyle(selectedLayer.originalStyle);
- }
-
- // Redraw in selected style
- layer.originalStyle = layer.options;
- layer.setStyle({color: '#0000ff', weight: 8});
-
- // If the current object is the list, don't innerHTML="", since that could clear it.
- if ($("#browse_content").firstChild == browseObjectList) {
- $("#browse_content").removeChild(browseObjectList);
- } else {
- $("#browse_content").empty();
- }
-
- var feature = layer.feature;
-
- $("#browse_content").html(JST["templates/browse/feature"]({
- name: featureNameSelect(feature),
- url: "/browse/" + feature.type + "/" + feature.id,
- attributes: feature.tags
- }));
-
- $("#browse_content").find("a.browse_show_list").click(loadObjectList);
- $("#browse_content").find("a.browse_show_history").click(loadHistory);
-
- // Stash the currently drawn feature
- selectedLayer = layer;
- }
-
- function loadHistory() {
- $(this).attr("href", "").text(I18n.t('browse.start_rjs.wait'));
-
- var feature = selectedLayer.feature;
-
- $.ajax({
- url: "/api/" + OSM.API_VERSION + "/" + feature.type + "/" + feature.id + "/history",
- success: function (xml) {
- if (selectedLayer.feature != feature || $("#browse_content").firstChild == browseObjectList) {
- return;