- Reports: the menu item shows how many reports are still open (not archived), for everyone with reports.view. The reports live in the bot, so the count sits in settings.reports_nav_cache and is fetched at most every 2 minutes with a short timeout (reports_nav_open()); the reports page refreshes it right away, also after archiving. reports_api_request() takes a timeout. - Moderation: the menu count now matches the "Freigabe" tab - waiting items plus reported items that are still visible (moderation_open_counts(), internal calendar entries only for calendar.leadership), with a title like "2 warten auf Freigabe, 1 gemeldet". - Warehouse and Lumishop cards get an info bubble on mouse hover or keyboard focus (not on touch): large image, category, stock, Lumishop price and the last movement in the warehouse; price, availability, amount in open requests and whether the own Lumipunkte suffice in the shop. Weapons and armour with the same name in the gear catalogue also show grade, level and base stats. Content is rendered as a <template> per card (includes/item_tooltip.php), shown and placed by assets/js/item-tooltip.js; the old native title on warehouse cards is gone. - Patch notes and README updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
3.3 KiB
JavaScript
93 lines
3.3 KiB
JavaScript
/**
|
|
* Info-Blase zu Gegenstaenden (Lagerhaus, Lumishop): Karten mit [data-item-tip] tragen ihren Inhalt als
|
|
* <template class="item-tip-template"> (includes/item_tooltip.php). Beim Draufzeigen mit der Maus bzw.
|
|
* beim Ansteuern mit der Tastatur erscheint er neben der Karte - rechts, sonst links, sonst darunter -
|
|
* und immer ganz im Fenster. Auf Touch-Geraeten nicht: dort ist Tippen schon "oeffnen" bzw. "beantragen".
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var tip = null;
|
|
var current = null;
|
|
|
|
function hide() {
|
|
if (tip) tip.hidden = true;
|
|
current = null;
|
|
}
|
|
|
|
function place(card) {
|
|
var box = card.getBoundingClientRect();
|
|
var gap = 10;
|
|
var margin = 8;
|
|
var viewWidth = document.documentElement.clientWidth;
|
|
var viewHeight = window.innerHeight;
|
|
if (box.bottom < 0 || box.top > viewHeight) {
|
|
hide();
|
|
return;
|
|
}
|
|
tip.style.left = '0px';
|
|
tip.style.top = '0px';
|
|
var width = tip.offsetWidth;
|
|
var height = tip.offsetHeight;
|
|
var left;
|
|
var top = box.top;
|
|
if (box.right + gap + width <= viewWidth - margin) {
|
|
left = box.right + gap;
|
|
} else if (box.left - gap - width >= margin) {
|
|
left = box.left - gap - width;
|
|
} else {
|
|
left = box.left + box.width / 2 - width / 2;
|
|
top = box.bottom + gap;
|
|
if (top + height > viewHeight - margin) top = box.top - gap - height;
|
|
}
|
|
tip.style.left = Math.round(Math.min(Math.max(margin, left), viewWidth - width - margin)) + 'px';
|
|
tip.style.top = Math.round(Math.min(Math.max(margin, top), viewHeight - height - margin)) + 'px';
|
|
}
|
|
|
|
function show(card) {
|
|
var template = card.querySelector('template.item-tip-template');
|
|
if (!template) {
|
|
hide();
|
|
return;
|
|
}
|
|
if (!tip) {
|
|
tip = document.createElement('div');
|
|
tip.className = 'item-tip';
|
|
tip.setAttribute('role', 'tooltip');
|
|
document.body.appendChild(tip);
|
|
}
|
|
if (current !== card) {
|
|
tip.textContent = '';
|
|
tip.appendChild(template.content.cloneNode(true));
|
|
current = card;
|
|
}
|
|
tip.hidden = false;
|
|
place(card);
|
|
}
|
|
|
|
document.addEventListener('pointerover', function (event) {
|
|
if (event.pointerType !== 'mouse') return;
|
|
var card = event.target.closest('[data-item-tip]');
|
|
if (card === current) return;
|
|
if (card && !card.hidden) show(card);
|
|
else hide();
|
|
});
|
|
document.documentElement.addEventListener('mouseleave', hide);
|
|
document.addEventListener('focusin', function (event) {
|
|
var card = event.target.closest('[data-item-tip]');
|
|
if (card) show(card);
|
|
else hide();
|
|
});
|
|
document.addEventListener('keydown', function (event) {
|
|
if (event.key === 'Escape') hide();
|
|
});
|
|
// Beim Scrollen mitwandern; verschwindet die Karte aus dem Bild, verschwindet auch die Blase
|
|
window.addEventListener('scroll', function () {
|
|
if (current) place(current);
|
|
}, true);
|
|
window.addEventListener('resize', hide);
|
|
// Dialoge (Einlagern, Beantragen ...) gehen vor
|
|
document.addEventListener('click', function (event) {
|
|
if (event.target.closest('[data-open-modal], .shop-buy')) hide();
|
|
});
|
|
})();
|