|
|
Line 414: |
Line 414: |
| -- Add the title row | | -- Add the title row |
| renderTitleRow(tbl) | | renderTitleRow(tbl) |
| | |
| -- Add the above row | | -- Add the above row |
| renderAboveRow(tbl) | | renderAboveRow(tbl) |
Line 453: |
Line 454: |
| navbarRow:tag('td') | | navbarRow:tag('td') |
| :attr('colspan', 2) | | :attr('colspan', 2) |
| :addClass('navboxMobile-navbar') -- Apply Navbar styling | | :addClass('navboxMobile-navbar') |
| :css('text-align', 'right') | | :css('text-align', 'right') |
| :wikitext(navbar{args.name,mini = 1}) | | :wikitext(navbar(args.name, {mini = 1})) |
| end | | end |
|
| |
|
| return tbl | | return tbl |
| end | | end |
| | |
|
| |
|
|
| |
|
Line 492: |
Line 494: |
| -- Render the main body of the navboxMobile | | -- Render the main body of the navboxMobile |
| local tbl = renderMainTable() | | local tbl = renderMainTable() |
|
| |
| -- Iterate through list numbers and handle child and flat lists separately
| |
| for _, listnum in ipairs(listnums) do
| |
| local listKey = "list" .. listnum
| |
| local groupKey = "group" .. listnum
| |
|
| |
| if args[listKey] then
| |
| -- Always render the parent group
| |
| local groupRow = addTableRow(tbl)
| |
| local groupCell = groupRow:tag('th')
| |
| :attr('scope', 'row')
| |
| :addClass('navboxMobile-group-content')
| |
| :addClass('navboxMobile-group-level1') -- Top-level groups use level1
| |
| :wikitext(processItem(args[groupKey]))
| |
|
| |
| if args[listKey] == 'child' then
| |
| -- Render child lists recursively
| |
| renderListRow(tbl, tostring(listnum), 2) -- Start at level 2 for children
| |
| else
| |
| -- Render flat lists directly
| |
| local listRow = addTableRow(tbl)
| |
| local listCell = listRow:tag('td')
| |
| :attr('colspan', 2)
| |
| :addClass('navboxMobile-list-content')
| |
| :addClass((listnum % 2 == 1) and 'navboxMobile-odd' or 'navboxMobile-even')
| |
| :cssText(args.liststyle)
| |
| :cssText(args[listKey .. 'style'])
| |
| :addClass('hlist') -- Ensure hlist class is added for proper shading
| |
| :wikitext(processItem(args[listKey], args.nowrapitems))
| |
|
| |
|
| |
| -- Ensure consistent background shading across rows
| |
| if args.groupstyle or args.liststyle then
| |
| local bgColor = mw.ustring.match(args.groupstyle or args.liststyle, "background%-color%s*:%s*([^;]+)")
| |
| if bgColor then
| |
| listCell:css('background-color', bgColor) -- Apply consistent background color
| |
| end
| |
| end
| |
|
| |
| end
| |
| end
| |
| end
| |
|
| |
|
| -- Create the final HTML with styles | | -- Create the final HTML with styles |
| local res = mw.html.create() | | local res = mw.html.create() |
|
| |
| -- Inject styles analogous to Module:Navbox
| |
| res:node(add_navbox_mobile_styles(hiding_templatestyles)) | | res:node(add_navbox_mobile_styles(hiding_templatestyles)) |
| | | res:node(tbl) |
| -- Handle wrapping based on border parameter | |
| if border == 'none' then
| |
| -- Wrap the table within a navigation div with ARIA attributes
| |
| local navWrapper = mw.html.create('div')
| |
| :attr('role', 'navigation')
| |
| :addClass('navboxMobile')
| |
| if args.title or args.above or (args.group1 and not args.group2) then
| |
| navWrapper:attr(
| |
| 'aria-labelledby',
| |
| mw.uri.anchorEncode(args.title or args.above or args.group1)
| |
| )
| |
| else
| |
| navWrapper:attr('aria-label', cfg.aria_label)
| |
| end
| |
| navWrapper:node(tbl)
| |
| res:node(navWrapper)
| |
| elseif border == 'subgroup' or border == 'child' then
| |
| -- Assume this navboxMobile is inside a parent navboxMobile's list cell
| |
| -- Insert closing and opening divs to manage padding
| |
| local subgroupWrapper = mw.html.create('div')
| |
| :addClass('navboxMobile-container') -- Consistent wrapping container
| |
| :node(tbl) -- Add the table as a child
| |
| | |
| res:node(subgroupWrapper)
| |
| else
| |
| -- Wrap the table within a navigation div with additional classes and styles
| |
| local navWrapper = mw.html.create('div')
| |
| :addClass('navboxMobile') -- Add consistent container
| |
| :attr('role', 'navigation')
| |
| :cssText(args.bodystyle)
| |
| :cssText(args.style)
| |
| :css('padding', '2px') -- Adjust padding as needed
| |
| if args.title or args.above or (args.group1 and not args.group2) then
| |
| navWrapper:attr(
| |
| 'aria-labelledby',
| |
| mw.uri.anchorEncode(args.title or args.above or args.group1)
| |
| )
| |
| else
| |
| navWrapper:attr('aria-label', cfg.aria_label)
| |
| end
| |
| navWrapper:node(tbl)
| |
| res:node(navWrapper)
| |
| end
| |
| | |
| -- Render tracking categories
| |
| renderTrackingCategories(res)
| |
|
| |
|
| return tostring(res) | | return tostring(res) |
| end | | end |
| | |
|
| |
|
| -- | | -- |