Module:NavboxMobile: Difference between revisions

No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 223: Line 223:
         :addClass(cfg.class.navbox_list)
         :addClass(cfg.class.navbox_list)
         :addClass(args[cfg.arg.titleclass])
         :addClass(args[cfg.arg.titleclass])
         :attr('data-level', 1) -- Level 1 for the main title
         :attr('data-level', 1)
         :attr('colspan', 2)
         :attr('colspan', 2)
         :cssText(args.basestyle)
         :cssText(args.basestyle)
Line 229: Line 229:
         :css('position', 'relative')  -- Ensure relative positioning for absolute children
         :css('position', 'relative')  -- Ensure relative positioning for absolute children


     -- Add the title content, centered
     -- Add the title content, centered across the full width
     titleCell
     titleCell
         :tag('div')
         :tag('div')
             :css('margin', '0')
             :css('margin', '0 auto')
             :css('text-align', 'center')
             :css('text-align', 'center')
             :wikitext(addNewline(args.title))
             :wikitext(addNewline(args.title))


     -- Add the navbar, positioned absolutely to not affect the title's centering
     -- Add the navbar, positioned absolutely in the top-right corner
     if has_navbar() then
     if has_navbar() then
         titleCell
         titleCell
Line 244: Line 244:
                 :css('top', '0')
                 :css('top', '0')
                 :css('right', '0')
                 :css('right', '0')
                :css('padding', '0.2em')  -- Optional: Adjust padding for alignment
                 :wikitext(navbar{
                 :wikitext(navbar{
                     args.name,
                     args.name,
Line 252: Line 253:
end
end


--
--  Above/Below rows
--


local function getAboveBelowColspan()
    return 2
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