Module:Infobox: Difference between revisions
Add classes to config
InvalidCards (talk | contribs) (let's see how this goes) |
(Add classes to config) |
||
Line 6:
local editbutton = require('Module:Edit button')
local smwutils = require('Module:SMW Utils')
local episode_classes = {▼
['hopeport'] = 'hopeport',▼
['hopeforest'] = 'hopeforest',▼
['mine of mantuban'] = 'mantuban',▼
['crenopolis'] = 'crenopolis',▼
}▼
local Infobox = {}
Line 30 ⟶ 23:
args_smw = {}, -- parameters parsed for smw
infobox_name = nil, -- template name
classes = {}, -- list of classes to add, using the default_version
param_names = {}, -- ordered param list
params = {}, -- param definitions
Line 214 ⟶ 208:
-- config: table containing configuration parameters
---- infobox_name = mandatory unique identifier for this infobox, used for css
----
--]]
function Infobox:config(config)
Line 222 ⟶ 216:
elseif k == 'max_buttons' then
self.max_buttons = tonumber(v)
elseif k == 'class' then
if type(v) == 'string' then
self.classes = {v}
elseif type(v) == 'table' then
self.classes = v
end
end
end
Line 408:
:addClass('infobox')
:addClass('infobox-'..self.infobox_name)
for _, class in ipairs(self.classes) do
self.rtable:addClass('infobox-'..mw.ustring.gsub(self:get_param(class, self.default_version)), '%s', '_')
end
-- Create the switch datatable if multiple versions
if self.versions > 1 then
Line 559 ⟶ 562:
end
▲local episode_classes = {
▲ ['hopeport'] = 'hopeport',
▲ ['hopeforest'] = 'hopeforest',
▲ ['mine of mantuban'] = 'mantuban',
▲ ['crenopolis'] = 'crenopolis',
▲}
function Infobox:set_episode_class(ep_param)
ep_param = string.lower(ep_param or '')
|