Module:NavboxMobile: Difference between revisions

No edit summary
No edit summary
Line 169: Line 169:
     local row = addTableRow(tbl)
     local row = addTableRow(tbl)


     --[[if listnum == 1 and args.imageleft then
     -- Process group
        row
            :tag('td')
                :addClass('navboxMobile-image')
                :addClass(args.imageclass)
                :css('width', '0%')
                :css('padding', '0px 2px 0px 0px')
                :cssText(args.imageleftstyle)
                :attr('rowspan', 2 * #listnums - 1)
                :tag('div')
                    :wikitext(addNewline(args.imageleft))
    end]]
 
     if args['group' .. listnum] then
     if args['group' .. listnum] then
         local groupCell = row:tag('th')
         local groupCell = row:tag('th')
         groupCell
         groupCell
             :attr('scope', 'row')
             :attr('scope', 'row')
             :addClass('navboxMobile-group')
             :addClass('navboxMobile-group')
            :addClass(args.groupclass)
             :cssText(args.basestyle)
             :cssText(args.basestyle)
        if args.groupwidth then
            groupCell:css('width', args.groupwidth)
        end
        groupCell
             :cssText(args.groupstyle)
             :cssText(args.groupstyle)
             :cssText(args['group' .. listnum .. 'style'])
             :cssText(args['group' .. listnum .. 'style'])
Line 201: Line 181:
     end
     end


     local row = addTableRow(tbl) -- added
     -- Add table row for the list
    row = addTableRow(tbl)
    local listCell = row:tag('td')
    listCell:attr('colspan', 2)
    listCell:css('width', '100%')
    listCell:cssText(args.liststyle)
    listCell:addClass('navboxMobile-list')
      
      
     local listCell = row:tag('td')
    -- Check for nested lists (e.g., child1_groupX)
    local nestedGroup = args['child' .. listnum .. '_group1']
     local nestedList = args['child' .. listnum .. '_list1']
 
    if nestedGroup or nestedList then
        local nestedTbl = mw.html.create('table')
            :addClass('navboxMobile-subgroup')
            :css('width', '100%')
 
        for i = 1, 10 do -- Assume a max of 10 nested groups/lists
            local nestedGroup = args['child' .. listnum .. '_group' .. i]
            local nestedList = args['child' .. listnum .. '_list' .. i]
 
            if not nestedGroup and not nestedList then break end


    if args['group' .. listnum] then
             local nestedRow = addTableRow(nestedTbl)
        listCell
             :css('text-align', 'left')
            :css('border-left-width', '2px')
            :css('border-left-style', 'solid')
    else
        listCell:attr('colspan', 2)
    end


    if not args.groupwidth then
            if nestedGroup then
        listCell:css('width', '100%')
                nestedRow:tag('th')
    end
                    :addClass('navboxMobile-group')
                    :cssText(args.basestyle)
                    :cssText(args['child' .. listnum .. '_group' .. i .. 'style'])
                    :wikitext(nestedGroup)
            end


    local isOdd = (listnum % 2) == 1
            if nestedList then
    local rowstyle = args.evenstyle
                nestedRow:tag('td')
    if isOdd then rowstyle = args.oddstyle end
                    :addClass('navboxMobile-list')
                    :cssText(args['child' .. listnum .. '_list' .. i .. 'style'])
                    :wikitext(addNewline(nestedList))
            end
        end


    local evenOdd
         listCell:node(nestedTbl)
    if args.evenodd == 'swap' then
         if isOdd then evenOdd = 'even' else evenOdd = 'odd' end
     else
     else
         if isOdd then evenOdd = args.evenodd or 'odd' else evenOdd = args.evenodd or 'even' end
         listCell:wikitext(addNewline(args['list' .. listnum]))
     end
     end
    listCell
        :css('padding', '0px')
        :cssText(args.liststyle)
        :cssText(rowstyle)
        :cssText(args['list' .. listnum .. 'style'])
        :addClass('navboxMobile-list')
        :addClass('navboxMobile-' .. evenOdd)
        :addClass(args.listclass)
        :tag('div')
            :css('padding', (listnum == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
            :wikitext(addNewline(args['list' .. listnum]))
    --[[if listnum == 1 and args.image then
        row
            :tag('td')
                :addClass('navboxMobile-image')
                :addClass(args.imageclass)
                :css('width', '0%')
                :css('padding', '0px 0px 0px 2px')
                :cssText(args.imagestyle)
                :attr('rowspan', 2 * #listnums - 1)
                :tag('div')
                    :wikitext(addNewline(args.image))
    end ]]
end
end