445
edits
(testing) |
m (38 revisions imported from wikipedia:Module:Navbox_with_collapsible_groups: see Topic:Vtixlm0q28eo6jtf) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
-- This module implements {{Navbox with collapsible groups}} | -- This module implements {{Navbox with collapsible groups}} | ||
local q = {} | local q = {} | ||
local Navbox = require('Module:Navbox') | |||
-- helper functions | -- helper functions | ||
Line 20: | Line 20: | ||
function q._navbox(pargs) | function q._navbox(pargs) | ||
-- table for args passed to navbox | -- table for args passed to navbox | ||
local targs = {} | local targs = {} | ||
Line 45: | Line 43: | ||
if (targs['list' .. n] == nil and pargs['group' .. n] == nil | if (targs['list' .. n] == nil and pargs['group' .. n] == nil | ||
and pargs['sect' .. n] == nil and pargs['section' .. n] == nil) then | and pargs['sect' .. n] == nil and pargs['section' .. n] == nil) then | ||
targs['list' .. n] = concatstrings(pargs['list' .. n] or '', pargs['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 69: | Line 68: | ||
local state = (pargs['abbr' .. n] and pargs['abbr' .. n] == pargs['selected']) | local state = (pargs['abbr' .. n] and pargs['abbr' .. n] == pargs['selected']) | ||
and 'uncollapsed' or pargs['state' .. n] or 'collapsed' | and 'uncollapsed' or pargs['state' .. n] or 'collapsed' | ||
targs['list' .. n] = Navbox._navbox( | |||
{'child', navbar = 'plain', state = state, | |||
basestyle = pargs['basestyle'], | basestyle = pargs['basestyle'], | ||
title = title, titlestyle = titlestyle, | title = title, titlestyle = titlestyle, | ||
Line 76: | Line 77: | ||
image = pargs['image' .. n], | image = pargs['image' .. n], | ||
imageleft = pargs['imageleft' .. n], | imageleft = pargs['imageleft' .. n], | ||
listpadding = pargs['listpadding']} | listpadding = pargs['listpadding']}) | ||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
-- ordering of style and bodystyle | |||
targs['style'] = concatstyles({targs['style'] or '', targs['bodystyle'] or ''}) | |||
targs['bodystyle'] = nil | |||
-- child or subgroup | -- child or subgroup | ||
if targs['border'] == nil then targs['border'] = pargs[1] end | if targs['border'] == nil then targs['border'] = pargs[1] end | ||
return | return Navbox._navbox(targs) | ||
end | end | ||
function q.navbox(frame) | function q.navbox(frame) | ||
local pargs = require('Module:Arguments').getArgs(frame, {wrappers = {'Template:Navbox with collapsible groups'}}) | local pargs = require('Module:Arguments').getArgs(frame, {wrappers = {'Template:Navbox with collapsible groups'}}) | ||