Module:Tt/Draft: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
adding in optional headers to support extra effect (so they can be individually styled) and changing "title"-style hovertext to css. my god this cleanTT is kind of terrible |
||
| Line 38: | Line 38: | ||
:wikitext(text) | :wikitext(text) | ||
-- Optional hover text but plain text must be there for gadget | -- Optional hover text but plain text must be there for gadget | ||
if not options or not options.nohover then hover: | -- Now uses a css box, not a title | ||
if not options or not options.nohover then | |||
local content = hover: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() | hover:allDone() | ||
-- Build toggle tooltip | -- Build toggle tooltip | ||
local toggle = out:tag('span'):addClass('custom-tt-wrapper mobile-only toggle-tooltip') | 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 | ||
if not options or not options.notoggle then | if not options or not options.notoggle then | ||
| Line 59: | Line 68: | ||
:wikitext(text) | :wikitext(text) | ||
:done() | :done() | ||
toggle | local collapsibleContent = toggle | ||
:tag('span') | :tag('span') | ||
:addClass('mw-collapsible-content custom-tt') | :addClass('mw-collapsible-content custom-tt') | ||
| Line 65: | Line 74: | ||
:wikitext(tooltip) | :wikitext(tooltip) | ||
:done() | :done() | ||
if header then | |||
collapsibleContent | |||
:tag('span') | |||
:addClass('tt-header') | |||
:wikitext(header) | |||
:done() | |||
end | |||
collapsibleContent:wikitext(tooltip) | |||
collapsibleContent:done() | |||
else | else | ||
toggle:wikitext(text) | toggle:wikitext(text) | ||
| Line 77: | Line 95: | ||
local full = tx | local full = tx | ||
local result = tx | local result = tx | ||
for tooltip, display in string.gmatch(full, '<span[^>]+title="([^>]-)">(.-)</span>') do | for tooltip, display in string.gmatch(full, '<span[^>]+title="([^>]-)">(.-)</span>') do | ||
local escTooltip = tooltip:gsub("([^%w])", "%%%1") | local escTooltip = tooltip:gsub("([^%w])", "%%%1") | ||