Module:NavboxMobile: Difference between revisions

No edit summary
No edit summary
Line 227: Line 227:
         :cssText(args.basestyle)
         :cssText(args.basestyle)
         :cssText(args.titlestyle)
         :cssText(args.titlestyle)
        :css('position', 'relative')  -- Ensure relative positioning for absolute children


     -- Add the navbar (VTE) and title
     -- Add the title content, centered
     titleCell:tag('div')
     titleCell
        :css('position', 'relative') -- Make positioning independent
        :wikitext(
            navbar{
                args.name,
                mini = 1,
                fontstyle = 'position:absolute; left:0; top:0; background:none; border:none;'
            }
        )
         :tag('div')
         :tag('div')
        :css('text-align', 'center') -- Ensure title remains centered
            :css('margin', '0')
        :wikitext(addNewline(args.title))
            :css('text-align', 'center')
end
            :wikitext(addNewline(args.title))


 
    -- Add the navbar, positioned absolutely to not affect the title's centering
 
    if has_navbar() then
 
        titleCell
--
            :tag('div')
--  Above/Below rows
                :addClass('navboxMobile-navbar')
--
                :css('position', 'absolute')
 
                :css('top', '0')
local function getAboveBelowColspan()
                :css('right', '0')
     return 2
                :wikitext(navbar{
                    args.name,
                    mini = 1,
                    fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;'
                })
     end
end
end


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




Line 464: Line 447:
     -- Add the below row
     -- Add the below row
     renderBelowRow(tbl)
     renderBelowRow(tbl)
    -- Add the Navbar row last
    if has_navbar() then
        local navbarRow = tbl:tag('tr')
        navbarRow:tag('td')
            :attr('colspan', 2)
            :addClass('navboxMobile-navbar')
            :css('text-align', 'right')
            :wikitext(navbar{args.name, mini = 1})
    end


     return tbl
     return tbl