mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-29 07:06:04 +02:00
Non-overwriting hash, add hash in select mode. Needs code for dealing
with hash.
This commit is contained in:
@@ -47,6 +47,11 @@ iD.modes.Select = function (entity) {
|
||||
behavior(surface);
|
||||
});
|
||||
|
||||
var q = iD.util.stringQs(location.hash.substring(1));
|
||||
location.hash = '#' + iD.util.qsString(_.assign(q, {
|
||||
id: entity.id
|
||||
}), true);
|
||||
|
||||
d3.select('.inspector-wrap')
|
||||
.style('display', 'block')
|
||||
.style('opacity', 1)
|
||||
@@ -149,6 +154,9 @@ iD.modes.Select = function (entity) {
|
||||
behavior.off(surface);
|
||||
});
|
||||
|
||||
var q = iD.util.stringQs(location.hash.substring(1));
|
||||
location.hash = '#' + iD.util.qsString(_.omit(q, 'id'), true);
|
||||
|
||||
surface.on("click.select", null);
|
||||
mode.map.keybinding().on('⌫.select', null);
|
||||
mode.history.on('change.entity-undone', null);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
iD.Hash = function() {
|
||||
var hash = { hadHash: false },
|
||||
s0, // cached location.hash
|
||||
s0 = null, // cached location.hash
|
||||
lat = 90 - 1e-8, // allowable latitude range
|
||||
map;
|
||||
|
||||
@@ -20,9 +20,12 @@ iD.Hash = function() {
|
||||
var center = map.center(),
|
||||
zoom = map.zoom(),
|
||||
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
|
||||
return '#?map=' + zoom.toFixed(2) +
|
||||
'/' + center[1].toFixed(precision) +
|
||||
'/' + center[0].toFixed(precision);
|
||||
var q = iD.util.stringQs(location.hash.substring(1));
|
||||
return '#' + iD.util.qsString(_.assign(q, {
|
||||
map: zoom.toFixed(2) +
|
||||
'/' + center[1].toFixed(precision) +
|
||||
'/' + center[0].toFixed(precision)
|
||||
}), true);
|
||||
};
|
||||
|
||||
var move = _.throttle(function() {
|
||||
@@ -32,7 +35,7 @@ iD.Hash = function() {
|
||||
|
||||
function hashchange() {
|
||||
if (location.hash === s0) return; // ignore spurious hashchange events
|
||||
if (parser(map, (s0 = location.hash).substring(2))) {
|
||||
if (parser(map, (s0 = location.hash).substring(1))) {
|
||||
move(); // replace bogus hash
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -30,9 +30,10 @@ iD.util.stringQs = function(str) {
|
||||
}, {});
|
||||
};
|
||||
|
||||
iD.util.qsString = function(obj) {
|
||||
iD.util.qsString = function(obj, noencode) {
|
||||
return Object.keys(obj).sort().map(function(key) {
|
||||
return encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]);
|
||||
return encodeURIComponent(key) + '=' + (
|
||||
noencode ? obj[key] : encodeURIComponent(obj[key]));
|
||||
}).join('&');
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user