Module:Navbox with collapsible groups: Difference between revisions
testing
(testing) |
(testing) |
||
Line 22: | Line 22: | ||
end | end | ||
function p._navbox( | function p._navbox(pargs) | ||
local tracking = '' | local tracking = '' | ||
Line 39: | Line 39: | ||
['imageleft']=true,['imageleftstyle']=true | ['imageleft']=true,['imageleftstyle']=true | ||
} | } | ||
for k,v in pairs( | for k,v in pairs(pargs) do | ||
if k and type(k) == 'string' then | if k and type(k) == 'string' then | ||
if passthrough[k] then | if passthrough[k] then | ||
Line 46: | Line 46: | ||
or k:match('^content[0-9][0-9]*$') ) then | or k:match('^content[0-9][0-9]*$') ) then | ||
local n = mw.ustring.gsub(k, '^[a-z]*([0-9]*)$', '%1') | local n = mw.ustring.gsub(k, '^[a-z]*([0-9]*)$', '%1') | ||
if (targs['list' .. n] == nil and | if (targs['list' .. n] == nil and pargs['group' .. n] == nil | ||
and | and pargs['sect' .. n] == nil and pargs['section' .. n] == nil) then | ||
targs['list' .. n] = concatstrings( | targs['list' .. n] = concatstrings(pargs['list' .. n] or '', pargs['content' .. n] or '') | ||
end | end | ||
elseif (k:match('^group[0-9][0-9]*$') | elseif (k:match('^group[0-9][0-9]*$') | ||
Line 56: | Line 56: | ||
if targs['list' .. n] == nil then | if targs['list' .. n] == nil then | ||
local titlestyle = concatstyles( | local titlestyle = concatstyles( | ||
{ | {pargs['groupstyle'] or '',pargs['secttitlestyle'] or '', | ||
pargs['group' .. n .. 'style'] or '', | |||
pargs['section' .. n ..'titlestyle'] or ''}) | |||
local liststyle = concatstyles( | local liststyle = concatstyles( | ||
{ | {pargs['liststyle'] or '', pargs['contentstyle'] or '', | ||
pargs['list' .. n .. 'style'] or '', | |||
pargs['content' .. n .. 'style'] or ''}) | |||
local title = concatstrings( | local title = concatstrings( | ||
{ | {pargs['group' .. n] or '', | ||
pargs['sect' .. n] or '', | |||
pargs['section' .. n] or ''}) | |||
local list = concatstrings( | local list = concatstrings( | ||
{ | {pargs['list' .. n] or '', | ||
pargs['content' .. n] or ''}) | |||
local state = ( | local state = (pargs['abbr' .. n] and pargs['abbr' .. n] == pargs['selected']) | ||
and 'uncollapsed' or | and 'uncollapsed' or pargs['state' .. n] or 'collapsed' | ||
local sargs = {'child', navbar = 'plain', state = state, | local sargs = {'child', navbar = 'plain', state = state, | ||
basestyle = | basestyle = pargs['basestyle'], | ||
title = title, titlestyle = titlestyle, | title = title, titlestyle = titlestyle, | ||
list1 = list, liststyle = liststyle, | list1 = list, liststyle = liststyle, | ||
listclass = | listclass = pargs['list' .. n .. 'class'], | ||
image = | image = pargs['image' .. n], | ||
imageleft = | imageleft = pargs['imageleft' .. n], | ||
listpadding = | listpadding = pargs['listpadding']} | ||
targs['list' .. n] = | targs['list' .. n] = Navbox._navbox(sargs) | ||
tracking = tracking .. '<hr /><center><b>k = ' .. k .. ', n = ' .. n .. '</b></center><hr />\n' | tracking = tracking .. '<hr /><center><b>k = ' .. k .. ', n = ' .. n .. '</b></center><hr />\n' | ||
for ks,vs in pairs(sargs) do | for ks,vs in pairs(sargs) do | ||
Line 92: | Line 92: | ||
-- child or subgroup | -- child or subgroup | ||
if targs['border'] == nil then targs['border'] = | if targs['border'] == nil then targs['border'] = pargs[1] end | ||
-- debug | -- debug | ||
Line 108: | Line 108: | ||
getArgs = require('Module:Arguments').getArgs | getArgs = require('Module:Arguments').getArgs | ||
end | end | ||
local | local pargs = getArgs(frame, {wrappers = {'Template:Navbox with collapsible groups'}}) | ||
-- Read the arguments in the order they'll be output in, to make references number in the right order. | -- Read the arguments in the order they'll be output in, to make references number in the right order. | ||
local _ | local _ | ||
_ = | _ = pargs.title | ||
_ = | _ = pargs.above | ||
for i = 1, 20 do | for i = 1, 20 do | ||
_ = | _ = pargs["group" .. tostring(i)] | ||
_ = | _ = pargs["list" .. tostring(i)] | ||
end | end | ||
_ = | _ = pargs.below | ||
return p._navbox( | return p._navbox(pargs) | ||
end | end | ||
return p | return p |