Module:Tt: Difference between revisions

From BlazBlue Wiki
(convert tooltip template to a lua module)
 
m (nest spans instead)
 
Line 15: Line 15:
parts = {
parts = {
'<div class="tooltip" style="',tooltip_style,'">',
'<span class="tooltip" style="',tooltip_style,'">',
text,
text,
'<span class="tooltiptext" style="text-align:',align,'">',
'<span class="tooltiptext" style="text-align:',align,'">',
tooltip,
tooltip,
'</span></div>'
'</span></span>'
}
}
mw.log(concatvalues(parts,""))
mw.log(concatvalues(parts,""))

Latest revision as of 00:47, 6 August 2019

Documentation for this module may be created at Module:Tt/doc

local p = {}
local cargo = mw.ext.cargo

function p.Main( frame )
	text = frame.args[1] or ''
	tooltip = frame.args[2] or ''
	line = frame.args['line'] or ''
	align = frame.args['align'] or 'default'
	
	if line == 'false' then
		tooltip_style = 'border-bottom: 0;'
	else
		tooltip_style = ''
	end
	
	parts = {
		'<span class="tooltip" style="',tooltip_style,'">',
		text,
		'<span class="tooltiptext" style="text-align:',align,'">',
		tooltip,
		'</span></span>'
	}
	mw.log(concatvalues(parts,""))
	return concatvalues(parts,"")
end

-- concat all the strings in table s together with the given delimiter
function concatvalues(s,delimiter)
    local t = { }
    for k,v in ipairs(s) do
        t[#t+1] = tostring(v)
    end
    return table.concat(t,delimiter)
end

return p