Module:NavboxMobile: Difference between revisions
EnWikiAdmin (talk | contribs) No edit summary |
EnWikiAdmin (talk | contribs) No edit summary Tag: Reverted |
||
Line 112: | Line 112: | ||
:done() | :done() | ||
end | end | ||
local function renderGroupRow(tbl, groupnum, level) | |||
local groupRow = addTableRow(tbl) | |||
local groupCell = groupRow:tag('th') | |||
:attr('scope', 'row') | |||
:addClass('navboxMobile-group-content') | |||
:addClass('navboxMobile-group-level' .. level) -- Level 2 for main groups, Level 3 for subgroups | |||
:cssText(args.basestyle) | |||
:cssText(args['group' .. groupnum .. 'style']) | |||
:wikitext(processItem(args['group' .. groupnum])) | |||
end | |||
-- Work around for style markers (similar to Navbox) | -- Work around for style markers (similar to Navbox) | ||
Line 319: | Line 332: | ||
local function renderListRow(tbl, listnum) | local function renderListRow(tbl, listnum) | ||
-- | -- Determine level (2 for main groups, 3 for subgroups) | ||
local level = 2 | |||
if border == 'subgroup' then | |||
level = 3 | |||
end | end | ||
-- | -- Render group row | ||
renderGroupRow(tbl, listnum, level) | |||
-- Continue with rendering the list | |||
local listRow = addTableRow(tbl) | local listRow = addTableRow(tbl) | ||
local listCell = listRow:tag('td') | local listCell = listRow:tag('td') | ||
:addClass('navboxMobile-list-content') | |||
:addClass('navboxMobile-' .. ((listnum % 2 == 1) and 'odd' or 'even')) | |||
:attr('colspan', 2) | :attr('colspan', 2) | ||
:css('padding', '0 0.25em') | :css('padding', '0 0.25em') | ||
:css('width', '100%') | :css('width', '100%') | ||
:cssText(args.liststyle) | :cssText(args.liststyle) | ||
:cssText(args['list' .. listnum .. 'style']) | :cssText(args['list' .. listnum .. 'style']) | ||
if args['list' .. listnum] == 'child' then | if args['list' .. listnum] == 'child' then | ||
-- Render nested table | -- Render nested subgroup as a separate table | ||
local nestedTbl = mw.html.create('table') | local nestedTbl = mw.html.create('table') | ||
:addClass('navboxMobile-subgroup') | :addClass('navboxMobile-subgroup') | ||
:css('width', '100%') | :css('width', '100%') | ||
:css('border-spacing', '0') | :css('border-spacing', '0') | ||
:css('margin-top', '0.25em') | :css('margin-top', '0.25em') | ||
:css('margin-bottom', '0.25em') | :css('margin-bottom', '0.25em') | ||
for i = 1, 10 do | for i = 1, 10 do | ||
local nestedGroup = args['child' .. listnum .. '_group' .. i] | local nestedGroup = args['child' .. listnum .. '_group' .. i] | ||
local nestedList = args['child' .. listnum .. '_list' .. i] | local nestedList = args['child' .. listnum .. '_list' .. i] | ||
if not nestedGroup and not nestedList then break end -- | if not nestedGroup and not nestedList then break end | ||
local | renderGroupRow(nestedTbl, i, 3) -- Level 3 for subgroups | ||
local nestedListRow = addTableRow(nestedTbl) | |||
local nestedListCell = nestedListRow:tag('td') | |||
:addClass('navboxMobile-list-content') | |||
:addClass('navboxMobile-' .. ((i % 2 == 1) and 'odd' or 'even')) | |||
:attr('colspan', 2) | |||
:css('padding', '0 0.25em') | |||
:cssText(args['child' .. listnum .. '_list' .. i .. 'style']) | |||
:wikitext(processItem(nestedList)) | |||
end | end | ||
listCell:node(nestedTbl) | listCell:node(nestedTbl) | ||
else | else | ||
-- Render | -- Render flat list | ||
listCell | listCell:tag('div') | ||
:css('padding', args.listpadding or '0 0.25em') | |||
:wikitext(processItem(args['list' .. listnum], args.nowrapitems)) | |||
end | end | ||
end | end | ||