Module:Infobox: Difference between revisions
Added skeleton code for invokable infobox; should not affect existing build functions |
No edit summary |
||
| Line 6: | Line 6: | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- Infobox header with adjacent links | |||
-- Adjacent links are placed on the sides of the title, with options for 0, 2, | |||
-- or 8 links. | |||
function p.infobox_header(title, adjacent_links) | function p.infobox_header(title, adjacent_links) | ||
local header = '' | |||
if adjacent_links == nil then | |||
header = header .. title | |||
header = header .. '\n' | |||
elseif #adjacent_links == 2 then | |||
local prev_link = adjacent_links[1] | |||
local next_link = adjacent_links[2] | |||
header = header | |||
.. '<table style="width: 100%; margin: 0;">\n' | |||
.. '<tr>\n' | |||
.. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: 0.75em;">\n' .. (prev_link or '') .. '</td>\n' | |||
.. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center;">\n' .. title .. '</td>\n' | |||
.. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: 0.75em;">\n' .. (next_link or '') .. '</td>\n' | |||
.. '</tr>\n' | |||
.. '</table>' | |||
elseif #adjacent_links == 8 then | |||
-- First row | |||
header = header | |||
.. '<table style="width: 100%; margin: 0;">\n' | |||
.. '<tr>\n' -- First row | |||
.. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: 0.75em;">\n' .. (adjacent_links[1] or '') .. '</td>\n' | |||
.. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center;">\n' .. (adjacent_links[2] or '') .. '</td>\n' | |||
.. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: 0.75em;">\n' .. (adjacent_links[3] or '') .. '</td>\n' | |||
.. '</tr>\n' | |||
.. '<tr>\n' -- Second row | |||
.. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: 0.75em;">\n' .. (adjacent_links[4] or '') .. '</td>\n' | |||
.. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center;">\n' .. title .. '</td>\n' | |||
.. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: 0.75em;">\n' .. (adjacent_links[5] or '') .. '</td>\n' | |||
.. '</tr>\n' | |||
.. '<tr>\n' -- Third row | |||
.. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: 0.75em;">\n' .. (adjacent_links[6] or '') .. '</td>\n' | |||
.. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center;">\n' .. (adjacent_links[7] or '') .. '</td>\n' | |||
.. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: 0.75em;">\n' .. (adjacent_links[8] or '') .. '</td>\n' | |||
.. '</tr>\n' | |||
-- End | |||
.. '</table>' | |||
else | |||
header = title | |||
end | |||
return header | |||
end | end | ||
-- Row of an infobox | |||
-- Infobox is set up as a Mediawiki table with two cols. | |||
function p.infobox_row(row_content) | function p.infobox_row(row_content) | ||
| Line 21: | Line 67: | ||
function p._infobox(args) | function p._infobox(args) | ||
-- Start of infobox; outer div and start of table | |||
local s = '<div style=' | |||
.. 'border: 1px solid #999; ' | |||
.. 'margin: 0; ' | |||
.. 'margin-left: 1em; ' | |||
.. 'margin-bottom: 0.5em; ' | |||
.. 'padding: 0.5em; ' | |||
.. 'background-color: #f0f0f0; ' | |||
.. 'min-width: 15em; ' | |||
.. 'float: right; ' | |||
.. 'max-width: 100%; ' | |||
.. 'overflow: auto; ' | |||
.. '>\n' | |||
-- Infobox table, starting with table | |||
.. '{| width="100%" style="border-collapse: collapse;"\n' | |||
.. '|+ style="font-size: 105%; font-weight: bold; text-align: center;" | ' .. p.infobox_header(title, adjacent_links) .. '\n' | |||
-- For loop for populating entries | |||
-- wip | |||
return s | |||
end | end | ||