Module:Sandbox/User:The Gaffer/Modules/Infobox Switch: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
The Gaffer (talk | contribs) No edit summary |
The Gaffer (talk | contribs) (Undo revision 18699 by The Gaffer (talk)) Tag: Undo |
||
Line 6: | Line 6: | ||
-- Module access point for infobox switch |
-- Module access point for infobox switch |
||
p._infobox_switch = function(args) |
p._infobox_switch = function(args) |
||
-- Prepare content list from arguments |
|||
local contents = {} |
|||
local i = 1 |
|||
while args['item'..i] do |
|||
table.insert(contents, { text = args['text'..i] or ('Item '..i), |
|||
table.insert(contents, { |
|||
content = '\n' .. args['item'..i], |
|||
id = args['switch_id'..i] or i}) |
|||
⚫ | |||
id = args['switch_id' .. i] or i |
|||
⚫ | |||
}) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
:addClass('infobox-buttons') |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
:done() |
|||
⚫ | |||
⚫ | |||
-- Create the tbody for the main content area of the infobox |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
:done() |
|||
end |
|||
⚫ | |||
local default_content = contents[1] -- Assuming default index is 1 |
local default_content = contents[1] -- Assuming default index is 1 |
||
if default_content then |
if default_content then |
||
Line 50: | Line 46: | ||
row:done() |
row:done() |
||
end |
end |
||
⚫ | |||
-- Create the hidden resources section that contains all switchable content |
-- Create the hidden resources section that contains all switchable content |
||
local resources_div = structure:tag('div') |
local resources_div = structure:tag('div') |
||
Line 68: | Line 64: | ||
end |
end |
||
-- Return the complete HTML structure |
-- Return the complete HTML structure |
||
return tostring(structure) |
return tostring(structure) |
||
end |
end |
||
-- Public function to be called by templates |
|||
p.infobox_switch = function(frame) |
p.infobox_switch = function(frame) |
||
⚫ | |||
-- Directly return the raw HTML output |
|||
return frame:callParserFunction('tag', { 'div', html_output, content = 'html' }) |
|||
⚫ | |||
end |
end |
||
return p |
return p |