menu: guard against duplicate (add data-action to native button)

This commit is contained in:
Hermes committed 2026-08-09 13:23:56 +02:00
1 parent 0e6cc6f025
commit e18c49cc69
1 file changed
+5 -2
+5 -2
View File
@@ -394,8 +394,10 @@
var menuSubscribed = false;
var menuInterval = null;
function addMenuButton() {
// Use Lampa's native menu API (adds to .menu__list:eq(0) and wires hover:enter).
Lampa.Menu.addButton(
// Guard: only one copy (addButton does not set data-action, so we add it ourselves).
if ($('[data-action="' + PLUGIN.menu_action + '"]').length) return;
// Use Lampa's native menu API (adds to .menu__list and wires hover:enter).
var el = Lampa.Menu.addButton(
'<svg class="sprite-folder"><use xlink:href="#sprite-folder"></use></svg>',
t(PLUGIN.title),
function () {
@@ -407,6 +409,7 @@
});
}
);
if (el && el.attr) el.attr('data-action', PLUGIN.menu_action);
}
function start() {
if (menuSubscribed) return;