Content deleted Content added
BrandonXLF (talk | contribs) Remove wrappers Tag: Reverted |
let's see what breaks Tag: Reverted |
||
Line 7:
local navbar = require('Module:Navbar')._navbar
local getArgs -- lazily initialized
local cfg = mw.loadData('Module:Navbox/configuration')
local args
Line 20 ⟶ 21:
-- by parent navboxes. The result is that the category shows all pages
-- where a child navbox is not contained in a parent navbox.
if border ==
▲ if border == 'subgroup' and args.orphan ~= 'yes' then
-- No change; striping occurs in outermost navbox.
return wikitext ..
end
local first, second =
if args[cfg.arg.evenodd] then
if args[cfg.arg.evenodd] ==
first, second = second, first
else
first = args[cfg.arg.evenodd]
second = first
end
Line 39:
else
local index = 0
changer = function (code) -- where is code set???
if code == '0' then
-- Current occurrence is for a group before a nested table.
Line 52:
end
end
local regex =
return (wikitext:gsub(regex, ''):gsub(REGEX_MARKER, changer)) -- () omits gsub count
end
Line 62:
return '\n' .. item ..'\n'
end
if nowrapitems ==
local lines = {}
for line in (item .. '\n'):gmatch('([^\n]*)\n') do
local prefix, content = line:match('^([*:;#]+)%s*(.*)')
if prefix and not content:match(
line =
end
table.insert(lines, line)
Line 81:
local function renderNavBar(titleCell)
if args[cfg.arg.navbar] ~= cfg.keyword.navbar_off and
if args.navbar ~= 'off' and args.navbar ~= 'plain' and not (not args.name and mw.getCurrentFrame():getParent():getTitle():gsub('/sandbox$', '') == 'Template:Navbox') then▼
args[cfg.arg.navbar] ~= cfg.keyword.navbar_plain and
▲
titleCell:wikitext(navbar{
args[cfg.arg.name],
[cfg.navbar.mini] = 1,
[cfg.navbar.fontstyle] = (args[cfg.arg.basestyle] or '') .. ';' ..
(args[cfg.arg.titlestyle] or '') .. ';background:none transparent;border:none;box-shadow:none;padding:0;' })
end
Line 95 ⟶ 99:
--
local function renderTitleRow(tbl)
if not args[cfg.arg.title] then return end
local titleRow = tbl:tag('tr')
if args[cfg.arg.titlegroup] then
titleRow
:tag('th')
:attr('scope', 'row')
:addClass(
:addClass(args[cfg.arg.titlegroupclass])
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.groupstyle])
:cssText(args[cfg.arg.titlegroupstyle])
:wikitext(args[cfg.arg.titlegroup])
end
local titleCell = titleRow:tag('th'):attr('scope', 'col')
if args[cfg.arg.titlegroup] then
titleCell
:css('border-left', '2px solid #fdfdfd')
Line 120 ⟶ 124:
local titleColspan = 2
if args[cfg.arg.imageleft] then titleColspan = titleColspan + 1 end
if args[cfg.arg.image] then titleColspan = titleColspan + 1 end
if args[cfg.arg.titlegroup] then titleColspan = titleColspan - 1 end
titleCell
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.titlestyle])
:addClass(
:attr('colspan', titleColspan)
Line 135 ⟶ 139:
:tag('div')
-- id for aria-labelledby attribute
:attr('id', mw.uri.anchorEncode(args[cfg.arg.title]))
:addClass(args[cfg.arg.titleclass])
:css('font-size', '114%')
:css('margin', '0 4em')
:wikitext(processItem(args[cfg.arg.title]))
end
Line 148 ⟶ 152:
local function getAboveBelowColspan()
local ret = 2
if args[cfg.arg.imageleft] then ret = ret + 1 end
if args[cfg.arg.image] then ret = ret + 1 end
return ret
end
local function renderAboveRow(tbl)
if not args[cfg.arg.above] then return end
tbl:tag('tr')
:tag('td')
:addClass(
:addClass(args[cfg.arg.aboveclass])
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.abovestyle])
:attr('colspan', getAboveBelowColspan())
:tag('div')
-- id for aria-labelledby attribute, if no title
:attr('id', args[cfg.arg.title] and nil or mw.uri.anchorEncode(args[cfg.arg.above]))
:wikitext(processItem(args[cfg.arg.above], args[cfg.arg.nowrapitems]))
end
local function renderBelowRow(tbl)
if not args[cfg.arg.below] then return end
tbl:tag('tr')
:tag('td')
:addClass(
:addClass(args[cfg.arg.belowclass])
:cssText(args[cfg.arg.basestyle])
:cssText(args[cfg.arg.belowstyle])
:attr('colspan', getAboveBelowColspan())
:tag('div')
:wikitext(processItem(args[cfg.arg.below], args[cfg.arg.nowrapitems]))
end
Line 189 ⟶ 193:
local row = tbl:tag('tr')
if index == 1 and args[cfg.arg.imageleft] then
row
:tag('td')
:addClass(
:addClass(
:addClass(args[cfg.arg.imageclass])
:css('width', '1px') -- Minimize width
:css('padding', '
:cssText(args[cfg.arg.imageleftstyle])
:attr('rowspan', #listnums)
:tag('div')
:wikitext(processItem(args[cfg.arg.imageleft]))
end
if args[
local groupCell = row:tag('th')
-- id for aria-labelledby attribute, if lone group with no title or above
if listnum == 1 and not (args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group2]) then
groupCell
:attr('id', mw.uri.anchorEncode(args[cfg.arg.group1]))
end
groupCell
:attr('scope', 'row')
:addClass(
:addClass(args[cfg.arg.groupclass])
:cssText(args[cfg.arg.basestyle])
:css('width', args[cfg.arg.groupwidth] or '1%') -- If groupwidth not specified, minimize width
groupCell
:cssText(args[cfg.arg.groupstyle])
:cssText(args[
:wikitext(args[
end
local listCell = row:tag('td')
if args[
listCell
:css('text-align', 'left')
Line 236 ⟶ 240:
end
if not args[cfg.arg.groupwidth] then
listCell:css('width', '100%')
end
Line 242 ⟶ 246:
local rowstyle -- usually nil so cssText(rowstyle) usually adds nothing
if index % 2 == 1 then
rowstyle = args[cfg.arg.oddstyle]
else
rowstyle = args[cfg.arg.evenstyle]
end
local listText = args[
local oddEven = ODD_EVEN_MARKER
if listText:sub(1, 12) == '</div><table' then
-- Assume list text is for a subgroup navbox so no automatic striping for this row.
oddEven = listText:find(
end
listCell
:css('padding', '
:cssText(args[cfg.arg.liststyle])
:cssText(rowstyle)
:cssText(args[
:addClass(
:addClass(
:addClass(args[cfg.arg.listclass])
:addClass(args[
:tag('div')
:css('padding', (index == 1 and args[cfg.arg.list1padding]) or args[cfg.arg.listpadding] or '
:wikitext(processItem(listText, args[cfg.arg.nowrapitems]))
if index == 1 and args[cfg.arg.image] then
row
:tag('td')
:addClass(
:addClass(
:addClass(args[cfg.arg.imageclass])
:css('width', '1px') -- Minimize width
:css('padding', '
:cssText(args[cfg.arg.imagestyle])
:attr('rowspan', #listnums)
:tag('div')
:wikitext(processItem(args[cfg.arg.image]))
end
end
Line 287 ⟶ 291:
local function needsHorizontalLists()
if border ==
return false
end
-- FIXME: These should be finding the classes in list_classes, not looking for equality.
return not (
▲ return not (listClasses[args.listclass] or listClasses[args.bodyclass])
end
local function hasBackgroundColors()
for _, key in ipairs({
cfg.arg.basestyle if tostring(args[key]):find('background', 1, true) then
return true
Line 307 ⟶ 308:
local function hasBorders()
for _, key in ipairs({
cfg.arg.abovestyle if tostring(args[key]):find('border', 1, true) then
return true
Line 318 ⟶ 320:
for key, style in pairs(args) do
if tostring(key):match(
if styleratio{mw.text.unstripNoWiki(style)} < 4.5 then
return true
Line 329 ⟶ 331:
local function getTrackingCategories()
local cats = {}
if needsHorizontalLists() then table.insert(cats,
if hasBackgroundColors() then table.insert(cats,
if isIllegible() then table.insert(cats,
if hasBorders() then table.insert(cats,
return cats
end
Line 340 ⟶ 342:
if title.namespace ~= 10 then return end -- not in template space
local subpage = title.subpageText
if subpage ==
or subpage == cfg.keyword.subpage_testcases then return end
for _, cat in ipairs(getTrackingCategories()) do
Line 352 ⟶ 355:
local function renderMainTable()
local tbl = mw.html.create('table')
:addClass(
:addClass(args[cfg.arg.bodyclass])
if args[cfg.arg.title] and (args[cfg.arg.state] ~=
if args[cfg.arg.state] == cfg.keyword.state_collapsed then args[cfg.arg.state] = cfg.class.collapsed end
tbl
:addClass(
:addClass(args[cfg.arg.state] or
end
tbl:css('border-spacing', 0)
if border ==
tbl
:addClass(
:cssText(args[cfg.arg.bodystyle])
:cssText(args[cfg.arg.style])
else -- regular navbox - bodystyle and style will be applied to the wrapper table
tbl
:addClass(
:css('background', 'transparent')
:css('color', 'inherit')
end
tbl:cssText(args[cfg.arg.innerstyle])
renderTitleRow(tbl)
Line 392 ⟶ 396:
for k, _ in pairs(args) do
if type(k) == 'string' then
local listnum = k:match(
if listnum then table.insert(listnums, tonumber(listnum)) end
end
Line 398 ⟶ 402:
table.sort(listnums)
border = mw.text.trim(args[cfg.arg.border] or args[1] or '')
if border ==
border =
end
Line 408 ⟶ 412:
-- render the appropriate wrapper around the navbox, depending on the border param
local res = mw.html.create()
if border ==
local nav = res:tag('div')
:attr('role', 'navigation')
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
if args[cfg.arg.title] or args[cfg.arg.above] or (args[cfg.arg.group1] and not args[cfg.arg.group2]) then
nav:attr('aria-labelledby', mw.uri.anchorEncode(args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]))
else
nav:attr('aria-label',
end
elseif border ==
-- 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
Line 429 ⟶ 433:
local nav = res:tag('div')
:attr('role', 'navigation')
:addClass(
:addClass(args[cfg.arg.navboxclass])
:cssText(args[cfg.arg.bodystyle])
:cssText(args[cfg.arg.style])
:css('padding', '3px')
:node(tbl)
-- aria-labelledby title, otherwise above, otherwise lone group
if args[cfg.arg.title] or args[cfg.arg.above] or (args[cfg.arg.group1] and not args[cfg.arg.group2]) then
nav:attr('aria-labelledby', mw.uri.anchorEncode(args[cfg.arg.title] or args[cfg.arg.above] or args[cfg.arg.group1]))
else
nav:attr('aria-label',
end
end
if (args[cfg.arg.nocat] or
renderTrackingCategories(res)
end
Line 457 ⟶ 461:
-- Read the arguments in the order they'll be output in, to make references number in the right order.
local _
_ = args[cfg.arg.title]
_ = args[cfg.arg.above]
for i = 1, 20 do
_ = args[
_ = args[
end
_ = args[cfg.arg.below]
return p._navbox(args)
|