Module:Navbox: Difference between revisions

From Test Wiki
Content deleted Content added
fix title centering
don't need a special function for the list1 row, and fix for border=none
Line 168: Line 168:
-- List rows
-- List rows
--
--
function renderFirstListRow(tbl)
function renderListRow(tbl, listnum)
if not args.list1 then return end
local row = addTableRow(tbl)
local row = addTableRow(tbl)
if args.imageleft then
if listnum == 1 and args.imageleft then
row
row
.tag('td')
.tag('td')
Line 187: Line 185:
end
end
if args.group1 then
local groupCell = row.tag('th')
groupCell
.attr('scope', 'row')
.addClass('navbox-group')
.addClass(args.groupclass)
.cssText(args.basestyle)
if args.groupwidth then
groupCell.css('width', args.groupwidth)
end

groupCell
.cssText(args.groupstyle)
.cssText(args.group1style)
.wikitext(args.group1)
end
local listCell = row.tag('td')
if args.group1 then
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
listCell.css('width', '100%')
end

local evenOdd = args.evenodd or 'odd'
if args.evenodd == 'swap' then evenOdd = 'even' end
listCell
.css('padding', '0px')
.cssText(args.liststyle)
.cssText(args.oddstyle)
.cssText(args.list1style)
.addClass('navbox-list')
.addClass('navbox-' .. evenOdd)
.addClass(args.listclass)
.tag('div')
.css('padding', args.list1padding or args.listpadding or '0em 0.25em')
.newline()
.wikitext(args.list1)

if args.image then
row
.tag('td')
.addClass('navbox-image')
.addClass(args.imageclass)
.css('width', '0%')
.css('padding', '0px 0px 0px 2px')
.cssText(args.imagestyle)
.attr('rowspan', 2 * #listnums - 1)
.tag('div')
.newline()
.wikitext(args.image)
end
end
function renderNthListRow(tbl, listnum)
local row = addTableRow(tbl)
if args['group' .. listnum] then
if args['group' .. listnum] then
local groupCell = row.tag('th')
local groupCell = row.tag('th')
Line 312: Line 242:
.newline()
.newline()
.wikitext(args['list' .. listnum])
.wikitext(args['list' .. listnum])

if listnum == 1 and args.image then
row
.tag('td')
.addClass('navbox-image')
.addClass(args.imageclass)
.css('width', '0%')
.css('padding', '0px 0px 0px 2px')
.cssText(args.imagestyle)
.attr('rowspan', 2 * #listnums - 1)
.tag('div')
.newline()
.wikitext(args.image)
end
end
end


Line 346: Line 290:
renderTitleRow(tbl)
renderTitleRow(tbl)
renderAboveRow(tbl)
renderAboveRow(tbl)
renderFirstListRow(tbl)
-- render lists 2 through N
for i, listnum in ipairs(listnums) do
for i, listnum in ipairs(listnums) do
if listnum > 1 then
renderListRow(tbl, listnum)
renderNthListRow(tbl, listnum)
end
end
end
renderBelowRow(tbl)
renderBelowRow(tbl)
Line 394: Line 332:
.css('padding', '2px')
.css('padding', '2px')
.node(tbl)
.node(tbl)
else -- border == 'none'
res.node(tbl)
end
end