Module:Tt: Difference between revisions

ReisuDesign (talk | contribs)
No edit summary
ReisuDesign (talk | contribs)
No edit summary
Line 27: Line 27:
local toggle = out:tag('span')
local toggle = out:tag('span')
:addClass('custom-tt-wrapper')
:addClass('custom-tt-wrapper')
:addClass('toggle-tooltip')
:addClass('mw-collapsible')
:addClass('mw-collapsible')
:addClass('mw-collapsed')
:addClass('mw-collapsed')
Line 36: Line 35:
end
end


-- Make the text clickable if a link is provided,
-- If a link is supplied, make the visible text a link.
-- or if the text already contains a wiki link.
if (args.link and args.link ~= '') or (text:find('%[%[') and text:find('%]%]')) then
if (args.link and args.link ~= '') or (text:find('%[%[') and text:find('%]%]')) then
local link = tostring(args.link or '')
local link = tostring(args.link or '')


if link == '1' then
if link == '1' then
toggle:wikitext(
toggle:wikitext('[[' .. text .. ']] ')
'[[', text, ']]', ' '
)
elseif link ~= '' then
elseif link ~= '' then
toggle:wikitext(
toggle:wikitext('[[' .. link .. '|' .. text .. ']] ')
'[[', link, '|', text, ']]', ' '
)
else
else
toggle:wikitext(text, ' ')
toggle:wikitext(text .. ' ')
end
end


-- Add accessible text and an info icon.
local cleanText = text
local cleanText = text
:gsub('%[%[?[^|%]]+|', '')
:gsub('%[%[?[^|%]]+|', '')
Line 67: Line 60:
toggle:attr('data-tt-text', text)
toggle:attr('data-tt-text', text)


-- Toggle
-- The actual collapsible content.
toggle:tag('span')
:addClass('mw-collapsible-toggle')
:addClass('mw-collapsible-toggle-collapsed')
:addClass('custom-tt')
:wikitext(text)
:done()
 
-- Tooltip
toggle:tag('span')
toggle:tag('span')
:addClass('mw-collapsible-content')
:addClass('mw-collapsible-content')
:addClass('custom-tt')
:addClass('custom-tt')
:css('display', 'none')
:wikitext(tooltip)
:wikitext(tooltip)
:done()
:done()