FANDOM


local Navbox = {}
local HF = require('Module:HF')
-- local CH = require('Module:Category handler').main
-- local language = mw.language.new('en')
local tableRowAdded = false
 
local function renderTable()
    local tbl = mw.html.create('table')
-- table modifications (state,image,imageleft,navbar,border,bodystyle,bodyclass)
        tbl:attr('cellspacing', 0)
        tbl:addClass('nowraplinks')
        if not HF.isEmpty( frame.args.bodyclass ) then tbl:addClass( frame.args.bodyclass ) end
 
    if not HF.isEmpty( frame.args.title ) and (frame.args.state ~= 'plain' and frame.args.state ~= 'off') then
        tbl
            :addClass('collapsible')
            :addClass(frame.args.state or 'autocollapse')
    end
 
    tbl:css('border-spacing', 0)
    if border == 'subgroup' or border == 'child' or border == 'none' then
        tbl
            :addClass('navbox-subgroup')
            :cssText(frame.args.bodystyle)
            :cssText(frame.args.style)
    else -- regular navobx - bodystyle and style will be applied to the wrapper table
        tbl
            :addClass('navbox-inner')
            :css('background', 'transparent')
            :css('color', 'inherit')
    end
    tbl:cssText(frame.args.innerstyle)
-- title
    local titleRow = renderRow(tbl)
if not HF.isEmpty( frame.args.title ) then  
    if frame.args.titlegroup then
        titleRow
            :tag('th')
            :attr('scope', 'row')
            :addClass('navbox-group')
            :addClass(frame.args.titlegroupclass)
            :cssText(frame.args.basestyle)
            :cssText(frame.args.groupstyle)
            :cssText(frame.args.titlegroupstyle)
            :wikitext(frame.args.titlegroup)
    end
 
    local titleCell = titleRow:tag('th')
     titleCell:attr('scope', 'col')
 
    if frame.args.titlegroup then
        titleCell
            :css('border-left', '2px solid #fdfdfd')
            :css('width', '100%')
    end
 
    local titleColspan = 2
    if frame.args.imageleft then titleColspan = titleColspan + 1 end
    if frame.args.image then titleColspan = titleColspan + 1 end
    if frame.args.titlegroup then titleColspan = titleColspan - 1 end
 
    titleCell
        :cssText(frame.args.basestyle)
        :cssText(frame.args.titlestyle)
        :addClass('navbox-title')
        :attr('colspan', titleColspan)
 
--    renderNavBar(titleCell)
 
    titleCell
         :tag('div')
         :addClass(frame.args.titleclass)
         :css('font-size', '110%')
         :wikitext(frame.args.title)
end
-- find out why there's a newline in that last line
-- above
if not HF.isEmpty( frame.args.above ) then
    renderRow(tbl)
        :tag('td')
            :addClass('navbox-abovebelow')
            :addClass(frame.args.aboveclass)
            :cssText(frame.args.basestyle)
            :cssText(frame.args.abovestyle)
            :attr('colspan', getAboveBelowColspan())
            :tag('div')
                :wikitext(frame.args.above)
end
-- groups and rows
    for i, listnum in ipairs(listnums) do
        renderListRow(tbl, listnum) 
    end
-- below
if not HF.isEmpty( frame.args.below ) then
    renderRow(tbl)
        :tag('td')
            :addClass('navbox-abovebelow')
            :addClass(frame.args.belowclass)
            :cssText(frame.args.basestyle)
            :cssText(frame.args.belowstyle)
            :tag('div')
                :wikitext(frame.args.below)
end
end
 
local function getAboveBelowColspan()
    local ret = 2
    if args.imageleft then ret = ret + 1 end
    if args.image then ret = ret + 1 end
    return ret
end
 
local function renderRow(tbl)
-- If any other rows have already been added, then we add a 2px gutter row.
    if tableRowAdded then
        tbl
            :tag('tr')
            :css('height', '2px')
            :tag('td')
            :attr('colspan',2)
    end
 
    tableRowAdded = true
 
    return tbl:tag('tr')
 
