Show a popup listing available editors when hovering over the edit tab

This commit is contained in:
Tom Hughes 2010-11-15 00:44:17 +00:00
parent 6c3b5aa9d4
commit 04a6c41be9
8 changed files with 154 additions and 15 deletions

View file

@ -0,0 +1,62 @@
/*
* Open a menu.
*/
function openMenu(anchor, menu) {
menu.style.display = "block";
menu.clonePosition(anchor, {
setLeft: true, setTop: true, setWidth: false, setHeight: false,
offsetLeft: 0, offsetTop: anchor.getHeight()
});
}
/*
* Callback called when the mouse enters a menu anchor.
*/
function enterMenuAnchor(event, anchor, menu, delay) {
clearTimeout(menu.timer);
if (delay > 0) {
menu.timer = setTimeout(function () { openMenu(anchor, menu) }, delay);
} else {
openMenu(event, menu);
}
}
/*
* Callback called when the mouse leaves a menu anchor.
*/
function leaveMenuAnchor(event, anchor, menu) {
var to = event.relatedTarget || event.toElement;
if (to != menu && !to.descendantOf(menu)) {
menu.style.display = "none";
}
clearTimeout(menu.timer);
}
/*
* Callback called when the mouse leaves a menu.
*/
function leaveMenu(event, anchor, menu) {
var to = event.relatedTarget || event.toElement;
if (to != anchor && !to.descendantOf(menu)) {
menu.style.display = "none";
}
clearTimeout(menu.timer);
}
/*
* Setup a menu, triggered by hovering over an anchor for a given time.
*/
function createMenu(anchorid, menuid, delay) {
var anchor = $(anchorid);
var menu = $(menuid);
anchor.onmouseover = function (event) { enterMenuAnchor(anchor, anchor, menu, delay) };
anchor.onmouseout = function (event) { leaveMenuAnchor(event, anchor, menu) };
menu.onmouseout = function (event) { leaveMenu(event, anchor, menu) };
}

View file

@ -1,4 +1,3 @@
/*
* Called as the user scrolls/zooms around to aniplate hrefs of the
* view tab and various other links
@ -69,15 +68,54 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj
}
}
node = $("potlatchanchor");
if (node) {
var args = new Object();
args.editor = "potlatch";
args.lat = lat;
args.lon = lon;
args.zoom = zoom;
if (objtype && objid) {
args[objtype] = objid;
}
node.href = setArgs("/edit", args);
}
node = $("potlatch2anchor");
if (node) {
var args = new Object();
args.editor = "potlatch2";
args.lat = lat;
args.lon = lon;
args.zoom = zoom;
if (objtype && objid) {
args[objtype] = objid;
}
node.href = setArgs("/edit", args);
}
node = $("josmanchor");
if (node) {
var args = new Object();
args.editor = "josm";
args.lat = lat;
args.lon = lon;
args.zoom = zoom;
if (objtype && objid) {
args[objtype] = objid;
}
node.href = setArgs("/edit", args);
}
node = $("historyanchor");
if (node) {
if (zoom >= 11) {
var args = new Object();
//set bbox param from 'extents' object
if (typeof minlon == "number" &&
typeof minlat == "number" &&
typeof maxlon == "number" &&
typeof maxlat == "number") {
typeof minlat == "number" &&
typeof maxlon == "number" &&
typeof maxlat == "number") {
minlon = Math.round(minlon * decimals) / decimals;
minlat = Math.round(minlat * decimals) / decimals;
@ -225,24 +263,24 @@ function makeShortCode(lat, lon, zoom) {
// z18 so we don't need to care for now.
var c1 = 0, c2 = 0;
for (var i = 31; i > 16; --i) {
c1 = (c1 << 1) | ((x >> i) & 1);
c1 = (c1 << 1) | ((y >> i) & 1);
c1 = (c1 << 1) | ((x >> i) & 1);
c1 = (c1 << 1) | ((y >> i) & 1);
}
for (var i = 16; i > 1; --i) {
c2 = (c2 << 1) | ((x >> i) & 1);
c2 = (c2 << 1) | ((y >> i) & 1);
c2 = (c2 << 1) | ((x >> i) & 1);
c2 = (c2 << 1) | ((y >> i) & 1);
}
var str = "";
for (var i = 0; i < Math.ceil((zoom + 8) / 3.0) && i < 5; ++i) {
digit = (c1 >> (24 - 6 * i)) & 0x3f;
str += char_array.charAt(digit);
digit = (c1 >> (24 - 6 * i)) & 0x3f;
str += char_array.charAt(digit);
}
for (var i = 5; i < Math.ceil((zoom + 8) / 3.0); ++i) {
digit = (c2 >> (24 - 6 * (i - 5))) & 0x3f;
str += char_array.charAt(digit);
digit = (c2 >> (24 - 6 * (i - 5))) & 0x3f;
str += char_array.charAt(digit);
}
for (var i = 0; i < ((zoom + 8) % 3); ++i) {
str += "-";
str += "-";
}
return str;
}