Module:Sandbox/LVL: Difference between revisions

Jump to navigation Jump to search
LVL (talk | contribs)
Tooltip fix
LVL (talk | contribs)
No edit summary
Line 632: Line 632:
end)
end)


-- Iterate heroes
-- Iterate heroes
for _, hero_entry in ipairs(sorted_heroes) do
for _, hero_entry in ipairs(sorted_heroes) do
local hero_key = hero_entry.key
local hero_key = hero_entry.key
Line 725: Line 725:
-- Build tooltip content showing scaling info
-- Build tooltip content showing scaling info
local tooltip_lines = {}
local tooltip_lines = {}
local has_scaling = false
if type(base_value) == "number" then
if type(base_value) == "number" then
    table.insert(tooltip_lines, string.format("Base: %s", util_module.round_to_sig_fig(base_value, 3)))
    table.insert(tooltip_lines, string.format("Base: %s", util_module.round_to_sig_fig(base_value, 3)))
Line 735: Line 737:
    if tp_boon_scale and tp_boon_scale > 0 then
    if tp_boon_scale and tp_boon_scale > 0 then
        table.insert(tooltip_lines, string.format("Level: +%s per boon", tp_boon_scale))
        table.insert(tooltip_lines, string.format("Level: +%s per boon", tp_boon_scale))
        has_scaling = true
    end
    end
else
else
Line 740: Line 743:
    if level_scale and level_scale > 0 then
    if level_scale and level_scale > 0 then
        table.insert(tooltip_lines, string.format("Level: +%s per boon", level_scale))
        table.insert(tooltip_lines, string.format("Level: +%s per boon", level_scale))
        has_scaling = true
    end
    end
    if spirit_scale and spirit_scale > 0 then
    if spirit_scale and spirit_scale > 0 then
        table.insert(tooltip_lines, string.format("Spirit: +%s per point", spirit_scale))
        table.insert(tooltip_lines, string.format("Spirit: +%s per point", spirit_scale))
        if innate_spirit_scale and innate_spirit_scale > 0 then
        has_scaling = true
            table.insert(tooltip_lines, string.format("Innate Spirit: +%s per boon", innate_spirit_scale))
        end
    end
    end
end
end
Line 761: Line 763:
)
)
-- Build cell with tooltip wrapper
-- Build cell with tooltip wrapper ONLY if there is scaling
local cell_inner = string.format(
local cell_inner
    '<span class="tooltip-container">' ..
if has_scaling then
    '<span class="tooltip-trigger" tabindex="0"><span class="stat-num">%s</span></span>' ..
    cell_inner = string.format(
    '<span class="tooltip-content" role="tooltip">%s</span>' ..
        '<span class="tooltip-container">' ..
    '</span>',
        '<span class="tooltip-trigger" tabindex="0"><span class="stat-num">%s</span></span>' ..
    stat_value,
        '<span class="tooltip-content" role="tooltip">%s</span>' ..
    tooltip_text
        '</span>',
)
        stat_value,
        tooltip_text
    )
else
    cell_inner = string.format('<span class="stat-num">%s</span>', stat_value)
end
-- Add it to the row with data attributes and span wrapper
-- Add it to the row with data attributes and span wrapper