mirror of
https://github.com/openstreetmap/openstreetmap-website.git
synced 2025-08-16 17:07:06 +00:00
Merge remote-tracking branch 'upstream/pull/6128'
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
//= require index/changeset
|
||||
//= require index/query
|
||||
//= require index/home
|
||||
//= require index/element
|
||||
//= require router
|
||||
|
||||
$(function () {
|
||||
@ -286,48 +287,6 @@ $(function () {
|
||||
return page;
|
||||
};
|
||||
|
||||
OSM.Browse = function (map, type) {
|
||||
const page = {};
|
||||
|
||||
page.pushstate = page.popstate = function (path, id, version) {
|
||||
OSM.loadSidebarContent(path, function () {
|
||||
addObject(type, id, version);
|
||||
});
|
||||
};
|
||||
|
||||
page.load = function (path, id, version) {
|
||||
addObject(type, id, version, true);
|
||||
};
|
||||
|
||||
function addObject(type, id, version, center) {
|
||||
const hashParams = OSM.parseHash();
|
||||
map.addObject({ type: type, id: parseInt(id, 10), version: version && parseInt(version, 10) }, function (bounds) {
|
||||
if (!hashParams.center && bounds.isValid() &&
|
||||
(center || !map.getBounds().contains(bounds))) {
|
||||
OSM.router.withoutMoveListener(function () {
|
||||
map.fitBounds(bounds);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
page.unload = function () {
|
||||
map.removeObject();
|
||||
};
|
||||
|
||||
return page;
|
||||
};
|
||||
|
||||
OSM.OldBrowse = function () {
|
||||
const page = {};
|
||||
|
||||
page.pushstate = page.popstate = function (path) {
|
||||
OSM.loadSidebarContent(path);
|
||||
};
|
||||
|
||||
return page;
|
||||
};
|
||||
|
||||
const history = OSM.History(map);
|
||||
|
||||
OSM.router = OSM.Router(map, {
|
||||
@ -341,12 +300,12 @@ $(function () {
|
||||
"/history": history,
|
||||
"/user/:display_name/history": history,
|
||||
"/note/:id": OSM.Note(map),
|
||||
"/node/:id(/history)": OSM.Browse(map, "node"),
|
||||
"/node/:id/history/:version": OSM.Browse(map, "node"),
|
||||
"/way/:id(/history)": OSM.Browse(map, "way"),
|
||||
"/way/:id/history/:version": OSM.OldBrowse(),
|
||||
"/relation/:id(/history)": OSM.Browse(map, "relation"),
|
||||
"/relation/:id/history/:version": OSM.OldBrowse(),
|
||||
"/node/:id(/history)": OSM.MappedElement(map, "node"),
|
||||
"/node/:id/history/:version": OSM.MappedElement(map, "node"),
|
||||
"/way/:id(/history)": OSM.MappedElement(map, "way"),
|
||||
"/way/:id/history/:version": OSM.Element(map, "way"),
|
||||
"/relation/:id(/history)": OSM.MappedElement(map, "relation"),
|
||||
"/relation/:id/history/:version": OSM.Element(map, "relation"),
|
||||
"/changeset/:id": OSM.Changeset(map),
|
||||
"/query": OSM.Query(map),
|
||||
"/account/home": OSM.Home(map)
|
||||
|
46
app/assets/javascripts/index/element.js
Normal file
46
app/assets/javascripts/index/element.js
Normal file
@ -0,0 +1,46 @@
|
||||
(function () {
|
||||
OSM.Element = function (map, type) {
|
||||
const page = {};
|
||||
|
||||
page.pushstate = page.popstate = function (path, id, version) {
|
||||
OSM.loadSidebarContent(path, function () {
|
||||
page._addObject(type, id, version);
|
||||
});
|
||||
};
|
||||
|
||||
page.load = function (path, id, version) {
|
||||
page._addObject(type, id, version, true);
|
||||
};
|
||||
|
||||
page.unload = function () {
|
||||
page._removeObject();
|
||||
};
|
||||
|
||||
page._addObject = function () {};
|
||||
page._removeObject = function () {};
|
||||
|
||||
return page;
|
||||
};
|
||||
|
||||
OSM.MappedElement = function (map, type) {
|
||||
const page = OSM.Element(map, type);
|
||||
|
||||
page._addObject = function (type, id, version, center) {
|
||||
const hashParams = OSM.parseHash();
|
||||
map.addObject({ type: type, id: parseInt(id, 10), version: version && parseInt(version, 10) }, function (bounds) {
|
||||
if (!hashParams.center && bounds.isValid() &&
|
||||
(center || !map.getBounds().contains(bounds))) {
|
||||
OSM.router.withoutMoveListener(function () {
|
||||
map.fitBounds(bounds);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
page._removeObject = function () {
|
||||
map.removeObject();
|
||||
};
|
||||
|
||||
return page;
|
||||
};
|
||||
}());
|
Reference in New Issue
Block a user