Module:Tt/Draft: Difference between revisions

Kuhlau (talk | contribs)
No edit summary
Kuhlau (talk | contribs)
No edit summary
 
(One intermediate revision by the same user not shown)
Line 19: Line 19:
function p._main(args, options)
function p._main(args, options)
local text = args[1]
local text = args[1]
local tooltip = mw.text.decode(args[2], true)
local tooltip = args[2]
local header = lib.isNotEmpty(args.header) and mw.text.decode(args.header, true) or nil
local header = lib.isNotEmpty(args.header) and args.header or nil
local out = mw.html.create()
local out = mw.html.create()
Line 32: Line 32:
end
end
-- Build hover tooltip (desktop only)
-- Build toggle tooltip
-- Now uses a css box, not a title
local toggle = out:tag('span'):addClass('custom-tt-wrapper toggle-tooltip')
local hover = out:tag('span')
hover
:addClass('text-tooltip hover-tooltip')
:wikitext(text)
-- Optional hover text but plain text must be there for gadget
if not options or not options.nohover then
local content = tooltip:tag('span'):addClass('tt-content')
if header then
content:tag('span'):addClass('tt-header'):wikitext(header)
:done()
end
content:wikitext(tooltip)
content:done()
end
hover:allDone()
-- Build toggle tooltip (mobile only)
local toggle = out:tag('span'):addClass('custom-tt-wrapper mobile-only toggle-tooltip')
-- Optional toggleable text but plain text must be there for gadget
-- Optional toggleable text but plain text must be there for gadget