Module:Navbox: Difference between revisions
Change navbox template |
change module navbox to wikipedia |
||
Line 77: | Line 77: | ||
end | end | ||
return item | return item | ||
end | end | ||
local function renderNavBar(titleCell) | local function renderNavBar(titleCell) | ||
if | if args.navbar ~= 'off' and args.navbar ~= 'plain' and not (not args.name and mw.getCurrentFrame():getParent():getTitle():gsub('/sandbox$', '') == 'Template:Navbox') then | ||
titleCell:wikitext(navbar{ | titleCell:wikitext(navbar{ | ||
args.name, | args.name, | ||
mini = 1, | mini = 1, | ||
fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;box-shadow:none; padding:0;' | fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;box-shadow:none;padding:0;' | ||
}) | }) | ||
end | end | ||
Line 125: | Line 115: | ||
if args.titlegroup then | if args.titlegroup then | ||
titleCell | titleCell | ||
: | :css('border-left', '2px solid #fdfdfd') | ||
:css('width', '100%') | |||
end | end | ||
Line 201: | Line 192: | ||
row | row | ||
:tag('td') | :tag('td') | ||
:addClass('noviewer') | |||
:addClass('navbox-image') | :addClass('navbox-image') | ||
:addClass(args.imageclass) | :addClass(args.imageclass) | ||
Line 237: | Line 229: | ||
if args['group' .. listnum] then | if args['group' .. listnum] then | ||
listCell | listCell | ||
: | :css('text-align', 'left') | ||
:css('border-left-width', '2px') | |||
:css('border-left-style', 'solid') | |||
else | else | ||
listCell:attr('colspan', 2) | listCell:attr('colspan', 2) | ||
Line 275: | Line 269: | ||
row | row | ||
:tag('td') | :tag('td') | ||
:addClass('noviewer') | |||
:addClass('navbox-image') | :addClass('navbox-image') | ||
:addClass(args.imageclass) | :addClass(args.imageclass) | ||
Line 301: | Line 296: | ||
} | } | ||
return not (listClasses[args.listclass] or listClasses[args.bodyclass]) | return not (listClasses[args.listclass] or listClasses[args.bodyclass]) | ||
end | end | ||
Line 370: | Line 315: | ||
local function isIllegible() | 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 | return false | ||
end | end | ||
Line 452: | Line 405: | ||
-- render the main body of the navbox | -- render the main body of the navbox | ||
local tbl = renderMainTable() | local tbl = renderMainTable() | ||
-- | -- render the appropriate wrapper around the navbox, depending on the border param | ||
local res = mw.html.create() | local res = mw.html.create() | ||
if border == 'none' then | if border == 'none' then | ||
local nav = res:tag('div') | local nav = res:tag('div') | ||
:attr('role', 'navigation') | :attr('role', 'navigation') | ||
:node(tbl) | :node(tbl) | ||
-- aria-labelledby title, otherwise above, otherwise lone group | -- aria-labelledby title, otherwise above, otherwise lone group | ||
Line 490: | Line 419: | ||
end | end | ||
elseif border == 'subgroup' then | elseif border == 'subgroup' then | ||
-- We assume that this navbox is being rendered in a list cell of a | -- 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 | |||
-- padding being applied, and at the end add a <div> to balance out the parent's </div> | |||
res | res | ||
:wikitext('</div>') | :wikitext('</div>') | ||
:node(tbl) | :node(tbl) | ||
:wikitext('<div>') | :wikitext('<div>') | ||
Line 507: | Line 434: | ||
:cssText(args.style) | :cssText(args.style) | ||
:css('padding', '3px') | :css('padding', '3px') | ||
:node(tbl) | :node(tbl) | ||
-- aria-labelledby title, otherwise above, otherwise lone group | -- aria-labelledby title, otherwise above, otherwise lone group | ||
Line 520: | Line 446: | ||
renderTrackingCategories(res) | renderTrackingCategories(res) | ||
end | end | ||
return striped(tostring(res)) | return striped(tostring(res)) | ||
end | end | ||
Line 528: | Line 453: | ||
getArgs = require('Module:Arguments').getArgs | getArgs = require('Module:Arguments').getArgs | ||
end | end | ||
args = getArgs(frame, {wrappers = {'Template:Navbox | args = getArgs(frame, {wrappers = {'Template:Navbox'}}) | ||
-- Read the arguments in the order they'll be output in, to make references number in the right order. | -- Read the arguments in the order they'll be output in, to make references number in the right order. |