end
 
 
 
 
 
 
local function renderListRow(tbl, listnum)
    local row = renderRow(tbl)
 
    if listnum == 1 and frame.args.imageleft then
        row
            :tag('td')
                :addClass('navbox-image')
                :addClass(frame.args.imageclass)
                :css('width', '0%')
                :css('padding', '0px 2px 0px 0px')
                :cssText(args.imageleftstyle)
                :attr('rowspan', 2 * #listnums - 1)
                :tag('div')
                    :wikitext(frame.args.imageleft)
    end
 
    if args['group' .. listnum] then
        local groupCell = row:tag('th')
 
        groupCell
               :attr('scope', 'row')
               :addClass('navbox-group')
               :addClass(frame.args.groupclass)
               :cssText(frame.args.basestyle)
 
        if frame.args.groupwidth then
            groupCell:css('width', frame.args.groupwidth)
        end
 
        groupCell
            :cssText(frame.args.groupstyle)
            :cssText(frame.args['group' .. listnum .. 'style'])
            :wikitext(frame.args['group' .. listnum])
    end
 
    local listCell = row:tag('td')
 
    if args['group' .. listnum] then
        listCell
            :css('text-align', 'left')
            :css('border-left-width', '2px')
            :css('border-left-style', 'solid')
    else
        listCell:attr('colspan', 2)
    end
 
    if not frame.args.groupwidth then 
        listCell:css('width', '100%')
    end
 
    local isOdd = (listnum % 2) == 1
    local rowstyle = frame.args.evenstyle
    if isOdd then rowstyle = frame.args.oddstyle end
 
    local evenOdd
    if frame.args.evenodd == 'swap' then
        if isOdd then evenOdd = 'even' else evenOdd = 'odd' end
    else
        if isOdd then evenOdd = frame.args.evenodd or 'odd' else evenOdd = frame.args.evenodd or 'even' end
    end
 
    listCell
        :css('padding', '0px')
        :cssText(frame.args.liststyle)
        :cssText(rowstyle)
        :cssText(frame.args['list' .. listnum .. 'style'])
        :addClass('navbox-list')
        :addClass('navbox-' .. evenOdd)
        :addClass(frame.args.listclass)
        :tag('div')
            :css('padding', (listnum == 1 and frame.args.list1padding) or frame.args.listpadding or '0em 0.25em')
            :wikitext(frame.args['list' .. listnum])
 
    if listnum == 1 and frame.args.image then
        row
            :tag('td')
                :addClass('navbox-image')
                :addClass(frame.args.imageclass)
                :css('width', '0%')
                :css('padding', '0px 0px 0px 2px')
                :cssText(args.imagestyle)
                :attr('rowspan', 2 * #listnums - 1)
                :tag('div')
                    :wikitext(frame.args.image)
    end
end
 
function Navbox._navbox(navboxArgs)
    args = navboxArgs
 
    for k, v in pairs(args) do
        local listnum = ('' .. k):match('^list(%d+)$')
        if listnum then table.insert(listnums, tonumber(listnum)) end
    end
    table.sort(listnums)
 
    border = trim(frame.args.border or frame.args[1] or '')
 
    -- render the main body of the navbox
    local tbl = renderMainTable()
 
    -- render the appropriate wrapper around the navbox, depending on the border param
    local res = HtmlBuilder.create()
    if border == 'none' then
        res.node(tbl)
    elseif border == 'subgroup' or border == 'child' then
        -- We assume that this navbox is being rendered in a list cell of a parent navbox, and is
        -- therefore inside a div with padding:0em 0.25em. We start with a </div> to avoid the
        -- padding being applied, and at the end add a <div> to balance out the parent's </div>
        res
            .tag('/div', {unclosed = true})
                .done()
            .node(tbl)
            .tag('div', {unclosed = true})
    else
        res
            .tag('table')
                .attr('cellspacing', 0)
                .addClass('navbox')
                .css('border-spacing', 0)
                .cssText(args.bodystyle)
                .cssText(args.style)
                .tag('tr')
                    .tag('td')
                        .css('padding', '2px')
                        .node(tbl)
    end
 
    renderTrackingCategories(res)
 
    return tostring(res)
end
 
function Navbox.navbox(frame)
    return Navbox._navbox(frame.args)
end
 
return Navbox

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.