Module:Navbox: Difference between revisions

enwp>Ahecht
cfg.pattern.without_first_col → cfg.category.without_first_col
m 1 revision imported: Importing template Sfrac
 
(6 intermediate revisions by 3 users not shown)
Line 579: Line 579:
)
)
else
else
nav:attr('aria-label', cfg.aria_label)
nav:attr('aria-label', cfg.aria_label .. args.argHash)
end
end
elseif border == cfg.keyword.border_subgroup then
elseif border == cfg.keyword.border_subgroup then
Line 771: Line 771:
row = coltable:tag('tr')
row = coltable:tag('tr')
for k, n in ipairs(colheadernums) do
for k, n in ipairs(colheadernums) do
col = row:tag('td'):addClass('navbox-abovebelow')
col = row:tag('th'):addClass('navbox-abovebelow')
col:cssText(concatstyles({
col:cssText(concatstyles({
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
(k > 1) and 'border-left:2px solid #fdfdfd' or '',
Line 852: Line 852:
function p.navbox (frame, boxtype)
function p.navbox (frame, boxtype)
local function readArgs(args, prefix)
local function readArgs(args, prefix)
local function readSubgroups(element, i)
if inArray(cfg.keyword.subgroups, args[prefix .. andnum(element, i)]) then
for _, v in ipairs(cfg.arg.subgroups_and_num) do
readArgs(args, prefix .. string.format(v, i) .. "_")
end
readArgs(args, prefix .. andnum('col', i) .. "_")
end
end
-- Read the arguments in the order they'll be output in, to make references
-- Read the arguments in the order they'll be output in, to make references
-- number in the right order.
-- number in the right order.
local _ = 0
local _
_ = _ + (args[prefix .. cfg.arg.title] and #args[prefix .. cfg.arg.title] or 0)
_ = args[prefix .. cfg.arg.title]
_ = _ + (args[prefix .. cfg.arg.above] and #args[prefix .. cfg.arg.above] or 0)
_ = args[prefix .. cfg.arg.above]
-- Limit this to 20 as covering 'most' cases (that's a SWAG) and because
-- Limit this to 20 as covering 'most' cases (that's a SWAG) and because
-- iterator approach won't work here
-- iterator approach won't work here
local boxtype = args.type or cfg.keyword[boxtype]
if boxtype == cfg.keyword.with_columns then
for i = 1, 20 do
_ = args[prefix .. andnum('colheader', i)]
end
for i = 1, 20 do
readSubgroups('col', i)
end
for i = 1, 20 do
_ = args[prefix .. andnum('colfooter', i)]
end
end
for i = 1, 20 do
for i = 1, 20 do
_ = _ + (args[prefix .. andnum('group', i)] and #args[prefix .. andnum('group', i)] or 0)
_ = args[prefix .. andnum('group', i)]
if inArray(cfg.keyword.subgroups, args[prefix .. andnum('list', i)]) then
readSubgroups('list', i)
for _, v in ipairs(cfg.arg.subgroups_and_num) do
readArgs(args, prefix .. string.format(v, i) .. "_")
end
readArgs(args, prefix .. andnum('col', i) .. "_")
end
end
end
_ = _ + (args[prefix .. cfg.arg.below] and #args[prefix .. cfg.arg.below] or 0)
_ = args[prefix .. cfg.arg.below]
return _
end
end


Line 876: Line 890:
end
end
local args = getArgs(frame, {wrappers = {cfg.pattern[boxtype or 'navbox']}})
local args = getArgs(frame, {wrappers = {cfg.pattern[boxtype or 'navbox']}})
args.argHash = readArgs(args, "")
readArgs(args, "")
args.argHash = nil -- we shouldn't accept argHash passed from a template
args.type = args.type or cfg.keyword[boxtype]
args.type = args.type or cfg.keyword[boxtype]
return p['_navbox'](args)
return p['_navbox'](args)