Jump to content

Module:Navbox with collapsible groups: Difference between revisions

testing
(testing)
(testing)
Line 22: Line 22:
end
end


function p._navbox(frame, args)
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(args) do
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 args['group' .. n] == nil
if (targs['list' .. n] == nil and pargs['group' .. n] == nil
and args['sect' .. n] == nil and args['section' .. n] == nil) then
and pargs['sect' .. n] == nil and pargs['section' .. n] == nil) then
targs['list' .. n] = concatstrings(args['list' .. n] or '', args['content' .. n] or '')
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(
{args['groupstyle'] or '',args['secttitlestyle'] or '',  
{pargs['groupstyle'] or '',pargs['secttitlestyle'] or '',  
args['group' .. n .. 'style'] or '',  
pargs['group' .. n .. 'style'] or '',  
args['section' .. n ..'titlestyle'] or ''})
pargs['section' .. n ..'titlestyle'] or ''})
local liststyle = concatstyles(
local liststyle = concatstyles(
{args['liststyle'] or '', args['contentstyle'] or '',  
{pargs['liststyle'] or '', pargs['contentstyle'] or '',  
args['list' .. n .. 'style'] or '',  
pargs['list' .. n .. 'style'] or '',  
args['content' .. n .. 'style'] or ''})
pargs['content' .. n .. 'style'] or ''})
local title = concatstrings(
local title = concatstrings(
{args['group' .. n] or '',  
{pargs['group' .. n] or '',  
args['sect' .. n] or '',
pargs['sect' .. n] or '',
args['section' .. n] or ''})
pargs['section' .. n] or ''})
local list = concatstrings(
local list = concatstrings(
{args['list' .. n] or '',  
{pargs['list' .. n] or '',  
args['content' .. n] or ''})
pargs['content' .. n] or ''})
local state = (args['abbr' .. n] and args['abbr' .. n] == args['selected'])  
local state = (pargs['abbr' .. n] and pargs['abbr' .. n] == pargs['selected'])  
and 'uncollapsed' or args['state' .. n] or 'collapsed'
and 'uncollapsed' or pargs['state' .. n] or 'collapsed'
local sargs = {'child', navbar = 'plain', state = state,
local sargs = {'child', navbar = 'plain', state = state,
basestyle = args['basestyle'],
basestyle = pargs['basestyle'],
title = title, titlestyle = titlestyle,
title = title, titlestyle = titlestyle,
list1 = list, liststyle = liststyle,
list1 = list, liststyle = liststyle,
listclass = args['list' .. n .. 'class'],
listclass = pargs['list' .. n .. 'class'],
image = args['image' .. n],
image = pargs['image' .. n],
imageleft = args['imageleft' .. n],
imageleft = pargs['imageleft' .. n],
listpadding = args['listpadding']}
listpadding = pargs['listpadding']}
targs['list' .. n] = frame:expandTemplate{title='Navbox', args = sargs}
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'] = args[1] end
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 args = getArgs(frame, {wrappers = {'Template:Navbox with collapsible groups'}})
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 _
_ = args.title
_ = pargs.title
_ = args.above
_ = pargs.above
for i = 1, 20 do
for i = 1, 20 do
_ = args["group" .. tostring(i)]
_ = pargs["group" .. tostring(i)]
_ = args["list" .. tostring(i)]
_ = pargs["list" .. tostring(i)]
end
end
_ = args.below
_ = pargs.below


return p._navbox(frame, args)
return p._navbox(pargs)
end
end


return p
return p
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.