Module:Navbox: Difference between revisions

The revision 41155 by Hapsbro(talk) has been undone.
(Testing different version of module; will immediately revert if this does not produce the intended result)
(The revision 41155 by Hapsbro(talk) has been undone.)
Tag: Undo
 
Line 9:
 
local args
local tableRowAdded = false
local border
local listnums = {}
Line 57 ⟶ 56:
end
 
local function addNewlineprocessItem(sitem, nowrapitems)
if sitem:matchsub('^[*:;#]'1, 2) or== s:match('^{|') then
-- Applying nowrap to lines in a table does not make sense.
return '\n' .. s ..'\n'
-- Add newlines to compensate for trim of x in |parm=x in a template.
else
return s'\n' .. item ..'\n'
end
if nowrapitems == 'yes' then
end
local lines = {}
 
for line in (item .. '\n'):gmatch('([^\n]*)\n') do
local function addTableRow(tbl)
local prefix, content = line:match('^([*:;#]+)%s*(.*)')
-- If any other rows have already been added, then we add a 2px gutter row.
if prefix and not content:match('^<span class="nowrap">') then
if tableRowAdded then
line = prefix .. '<span class="nowrap">' .. content .. '</span>'
tbl
:tag('tr')end
:csstable.insert('height'lines, '2px'line)
end
:tag('td')
item = table.concat(lines, '\n')
:attr('colspan',2)
end
if item:match('^[*:;#]') then
 
return '\n' .. sitem ..'\n'
tableRowAdded = true
end
 
return tbl:tag('tr')item
end
 
Line 86 ⟶ 85:
args.name,
mini = 1,
fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;'
})
end
Line 98 ⟶ 97:
if not args.title then return end
 
local titleRow = addTableRow(tbl:tag('tr')
 
if args.titlegroup then
Line 139 ⟶ 138:
:css('font-size', '114%')
:css('margin', '0 4em')
:wikitext(addNewlineprocessItem(args.title))
end
 
Line 156 ⟶ 155:
if not args.above then return end
 
tbl:tag('tdtr')
addTableRow(tbl)
:tag('td')
:addClass('navbox-abovebelow')
Line 164 ⟶ 163:
:attr('colspan', getAboveBelowColspan())
:tag('div')
:wikitext(addNewlineprocessItem(args.above, args.nowrapitems))
end
 
Line 170 ⟶ 169:
if not args.below then return end
 
tbl:tag('tr')
addTableRow(tbl)
:tag('td')
:addClass('navbox-abovebelow')
Line 178 ⟶ 177:
:attr('colspan', getAboveBelowColspan())
:tag('div')
:wikitext(addNewlineprocessItem(args.below, args.nowrapitems))
end
 
Line 185 ⟶ 184:
--
local function renderListRow(tbl, index, listnum)
local row = addTableRow(tbl:tag('tr')
 
if index == 1 and args.imageleft then
Line 192 ⟶ 191:
:addClass('navbox-image')
:addClass(args.imageclass)
:css('width', '0%1px') -- Minimize width
:css('padding', '0px 2px 0px 0px')
:cssText(args.imageleftstyle)
:attr('rowspan', 2 * #listnums - 1)
:tag('div')
:wikitext(addNewlineprocessItem(args.imageleft))
end
 
Line 208 ⟶ 207:
:addClass(args.groupclass)
:cssText(args.basestyle)
:css('width', args.groupwidth or '1%') -- If groupwidth not specified, minimize width
 
if args.groupwidth then
groupCell:css('width', args.groupwidth)
end
 
groupCell
Line 257 ⟶ 253:
:tag('div')
:css('padding', (index == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
:wikitext(addNewlineprocessItem(listText, args.nowrapitems))
 
if index == 1 and args.image then
Line 264 ⟶ 260:
:addClass('navbox-image')
:addClass(args.imageclass)
:css('width', '0%1px') -- Minimize width
:css('padding', '0px 0px 0px 2px')
:cssText(args.imagestyle)
:attr('rowspan', 2 * #listnums - 1)
:tag('div')
:wikitext(addNewlineprocessItem(args.image))
end
end
Line 325 ⟶ 321:
if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end
 
for i_, cat in ipairs(getTrackingCategories()) do
builder:wikitext('[[Category:' .. cat .. ']]')
end
Line 371 ⟶ 367:
args = navboxArgs
 
for k, v_ in pairs(args) do
if type(k) == 'string' then
local listnum = ('' .. k):match('^list(%d+)$')
if local listnum then= table.insertk:match(listnums, tonumber'^list(listnum%d+)$') end
if listnum then table.insert(listnums, tonumber(listnum)) end
end
end
table.sort(listnums)