Module:Userbox: Difference between revisions

438 bytes added ,  4 years ago
no edit summary
No edit summary
No edit summary
Line 229:
local tableroot = root:tag('table')
tableroot
:attr('role', 'presentation')
:css('border-collapse', 'collapse')
:css('width', data.width)
Line 239 ⟶ 238:
local tablerow = tableroot:tag('tr')
if data.showId then
tablerow:tag('tdth')
:css('border', '0')
:css('width', data.idWidth)
Line 246 ⟶ 245:
:css('text-align', data.idTextAlign)
:css('font-size', data.idFontSize)
:css('font-weight', 'bold')
:css('color', data.idColor)
:css('padding', data.idPadding)
Line 272 ⟶ 270:
-- Render the second id html.
if data.showId2 then
tablerow:tag('tdth')
:css('border', '0')
:css('width', data.id2Width)
Line 279 ⟶ 277:
:css('text-align', data.id2TextAlign)
:css('font-size', data.id2FontSize)
:css('font-weight', 'bold')
:css('color', data.id2Color)
:css('padding', data.id2Padding)
Line 297 ⟶ 294:
end
 
local legible = true
local contrast = require('Module:Color contrast')._ratio
 
Line 309 ⟶ 307:
wikitext = wikitext:gsub("%[%[%s*[Ff][Ii][Ll][Ee]%s*:[^|]-(|.-)]]", get_alt)
return mw.text.trim(wikitext) ~= ""
end
 
if contrast { data.infoColor, data.backgroundColor, error = 0 } < 4.5 then
legible = false
end
 
if data.showId and contrast { data.idColor, data.idBackgroundColor, error = 0 } < 4.5 then
if has_text(data.id or "") then
legible = false
end
end
 
if data.showId2 and contrast { data.id2Color, data.id2BackgroundColor, error = 0 } < 4.5 then
if has_text(data.id2 or "") then
legible = false
end
end
 
if not legible then
root:wikitext('[[Category:Potentially illegible userboxes]]')
end
 
0

edits