Changes
Jump to navigation
Jump to search
local HtmlBuilder = require('Module:HtmlBuilder')
.:tag('tr') .:css('height', '2px') .:tag('td') .:attr('colspan',2)
local spacerSide = nil
if args.navbar == 'off' then
.:tag('span') .:css('float', spacerSide) .:css('width', '6em') .:wikitext(' ')
.:tag('th') .:attr('scope', 'row') .:addClass('navbox-group') .:addClass(args.titlegroupclass) .:cssText(args.basestyle) .:cssText(args.groupstyle) .:cssText(args.titlegroupstyle) .:wikitext(args.titlegroup)
.:css('border-left', '2px solid #fdfdfd') .:css('width', '100%')
.:cssText(args.basestyle) .:cssText(args.titlestyle) .:addClass('navbox-title') .:attr('colspan', titleColspan)
.:tag('div') .:addClass(args.titleclass) .:css('font-size', '110%') .:wikitext(addNewline(args.title))
.:tag('td') .:addClass('navbox-abovebelow') .:addClass(args.aboveclass) .:cssText(args.basestyle) .:cssText(args.abovestyle) .:attr('colspan', getAboveBelowColspan()) .:tag('div') .:wikitext(addNewline(args.above))
.:tag('td') .:addClass('navbox-abovebelow') .:addClass(args.belowclass) .:cssText(args.basestyle) .:cssText(args.belowstyle) .:attr('colspan', getAboveBelowColspan()) .:tag('div') .:wikitext(addNewline(args.below))
.:tag('td') .:addClass('navbox-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))
if args['group' .. listnum] then local groupCell = row.:tag('th') groupCell . :attr('scope', 'row') . :addClass('navbox-group') . :addClass(args.groupclass) . :cssText(args.basestyle)
groupCell .:cssText(args.groupstyle) .:cssText(args['group' .. listnum .. 'style']) .:wikitext(args['group' .. listnum])
if args['group' .. listnum] then
.:css('text-align', 'left') .:css('border-left-width', '2px') .:css('border-left-style', 'solid')
.:css('padding', '0px') .:cssText(args.liststyle) .:cssText(rowstyle) .:cssText(args['list' .. listnum .. 'style']) .:addClass('navbox-list') .:addClass('navbox-' .. 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]))
.: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') .:wikitext(addNewline(args.image))
if border == 'child' or border == 'subgroup' or args.tracking == 'no' then return false end
.:addClass('collapsible') .:addClass(args.state or 'autocollapse')
.:addClass('navbox-subgroup') .:cssText(args.bodystyle) .:cssText(args.style)
.:addClass('navbox-inner') .:css('background', 'transparent') .:css('color', 'inherit')
.tag:wikitext('</div>', {) -- XXX: hack due to lack of unclosed = true}) support in mw.html.done() .:node(tbl) .tag:wikitext('<div>', {) -- XXX: hack due to lack of unclosed = true})support in mw.html.
.: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)
switch to mw.html per talk page (no objections)
--
-- This module will implement implements {{Navbox}}
--
local p = {}
local navbar = require('Module:Navbar')._navbar
local getArgs -- lazily initialized
local border
local listnums = {}
local function trim(s)
return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
if tableRowAdded then
tbl
end
tableRowAdded = true
return tbl.:tag('tr')
end
-- Depending on the presence of the navbar and/or show/hide link, we may need to add a spacer div on the left
-- or right to keep the title centered.
-- No navbar, and client wants no spacer, i.e. wants the title to be shifted to the left. If there's
-- also no show/hide link, then we need a spacer on the right to achieve the left shift.
if args.state == 'plain' then spacerSide = 'right' end
titleCell.:wikitext(navbar{
args.name,
mini = 1,
if spacerSide then
titleCell
end
end
local titleRow = addTableRow(tbl)
if args.titlegroup then
titleRow
end
local titleCell = titleRow.:tag('th').:attr('scope', 'col')
if args.titlegroup then
titleCell
end
titleCell
renderNavBar(titleCell)
titleCell
end
addTableRow(tbl)
end
addTableRow(tbl)
end
if listnum == 1 and args.imageleft then
row
end
if args.groupwidth then
groupCell.:css('width', args.groupwidth)
end
end
local listCell = row.:tag('td')
listCell
else
listCell.:attr('colspan', 2)
end
if not args.groupwidth then
listCell.:css('width', '100%')
end
listCell
if listnum == 1 and args.image then
row
end
end
local function needsHorizontalLists()
local listClasses = {'plainlist', 'hlist', 'hlist hnum', 'hlist hwrap', 'hlist vcard', 'vcard hlist', 'hlist vevent'}
for i, cat in ipairs(getTrackingCategories()) do
builder.:wikitext('[[Category:' .. cat .. ']]')
end
end
--
local function renderMainTable()
local tbl = HtmlBuildermw.html.create('table') .:attr('cellspacing', 0) .:addClass('nowraplinks') .:addClass(args.bodyclass)
if args.title and (args.state ~= 'plain' and args.state ~= 'off') then
tbl
end
tbl.:css('border-spacing', 0)
if border == 'subgroup' or border == 'child' or border == 'none' then
tbl
else -- regular navobx - bodystyle and style will be applied to the wrapper table
tbl
end
tbl.:cssText(args.innerstyle)
renderTitleRow(tbl)
-- render the appropriate wrapper around the navbox, depending on the border param
local res = HtmlBuildermw.html.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
-- padding being applied, and at the end add a <div> to balance out the parent's </div>
res
else
res
end