Anonymous user
Module:Navbox: Difference between revisions
navigation div instead of single-cell table wrapper
m (1 revision imported: categories) |
(navigation div instead of single-cell table wrapper) |
||
Line 116:
titleCell
:wikitext(addNewline(args.title))
end
Line 271 ⟶ 272:
local function hasBackgroundColors()
return mw.ustring.match(args.titlestyle or '','background') or mw.ustring.match(args.groupstyle or '','background') or mw.ustring.match(args.basestyle or '','background')
end
local function isIllegible()
local styleratio = require('Module:Color contrast')._styleratio
for key, style in pairs(args) do
if tostring(key):match("style$") then
if styleratio{mw.text.unstripNoWiki(style)} < 4.5 then
return true
end
end
end
return false
end
Line 277 ⟶ 291:
if needsHorizontalLists() then table.insert(cats, 'Navigational boxes without horizontal lists') end
if hasBackgroundColors() then table.insert(cats, 'Navboxes using background colours') end
if isIllegible() then table.insert(cats, 'Potentially illegible navboxes') end
return cats
end
Line 346 ⟶ 361:
local res = mw.html.create()
if border == 'none' then
local nav = res:
:attr('role', 'navigation')
:node(tbl)
if args.title then
nav:attr('aria-labelledby', mw.uri.anchorEncode(args.title))
else
nav:attr('aria-label', 'Navbox')
end
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
Line 356 ⟶ 378:
:wikitext('<div>') -- XXX: hack due to lack of unclosed support in mw.html.
else
local nav = res:tag('div')
:
if args.title
nav:attr('aria-label', 'Navbox')
end
end
|