Module:NavboxMobile: Difference between revisions
EnWikiAdmin (talk | contribs) No edit summary |
EnWikiAdmin (talk | contribs) No edit summary |
||
Line 309: | Line 309: | ||
-- Process group | -- Process group | ||
if args['group' .. listnum] then | |||
local groupCell = row:tag('th') | local groupCell = row:tag('th') | ||
groupCell | groupCell | ||
:attr('scope', 'row') | :attr('scope', 'row') | ||
Line 324: | Line 316: | ||
:cssText(args.basestyle) | :cssText(args.basestyle) | ||
:cssText(args.groupstyle) | :cssText(args.groupstyle) | ||
:cssText(args[ | :cssText(args['group' .. listnum .. 'style']) | ||
:wikitext(processItem(args[ | :wikitext(processItem(args['group' .. listnum])) | ||
end | end | ||
-- Add list | -- Add table row for the list | ||
row = addTableRow(tbl) | |||
local listCell = row:tag('td') | local listCell = row:tag('td') | ||
listCell:attr('colspan', 2) | |||
listCell:css('width', '100%') | |||
if | -- Apply dynamic styling | ||
local oddEven = cfg.class.navbox_odd_part | |||
if args['list' .. listnum] and args['list' .. listnum]:sub(1, 12) == '</div><table' then | |||
oddEven = args['list' .. listnum]:find(cfg.pattern.navbox_title) and cfg.marker.restart or | |||
cfg.class.navbox_odd_part | |||
end | end | ||
listCell:addClass(oddEven) | |||
-- | listCell | ||
if inArray(cfg.keyword.subgroups, | :addClass('navboxMobile-list-content') | ||
:addClass(cfg.class.navbox_list) -- Add styling for lists | |||
:addClass(cfg.class.navbox_part .. ((listnum % 2 == 1) and 'odd' or 'even')) -- Ensure odd/even styles | |||
:addClass(args[cfg.arg.listclass]) -- Apply any additional classes from args | |||
:addClass(args['listclass_' .. listnum]) -- Apply list-specific classes | |||
:cssText(args.liststyle) | |||
:cssText(args['list' .. listnum .. 'style']) | |||
-- Check for nested subgroups dynamically | |||
if inArray(cfg.keyword.subgroups, args['list' .. listnum]) then | |||
local childArgs = { | local childArgs = { | ||
border = 'subgroup', | |||
navbar = 'plain' | |||
} | } | ||
for k, v in pairs(args) do | for k, v in pairs(args) do | ||
local prefix = | local prefix = 'child' .. listnum .. '_' | ||
if k:sub(1, #prefix) == prefix then | if k:sub(1, #prefix) == prefix then | ||
childArgs[k:sub(#prefix + 1)] = v | childArgs[k:sub(#prefix + 1)] = v | ||
end | end | ||
end | end | ||
args['list' .. listnum] = p._navboxMobile(childArgs) | |||
end | end | ||
-- | -- Check for nested lists (e.g., child1_groupX) | ||
local | local nestedGroup = args['child' .. listnum .. '_group1'] | ||
if | 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-content') | |||
:cssText(args.basestyle) | |||
:cssText(args['child' .. listnum .. '_group' .. i .. 'style']) | |||
:wikitext(processItem(nestedGroup)) | |||
end | |||
if nestedList then | |||
nestedRow:tag('td') | |||
:addClass('navboxMobile-list-content hlist') | |||
:cssText(args['child' .. listnum .. '_list' .. i .. 'style']) | |||
:wikitext(processItem(nestedList)) | |||
end | |||
end | |||
listCell:node(nestedTbl) | |||
else | |||
listCell | |||
:addClass('hlist') -- Add hlist for horizontal styling | |||
:tag('div') -- Wrap in a div to allow padding and better styling | |||
:css('padding', args[cfg.arg.listpadding] or '0 0.25em') | |||
:wikitext(processItem(args['list' .. listnum], args.nowrapitems)) | |||
end | end | ||
end | end | ||