Module:Tt/Draft: Difference between revisions
No edit summary |
No edit summary |
||
| (3 intermediate revisions 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 = | local tooltip = args[2] | ||
local header = lib.isNotEmpty(args.header) and | local header = lib.isNotEmpty(args.header) and args.header or nil | ||
local out = mw.html.create() | local out = mw.html.create() | ||
| Line 31: | Line 31: | ||
return p._main({ linkTo, args[2], header = args.header }, {nohover = true}) -- external tt for collapsible for the separated clickable | return p._main({ linkTo, args[2], header = args.header }, {nohover = true}) -- external tt for collapsible for the separated clickable | ||
end | end | ||
-- Build toggle tooltip | -- Build toggle tooltip | ||
local toggle = out:tag('span'):addClass('custom-tt-wrapper | local toggle = out:tag('span'):addClass('custom-tt-wrapper toggle-tooltip') | ||
-- Optional toggleable text but plain text must be there for gadget | -- Optional toggleable text but plain text must be there for gadget | ||
| Line 93: | Line 75: | ||
local full = tx | local full = tx | ||
local result = tx | local result = tx | ||
for display in string.gmatch(full, | |||
for | '<span[^>]*class="[^"]*custom%-tt%-wrapper[^"]*"[^>]*>' .. | ||
'<span[^>]*class="[^"]*mw%-collapsible%-toggle[^"]*"[^>]*>(.-)</span>' .. | |||
'<span[^>]*class="[^"]*mw%-collapsible%-content[^"]*"[^>]*>.-</span></span>' | |||
) do | |||
local escDisplay = display:gsub("([^%w])", "%%%1") | local escDisplay = display:gsub("([^%w])", "%%%1") | ||
search_str = '<span[^>] | local search_str = | ||
'<span[^>]*class="[^"]*custom%-tt%-wrapper[^"]*"[^>]*>' .. | |||
'<span[^>]*class="[^"]*mw%-collapsible%-toggle[^"]*"[^>]*>' .. escDisplay .. '</span>' .. | |||
'<span[^>]*class="[^"]*mw%-collapsible%-content[^"]*"[^>]*>.-</span></span>' | |||
result = result:gsub(search_str, display) | result = result:gsub(search_str, display) | ||
end | end | ||