Module:NavboxMobile: Difference between revisions

No edit summary
No edit summary
Line 266: Line 266:
end
end


local function renderBelowRow(tbl)
    if not args.below then return end
    addTableRow(tbl)
        :tag('td')
            :addClass('navboxMobile-abovebelow-content')
            :addClass(cfg.class.navbox_list) -- Add consistent list styling
            :addClass(args.belowclass)
            :cssText(args.basestyle)
            :cssText(args.belowstyle)
            :css('padding', args[cfg.arg.belowpadding] or '0.5em') -- Optional padding
            :attr('colspan', getAboveBelowColspan())
            :tag('div')
                :wikitext(addNewline(args.below))
end


local function renderListRow(tbl, path, parentLevel)
local function renderListRow(tbl, path, parentLevel)
Line 292: Line 276:


         if args[groupKey] then
         if args[groupKey] then
            -- Add custom inline styles based on group levels
            local inlineStyles = ""
             -- Render the group (heading)
             -- Render the group (heading)
             local groupRow = addTableRow(tbl)
             local groupRow = addTableRow(tbl)
Line 299: Line 286:
                 :addClass('navboxMobile-group-level' .. parentLevel) -- Level-specific class
                 :addClass('navboxMobile-group-level' .. parentLevel) -- Level-specific class
                 :attr('data-level', parentLevel) -- Optional attribute for CSS targeting
                 :attr('data-level', parentLevel) -- Optional attribute for CSS targeting
                :cssText(inlineStyles)
                 :wikitext(processItem(args[groupKey]))
                 :wikitext(processItem(args[groupKey]))


Line 307: Line 295:
                     :attr('colspan', 2)
                     :attr('colspan', 2)
                     :addClass('navboxMobile-list-content')
                     :addClass('navboxMobile-list-content')
                     :addClass('navboxMobile-list-level' .. parentLevel) -- Apply narrowing styles via class
                     :addClass('navboxMobile-list-level' .. parentLevel) -- Level-specific class
                     :addClass((i % 2 == 1) and 'navboxMobile-odd' or 'navboxMobile-even') -- Alternate row styling
                     :addClass((i % 2 == 1) and 'navboxMobile-odd' or 'navboxMobile-even')
                     :wikitext(processItem(args[listKey], args.nowrapitems))
                    :css('padding', '0 0.25em')
                    :css('width', parentLevel == 2 and '95%' or '90%') -- Adjust width for narrowing
                     :cssText(inlineStyles) -- Apply the same styles as the group heading
                    :cssText(args[listKey .. 'style'])


                 if args[listKey] == 'child' then
                 if args[listKey] == 'child' then
                     local newPath = (path ~= "" and path .. "_" or "") .. i
                     local newPath = (path ~= "" and path .. "_" or "") .. i
                     renderListRow(tbl, tostring(newPath), parentLevel + 1)
                     renderListRow(tbl, tostring(newPath), parentLevel + 1)
                else
                    listCell
                        :addClass('hlist')
                        :wikitext(processItem(args[listKey], args.nowrapitems))
                 end
                 end
             end
             end