Module:Infobox: Difference between revisions

Ganaram inukshuk (talk | contribs)
Undo revision 167742 by Ganaram inukshuk (talk)
Tag: Undo
Ganaram inukshuk (talk | contribs)
have original build function use new infobox function
Line 1: Line 1:
local getArgs = require("Module:Arguments").getArgs
local getArgs = require("Module:Arguments").getArgs
local p = {}
local p = {}
-- TODO:
-- Transfer functionality to new functions (in-progress)
-- Once done, convert old functions into wrapper functions (note that only
-- infobox mos needs the 8-link form, so the 8-link function can be removed and
-- infobox mos updated to use new "main" function)


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 205: Line 199:
-- Original function; kept for supporting old navboxes
-- Original function; kept for supporting old navboxes
function p.build(title, entries, prev_link, next_link)
function p.build(title, entries, prev_link, next_link)
local s = "<div style=\""
local args = {
.. "border: 1px solid #999; "
["Adjacent Links"] = { (prev_link or ""), (next_link or "") },
.. "margin: 0; "
["Title"] = title,
.. "margin-left: 1em; "
["Rows"] = entries,
.. "margin-bottom: 0.5em; "
}
.. "padding: 0.5em; "
 
.. "background-color: #f0f0f0; "
return p._infobox(args)
.. "min-width: 15em; "
.. "float: right; "
.. "max-width: 100%; "
.. "overflow: auto; "
.. "\">\n"
.. "{| width=\"100%\" style=\"border-collapse: collapse;\"\n"
.. "|+ style=\"font-size: 105%; font-weight: bold; text-align: center;\" | "
local has_adjacent = (prev_link and #prev_link > 0) or (next_link and #next_link > 0)
if has_adjacent then
s = s
.. "<table style=\"width: 100%; margin: 0;\"><tr>"
.. "<td style=\"width: 15%; text-align: left; white-space: nowrap; font-size: 0.75em;\">"
.. (prev_link or "")
.. "</td>"
.. "<td style=\"width: 70%; padding-left: 1em; padding-right: 1em; text-align: center;\">"
.. title
.. "</td>"
.. "<td style=\"width: 15%; text-align: right; white-space: nowrap; font-size: 0.75em;\">"
.. (next_link or "")
.. "</td>"
.. "</tr></table>"
else
s = s .. title
end
s = s .. "\n"
for _, entry in ipairs(entries) do
if #entry > 1 then
local caption = entry[1]
local text = entry[2]
s = s
.. "|-\n"
.. "| style=\"text-align: right; padding-right: 0.25em;\" | "
.. caption
.. "\n"
.. "| style=\"background-color: white; padding-left: 0.25em; font-weight: bold;\" | "
.. text
.. "\n"
elseif #entry == 1 then
local text = entry[1]
s = s .. "|-\n" .. "| colspan=\"2\" style=\"text-align: center;\" | ".. text .. "\n"
end
end
s = s .. "|}</div>"
return s
end
end