Module:NavboxMobile: Difference between revisions
EnWikiAdmin (talk | contribs) No edit summary |
EnWikiAdmin (talk | contribs) No edit summary |
||
Line 305: | Line 305: | ||
-- List rows | -- List rows | ||
-- | -- | ||
local function renderListRow(tbl | local function renderListRow(tbl, listnum) | ||
local row = addTableRow(tbl) | local row = addTableRow(tbl) | ||
-- Process group | -- Process group | ||
local group_and_num = format(cfg.arg.group_and_num, listnum) | local group_and_num = format(cfg.arg.group_and_num, listnum) | ||
local groupstyle_and_num = format(cfg.arg.groupstyle_and_num, listnum) | local groupstyle_and_num = format(cfg.arg.groupstyle_and_num, listnum) | ||
Line 314: | Line 314: | ||
local groupCell = row:tag('th') | local groupCell = row:tag('th') | ||
-- | -- Handle ARIA attributes for accessibility | ||
if listnum == 1 and not (args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group2]) then | if listnum == 1 and not (args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group2]) then | ||
groupCell:attr('id', mw.uri.anchorEncode(args[cfg.arg.group1])) | groupCell:attr('id', mw.uri.anchorEncode(args[cfg.arg.group1])) | ||
Line 330: | Line 330: | ||
-- Add list cell | -- Add list cell | ||
local listCell = row:tag('td') | local listCell = row:tag('td') | ||
if args[group_and_num] then | if args[group_and_num] then | ||
listCell:addClass( | listCell:addClass('navboxMobile-list-with-group') | ||
else | else | ||
listCell:attr('colspan', 2) | listCell:attr('colspan', 2) | ||
end | end | ||
if not args[cfg.arg.groupwidth] then | if not args[cfg.arg.groupwidth] then | ||
listCell:css('width', '100%') | listCell:css('width', '100%') | ||
end | end | ||
-- Apply styles | -- Apply row-specific styles | ||
local rowstyle = | local rowstyle = (listnum % 2 == 1) and args[cfg.arg.oddstyle] or args[cfg.arg.evenstyle] | ||
local list_and_num = format(cfg.arg.list_and_num, listnum) | local list_and_num = format(cfg.arg.list_and_num, listnum) | ||
local listText = args[list_and_num] | local listText = args[list_and_num] | ||
-- | -- Handle nested subgroups | ||
if inArray(cfg.keyword.subgroups, listText) then | if inArray(cfg.keyword.subgroups, listText) then | ||
local childArgs = { | local childArgs = { | ||
[cfg.arg.border] = cfg.keyword.border_subgroup, | [cfg.arg.border] = cfg.keyword.border_subgroup, | ||
[cfg.arg.navbar] = cfg.keyword.navbar_plain | [cfg.arg.navbar] = cfg.keyword.navbar_plain, | ||
} | } | ||
local hasChildArgs = false | local hasChildArgs = false | ||
for k, v in pairs(args) do | for k, v in pairs(args) do | ||
local prefix = cfg.keyword.subgroups[1] .. listnum .. "_" | |||
if k:sub(1, #prefix) == prefix then | |||
childArgs[k:sub(#prefix + 1)] = v | |||
hasChildArgs = true | |||
end | end | ||
end | end | ||
Line 375: | Line 362: | ||
end | end | ||
-- | -- Handle automatic striping for odd/even rows | ||
local oddEven = cfg.marker.oddeven | local oddEven = cfg.marker.oddeven | ||
if listText:sub(1, 12) == '</div><table' then | if listText and listText:sub(1, 12) == '</div><table' then | ||
oddEven = listText:find(cfg.pattern.navbox_title) and cfg.marker.restart or cfg.class.navbox_odd_part | oddEven = listText:find(cfg.pattern.navbox_title) and cfg.marker.restart or cfg.class.navbox_odd_part | ||
end | end | ||
-- | -- Render list content | ||
local liststyle_and_num = format(cfg.arg.liststyle_and_num, listnum) | local liststyle_and_num = format(cfg.arg.liststyle_and_num, listnum) | ||
listCell | listCell | ||
:cssText(args[cfg.arg.liststyle]) | :cssText(args[cfg.arg.liststyle]) | ||
:cssText(rowstyle) | :cssText(rowstyle) | ||
:cssText(args[liststyle_and_num]) | :cssText(args[liststyle_and_num]) | ||
:addClass( | :addClass('navboxMobile-list-content') | ||
:addClass(cfg.class.navbox_part .. oddEven) | :addClass(cfg.class.navbox_part .. oddEven) | ||
:addClass(args[cfg.arg.listclass]) | :addClass(args[cfg.arg.listclass]) | ||
:tag('div') | :tag('div') | ||
:css('padding', | :css('padding', args[cfg.arg.listpadding] or '0 0.25em') | ||
:wikitext(processItem(listText, args[cfg.arg.nowrapitems])) | :wikitext(processItem(listText or '', args[cfg.arg.nowrapitems])) | ||
end | end | ||