Module:NavboxMobile: Difference between revisions
EnWikiAdmin (talk | contribs) No edit summary |
EnWikiAdmin (talk | contribs) No edit summary |
||
Line 169: | Line 169: | ||
local row = addTableRow(tbl) | local row = addTableRow(tbl) | ||
-- | -- Process group | ||
if args['group' .. listnum] then | if args['group' .. listnum] then | ||
local groupCell = row:tag('th') | local groupCell = row:tag('th') | ||
groupCell | groupCell | ||
:attr('scope', 'row') | :attr('scope', 'row') | ||
:addClass('navboxMobile-group') | :addClass('navboxMobile-group') | ||
:cssText(args.basestyle) | :cssText(args.basestyle) | ||
:cssText(args.groupstyle) | :cssText(args.groupstyle) | ||
:cssText(args['group' .. listnum .. 'style']) | :cssText(args['group' .. listnum .. 'style']) | ||
Line 201: | Line 181: | ||
end | end | ||
-- Add table row for the list | |||
row = addTableRow(tbl) | |||
local listCell = row:tag('td') | |||
listCell:attr('colspan', 2) | |||
listCell:css('width', '100%') | |||
listCell:cssText(args.liststyle) | |||
listCell:addClass('navboxMobile-list') | |||
local | -- Check for nested lists (e.g., child1_groupX) | ||
local nestedGroup = args['child' .. listnum .. '_group1'] | |||
local nestedList = args['child' .. listnum .. '_list1'] | |||
if nestedGroup or nestedList then | |||
local nestedTbl = mw.html.create('table') | |||
:addClass('navboxMobile-subgroup') | |||
:css('width', '100%') | |||
for i = 1, 10 do -- Assume a max of 10 nested groups/lists | |||
local nestedGroup = args['child' .. listnum .. '_group' .. i] | |||
local nestedList = args['child' .. listnum .. '_list' .. i] | |||
if not nestedGroup and not nestedList then break end | |||
local nestedRow = addTableRow(nestedTbl) | |||
if nestedGroup then | |||
nestedRow:tag('th') | |||
:addClass('navboxMobile-group') | |||
:cssText(args.basestyle) | |||
:cssText(args['child' .. listnum .. '_group' .. i .. 'style']) | |||
:wikitext(nestedGroup) | |||
end | |||
if nestedList then | |||
nestedRow:tag('td') | |||
:addClass('navboxMobile-list') | |||
:cssText(args['child' .. listnum .. '_list' .. i .. 'style']) | |||
:wikitext(addNewline(nestedList)) | |||
end | |||
end | |||
listCell:node(nestedTbl) | |||
else | else | ||
listCell:wikitext(addNewline(args['list' .. listnum])) | |||
end | end | ||
end | end | ||