Module:Sandbox/ChaoticShadow/InfoboxBuilder: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 241: | Line 241: | ||
end |
end |
||
--- |
--- Determines if the row should be shown based of a list of param names |
||
-- @param param_names { param_name, ... } |
-- @param param_names { param_name, ... } |
||
-- param_name string |
-- param_name string |
||
-- The param name |
-- The param name |
||
-- @return |
-- @return should_show boolean |
||
⚫ | |||
⚫ | |||
if param_names and #param_names > 0 then |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
end |
end |
||
return true |
|||
end |
end |
||
--- Adds a header |
--- Adds a header |
||
Line 269: | Line 274: | ||
-- css {...} or nil |
-- css {...} or nil |
||
-- The css of the cell in table form |
-- The css of the cell in table form |
||
-- @param options { hideIfEmpty } |
|||
-- hideIfEmpty { param_name, ... } |
|||
⚫ | |||
-- The param_name that will be used to check if corresponding |
|||
⚫ | |||
-- @return self |
-- @return self |
||
-- The current object |
-- The current object |
||
function InfoboxBuilder:addHeader(arg) |
function InfoboxBuilder:addHeader(arg, options) |
||
if options then |
|||
⚫ | |||
return self |
|||
end |
|||
end |
|||
self:addSpacer() |
self:addSpacer() |
||
Line 306: | Line 322: | ||
--- Adds an image, or switchable images |
--- Adds an image, or switchable images |
||
-- @param |
-- @param cols { { tag, content, title }, ... } |
||
-- tag "artd" or "td" |
-- tag "artd" or "td" |
||
-- Whether or not an it is based off a parameter |
-- Whether or not an it is based off a parameter |
||
Line 313: | Line 329: | ||
-- title string or nil |
-- title string or nil |
||
-- The title, if using switchable images |
-- The title, if using switchable images |
||
-- @param options { hideIfEmpty } |
|||
-- hideIfEmpty { param_name, ... } |
|||
-- param_name string |
|||
-- The param_name that will be used to check if corresponding |
|||
-- content is nil |
|||
-- @return self |
-- @return self |
||
-- The current object |
-- The current object |
||
function InfoboxBuilder:addImage( |
function InfoboxBuilder:addImage(cols, options) |
||
if options then |
|||
local argt = ... |
|||
if not self:shouldShow(options.hideIfEmpty) then |
|||
return self |
|||
end |
|||
end |
|||
local _cell = self.infobox:tag('tr'):tag('td'):css('text-align', 'center') |
local _cell = self.infobox:tag('tr'):tag('td'):css('text-align', 'center') |
||
Line 322: | Line 347: | ||
local actual_args = {} |
local actual_args = {} |
||
for _,v in ipairs( |
for _,v in ipairs(cols) do |
||
local c = v.content |
local c = v.content |
||
if v.tag == 'argtd' then |
if v.tag == 'argtd' then |
||
Line 380: | Line 405: | ||
function InfoboxBuilder:addRow(cols, options) |
function InfoboxBuilder:addRow(cols, options) |
||
if options then |
if options then |
||
if |
if not self:shouldShow(options.hideIfEmpty) then |
||
return self |
|||
⚫ | |||
end |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||