Mudanças entre as edições de "Predefinição:Navbox"

De Micropedia
Ir para navegação Ir para pesquisar
(Criou página com '-- -- This module implements {{Navbox}} -- local p = {} local navbar = require('Module:Navbar')._navbar local getArgs -- lazily initialized local args local border local li...')
 
m (Protegido "Predefinição:Navbox" ([Editar=Permitir apenas administradores] (indefinidamente) [Mover=Permitir apenas administradores] (indefinidamente)))
 
(Uma revisão intermediária por um outro usuário não está sendo mostrada)
Linha 1: Linha 1:
--
+
{{#switch:{{{border|{{{1|}}}}}}|subgroup|child=</div>|none=|#default=<table class="navbox {{{bodyclass|}}}" cellspacing="0" <!--
-- This module implements {{Navbox}}
+
-->style="{{{bodystyle|}}};{{{style|}}}"><tr><td style="padding:2px;">}}<!--
--
 
  
local p = {}
+
--><table cellspacing="0" class="nowraplinks {{#if:{{{title|}}}|{{#switch:{{{state|}}}|plain|off=|<!--
 +
-->#default=collapsible {{#if:{{{state|}}}|{{{state}}}|autocollapse}}}}}} {{#switch:{{{border|{{{1|}}}}}}|<!--
 +
-->subgroup|child|none=navbox-subgroup" style="width:100%;{{{bodystyle|}}};{{{style|}}}|<!--
 +
-->#default=" style="width:100%;background:transparent;color:inherit}};{{{innerstyle|}}};"><!--
  
local navbar = require('Module:Navbar')._navbar
 
local getArgs -- lazily initialized
 
  
local args
+
---Title and Navbar---
local border
+
-->{{#if:{{{title|}}}|<tr>{{#if:{{{titlegroup|}}}|<!--
local listnums = {}
+
--><td class="navbox-group" style="{{{basestyle|}}};{{{groupstyle|}}};{{{titlegroupstyle|}}}">{{{titlegroup|}}}</td><!--
local ODD_EVEN_MARKER = '\127_ODDEVEN_\127'
+
--><th style="border-left:2px solid #fdfdfd;width:100%;|<th style="}}{{{basestyle|}}};{{{titlestyle|}}}" <!--
local RESTART_MARKER = '\127_ODDEVEN0_\127'
+
-->colspan={{#expr:2{{#if:{{{imageleft|}}}|+1}}{{#if:{{{image|}}}|+1}}{{#if:{{{titlegroup|}}}|-1}}}} <!--
local REGEX_MARKER = '\127_ODDEVEN(%d?)_\127'
+
-->class="navbox-title"><!--
  
local function striped(wikitext)
+
-->{{#if:{{#switch:{{{navbar|}}}|plain|off=1}}<!--
-- Return wikitext with markers replaced for odd/even striping.
+
-->{{#if:{{{name|}}}||{{#switch:{{{border|{{{1|}}}}}}|subgroup|child|none=1}}}}|<!--
-- Child (subgroup) navboxes are flagged with a category that is removed
+
-->{{#ifeq:{{{navbar|}}}|off|{{#ifeq:{{{state|}}}|plain|<span style="float:right;width:6em;">&nbsp;</span>}}|<!--
-- by parent navboxes. The result is that the category shows all pages
+
-->{{#ifeq:{{{state|}}}|plain||<span style="float:left;width:6em;">&nbsp;</span>}}}}|<!--
-- where a child navbox is not contained in a parent navbox.
+
--><span style="float:left;width:6em;text-align:left;">{{#if:{{{name|}}}|<!--
local orphanCat = '[[Category:Navbox orphans]]'
+
-->{{Navbar|{{{name}}}|mini=1|fontstyle={{{basestyle|}}};{{{titlestyle|}}};<!--
if border == 'subgroup' and args.orphan ~= 'yes' then
+
-->background:none transparent;border:none;font-size:100%;}}|<!--
-- No change; striping occurs in outermost navbox.
+
--><span class="error" style="white-space:nowrap;">Error: No name provided</span>}}</span><!--
return wikitext .. orphanCat
+
-->{{#ifeq:{{{state|}}}|plain|<span style="float:right;width:6em;">&nbsp;</span>}}}}<!--
end
 
local first, second = 'odd', 'even'
 
if args.evenodd then
 
if args.evenodd == 'swap' then
 
first, second = second, first
 
else
 
first = args.evenodd
 
second = first
 
end
 
end
 
local changer
 
if first == second then
 
changer = first
 
else
 
local index = 0
 
changer = function (code)
 
if code == '0' then
 
-- Current occurrence is for a group before a nested table.
 
-- Set it to first as a valid although pointless class.
 
-- The next occurrence will be the first row after a title
 
-- in a subgroup and will also be first.
 
index = 0
 
return first
 
end
 
index = index + 1
 
return index % 2 == 1 and first or second
 
end
 
end
 
local regex = orphanCat:gsub('([%[%]])', '%%%1')
 
return (wikitext:gsub(regex, ''):gsub(REGEX_MARKER, changer))  -- () omits gsub count
 
end
 
  
local function processItem(item, nowrapitems)
+
--><span class="{{{titleclass|}}}" style="font-size:{{#switch:{{{border|{{{1|}}}}}}|subgroup|child|none=100|#default=110}}%;"><!--
if item:sub(1, 2) == '{|' then
+
-->{{{title}}}</span></th></tr>}}<!--
-- Applying nowrap to lines in a table does not make sense.
 
-- Add newlines to compensate for trim of x in |parm=x in a template.
 
return '\n' .. item ..'\n'
 
end
 
if nowrapitems == 'yes' then
 
local lines = {}
 
for line in (item .. '\n'):gmatch('([^\n]*)\n') do
 
local prefix, content = line:match('^([*:;#]+)%s*(.*)')
 
if prefix and not content:match('^<span class="nowrap">') then
 
line = prefix .. '<span class="nowrap">' .. content .. '</span>'
 
end
 
table.insert(lines, line)
 
end
 
item = table.concat(lines, '\n')
 
end
 
if item:match('^[*:;#]') then
 
return '\n' .. item ..'\n'
 
end
 
return item
 
end
 
  
local function renderNavBar(titleCell)
 
  
if args.navbar ~= 'off' and args.navbar ~= 'plain' and not (not args.name and mw.getCurrentFrame():getParent():getTitle():gsub('/sandbox$', '') == 'Template:Navbox') then
+
---Above---
titleCell:wikitext(navbar{
+
-->{{#if:{{{above|}}}|<!--
args.name,
+
-->{{#if:{{{title|}}}|<tr style="height:2px;"><td></td></tr>}}<!--
mini = 1,
+
--><tr><td class="navbox-abovebelow" style="{{{basestyle|}}};{{{abovestyle|}}}" <!--
fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;'
+
-->colspan="{{#expr:2{{#if:{{{imageleft|}}}|+1}}{{#if:{{{image|}}}|+1}}}}">{{{above}}}</td></tr>}}<!--
})
 
end
 
  
end
 
  
--
+
---Body---
--   Title row
 
--
 
local function renderTitleRow(tbl)
 
if not args.title then return end
 
  
local titleRow = tbl:tag('tr')
+
---First group/list and images---
 +
-->{{#if:{{{list1|}}}|{{#if:{{{title|}}}{{{above|}}}|<tr style="height:2px;"><td></td></tr>}}<tr><!--
  
if args.titlegroup then
+
-->{{#if:{{{imageleft|}}}|<!--
titleRow
+
--><td style="width:0%;padding:0px 2px 0px 0px;{{{imageleftstyle|}}}" <!--
:tag('th')
+
-->rowspan={{#expr:1{{#if:{{{list2|}}}|+2}}{{#if:{{{list3|}}}|+2}}{{#if:{{{list4|}}}|+2}}<!--
:attr('scope', 'row')
+
-->{{#if:{{{list5|}}}|+2}}{{#if:{{{list6|}}}|+2}}{{#if:{{{list7|}}}|+2}}{{#if:{{{list8|}}}|+2}}<!--
:addClass('navbox-group')
+
-->{{#if:{{{list9|}}}|+2}}{{#if:{{{list10|}}}|+2}}{{#if:{{{list11|}}}|+2}}{{#if:{{{list12|}}}|+2}}<!--
:addClass(args.titlegroupclass)
+
-->{{#if:{{{list13|}}}|+2}}{{#if:{{{list14|}}}|+2}}{{#if:{{{list15|}}}|+2}}{{#if:{{{list16|}}}|+2}}<!--
:cssText(args.basestyle)
+
-->{{#if:{{{list17|}}}|+2}}{{#if:{{{list18|}}}|+2}}{{#if:{{{list19|}}}|+2}}{{#if:{{{list20|}}}|+2}}}}><!--
:cssText(args.groupstyle)
+
-->{{{imageleft}}}</td>}}<!--
:cssText(args.titlegroupstyle)
 
:wikitext(args.titlegroup)
 
end
 
  
local titleCell = titleRow:tag('th'):attr('scope', 'col')
+
-->{{#if:{{{group1|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group1style|}}}"><!--
 +
-->{{{group1}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
 +
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list1style|}}}" <!--
 +
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
 +
--><div style="padding:{{{list1padding|{{{listpadding|0em 0.25em}}}}}}">
 +
{{{list1}}}</div></td><!--
  
if args.titlegroup then
+
-->{{#if:{{{image|}}}|<!--
titleCell
+
--><td style="width:0%;padding:0px 0px 0px 2px;{{{imagestyle|}}}" <!--
:css('border-left', '2px solid #fdfdfd')
+
-->rowspan={{#expr:1{{#if:{{{list2|}}}|+2}}{{#if:{{{list3|}}}|+2}}{{#if:{{{list4|}}}|+2}}<!--
:css('width', '100%')
+
-->{{#if:{{{list5|}}}|+2}}{{#if:{{{list6|}}}|+2}}{{#if:{{{list7|}}}|+2}}{{#if:{{{list8|}}}|+2}}<!--
end
+
-->{{#if:{{{list9|}}}|+2}}{{#if:{{{list10|}}}|+2}}{{#if:{{{list11|}}}|+2}}{{#if:{{{list12|}}}|+2}}<!--
 +
-->{{#if:{{{list13|}}}|+2}}{{#if:{{{list14|}}}|+2}}{{#if:{{{list15|}}}|+2}}{{#if:{{{list16|}}}|+2}}<!--
 +
-->{{#if:{{{list17|}}}|+2}}{{#if:{{{list18|}}}|+2}}{{#if:{{{list19|}}}|+2}}{{#if:{{{list20|}}}|+2}}}}><!--
 +
-->{{{image}}}</td>}}<!--
  
local titleColspan = 2
+
--></tr>}}<!--
if args.imageleft then titleColspan = titleColspan + 1 end
 
if args.image then titleColspan = titleColspan + 1 end
 
if args.titlegroup then titleColspan = titleColspan - 1 end
 
  
titleCell
 
:cssText(args.basestyle)
 
:cssText(args.titlestyle)
 
:addClass('navbox-title')
 
:attr('colspan', titleColspan)
 
  
renderNavBar(titleCell)
+
---Remaining groups/lists---
  
titleCell
+
-->{{#if:{{{list2|}}}|<!--
:tag('div')
+
-->{{#if:{{{title|}}}{{{above|}}}{{{list1|}}}|<tr style="height:2px"><td></td></tr>}}<tr><!--
-- id for aria-labelledby attribute
+
-->{{#if:{{{group2|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group2style|}}}"><!--
:attr('id', mw.uri.anchorEncode(args.title))
+
-->{{{group2}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
:addClass(args.titleclass)
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list2style|}}}" <!--
:css('font-size', '114%')
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
:css('margin', '0 4em')
+
--><div style="padding:{{{listpadding|0em 0.25em}}}">
:wikitext(processItem(args.title))
+
{{{list2}}}</div></td></tr>}}<!--
end
 
  
--
+
-->{{#if:{{{list3|}}}|<!--
--   Above/Below rows
+
-->{{#if:{{{title|}}}{{{above|}}}{{{list1|}}}{{{list2|}}}|<tr style="height:2px"><td></td></tr>}}<tr><!--
--
+
-->{{#if:{{{group3|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group3style|}}}"><!--
 +
-->{{{group3}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
 +
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list3style|}}}" <!--
 +
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list3}}}</div></td></tr>}}<!--
  
local function getAboveBelowColspan()
+
-->{{#if:{{{list4|}}}|<!--
local ret = 2
+
--><tr style="height:2px"><td></td></tr><tr><!--
if args.imageleft then ret = ret + 1 end
+
-->{{#if:{{{group4|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group4style|}}}"><!--
if args.image then ret = ret + 1 end
+
-->{{{group4}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
return ret
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list4style|}}}" <!--
end
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list4}}}</div></td></tr>}}<!--
  
local function renderAboveRow(tbl)
+
-->{{#if:{{{list5|}}}|<!--
if not args.above then return end
+
--><tr style="height:2px"><td></td></tr><tr><!--
 +
-->{{#if:{{{group5|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group5style|}}}"><!--
 +
-->{{{group5}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
 +
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list5style|}}}" <!--
 +
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list5}}}</div></td></tr>}}<!--
  
tbl:tag('tr')
+
-->{{#if:{{{list6|}}}|<!--
:tag('td')
+
--><tr style="height:2px"><td></td></tr><tr><!--
:addClass('navbox-abovebelow')
+
-->{{#if:{{{group6|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group6style|}}}"><!--
:addClass(args.aboveclass)
+
-->{{{group6}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
:cssText(args.basestyle)
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list6style|}}}" <!--
:cssText(args.abovestyle)
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
:attr('colspan', getAboveBelowColspan())
+
--><div style="padding:{{{listpadding|0em 0.25em}}}">
:tag('div')
+
{{{list6}}}</div></td></tr>}}<!--
-- id for aria-labelledby attribute, if no title
 
:attr('id', args.title and nil or mw.uri.anchorEncode(args.above))
 
:wikitext(processItem(args.above, args.nowrapitems))
 
end
 
  
local function renderBelowRow(tbl)
+
-->{{#if:{{{list7|}}}|<!--
if not args.below then return end
+
--><tr style="height:2px"><td></td></tr><tr><!--
 +
-->{{#if:{{{group7|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group7style|}}}"><!--
 +
-->{{{group7}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
 +
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list7style|}}}" <!--
 +
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list7}}}</div></td></tr>}}<!--
  
tbl:tag('tr')
+
-->{{#if:{{{list8|}}}|<!--
:tag('td')
+
--><tr style="height:2px"><td></td></tr><tr><!--
:addClass('navbox-abovebelow')
+
-->{{#if:{{{group8|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group8style|}}}"><!--
:addClass(args.belowclass)
+
-->{{{group8}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
:cssText(args.basestyle)
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list8style|}}}" <!--
:cssText(args.belowstyle)
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
:attr('colspan', getAboveBelowColspan())
+
--><div style="padding:{{{listpadding|0em 0.25em}}}">
:tag('div')
+
{{{list8}}}</div></td></tr>}}<!--
:wikitext(processItem(args.below, args.nowrapitems))
 
end
 
  
--
+
-->{{#if:{{{list9|}}}|<!--
--   List rows
+
--><tr style="height:2px"><td></td></tr><tr><!--
--
+
-->{{#if:{{{group9|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group9style|}}}"><!--
local function renderListRow(tbl, index, listnum)
+
-->{{{group9}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
local row = tbl:tag('tr')
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list9style|}}}" <!--
 +
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list9}}}</div></td></tr>}}<!--
  
if index == 1 and args.imageleft then
+
-->{{#if:{{{list10|}}}|<!--
row
+
--><tr style="height:2px"><td></td></tr><tr><!--
:tag('td')
+
-->{{#if:{{{group10|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group10style|}}}"><!--
:addClass('navbox-image')
+
-->{{{group10}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
:addClass(args.imageclass)
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list10style|}}}" <!--
:css('width', '1px')              -- Minimize width
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
:css('padding', '0px 2px 0px 0px')
+
--><div style="padding:{{{listpadding|0em 0.25em}}}">
:cssText(args.imageleftstyle)
+
{{{list10}}}</div></td></tr>}}<!--
:attr('rowspan', #listnums)
 
:tag('div')
 
:wikitext(processItem(args.imageleft))
 
end
 
  
if args['group' .. listnum] then
+
-->{{#if:{{{list11|}}}|<!--
local groupCell = row:tag('th')
+
--><tr style="height:2px"><td></td></tr><tr><!--
 +
-->{{#if:{{{group11|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group11style|}}}"><!--
 +
-->{{{group11}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
 +
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list11style|}}}" <!--
 +
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list11}}}</div></td></tr>}}<!--
  
-- id for aria-labelledby attribute, if lone group with no title or above
+
-->{{#if:{{{list12|}}}|<!--
if listnum == 1 and not (args.title or args.above or args.group2) then
+
--><tr style="height:2px"><td></td></tr><tr><!--
groupCell
+
-->{{#if:{{{group12|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group12style|}}}"><!--
:attr('id', mw.uri.anchorEncode(args.group1))
+
-->{{{group12}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
end
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list12style|}}}" <!--
 +
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list12}}}</div></td></tr>}}<!--
  
groupCell
+
-->{{#if:{{{list13|}}}|<!--
:attr('scope', 'row')
+
--><tr style="height:2px"><td></td></tr><tr><!--
:addClass('navbox-group')
+
-->{{#if:{{{group13|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group13style|}}}"><!--
:addClass(args.groupclass)
+
-->{{{group13}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
:cssText(args.basestyle)
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list13style|}}}" <!--
            :css('width', args.groupwidth or '1%') -- If groupwidth not specified, minimize width
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list13}}}</div></td></tr>}}<!--
  
groupCell
+
-->{{#if:{{{list14|}}}|<!--
:cssText(args.groupstyle)
+
--><tr style="height:2px"><td></td></tr><tr><!--
:cssText(args['group' .. listnum .. 'style'])
+
-->{{#if:{{{group14|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group14style|}}}"><!--
:wikitext(args['group' .. listnum])
+
-->{{{group14}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
end
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list14style|}}}" <!--
 +
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list14}}}</div></td></tr>}}<!--
  
local listCell = row:tag('td')
+
-->{{#if:{{{list15|}}}|<!--
 +
--><tr style="height:2px"><td></td></tr><tr><!--
 +
-->{{#if:{{{group15|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group15style|}}}"><!--
 +
-->{{{group15}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
 +
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list15style|}}}" <!--
 +
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list15}}}</div></td></tr>}}<!--
  
if args['group' .. listnum] then
+
-->{{#if:{{{list16|}}}|<!--
listCell
+
--><tr style="height:2px"><td></td></tr><tr><!--
:css('text-align', 'left')
+
-->{{#if:{{{group16|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group16style|}}}"><!--
:css('border-left-width', '2px')
+
-->{{{group16}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
:css('border-left-style', 'solid')
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list16style|}}}" <!--
else
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
listCell:attr('colspan', 2)
+
--><div style="padding:{{{listpadding|0em 0.25em}}}">
end
+
{{{list16}}}</div></td></tr>}}<!--
  
if not args.groupwidth then
+
-->{{#if:{{{list17|}}}|<!--
listCell:css('width', '100%')
+
--><tr style="height:2px"><td></td></tr><tr><!--
end
+
-->{{#if:{{{group17|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group17style|}}}"><!--
 +
-->{{{group17}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
 +
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list17style|}}}" <!--
 +
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list17}}}</div></td></tr>}}<!--
  
local rowstyle -- usually nil so cssText(rowstyle) usually adds nothing
+
-->{{#if:{{{list18|}}}|<!--
if index % 2 == 1 then
+
  --><tr style="height:2px"><td></td></tr><tr><!--
rowstyle = args.oddstyle
+
-->{{#if:{{{group18|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group18style|}}}"><!--
else
+
-->{{{group18}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
rowstyle = args.evenstyle
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list18style|}}}" <!--
end
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
 +
--><div style="padding:{{{listpadding|0em 0.25em}}}">
 +
{{{list18}}}</div></td></tr>}}<!--
  
local listText = args['list' .. listnum]
+
-->{{#if:{{{list19|}}}|<!--
local oddEven = ODD_EVEN_MARKER
+
--><tr style="height:2px"><td></td></tr><tr><!--
if listText:sub(1, 12) == '</div><table' then
+
-->{{#if:{{{group19|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group19style|}}}"><!--
-- Assume list text is for a subgroup navbox so no automatic striping for this row.
+
-->{{{group19}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
oddEven = listText:find('<th[^>]*"navbox%-title"') and RESTART_MARKER or 'odd'
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{oddstyle|}}};{{{list19style|}}}" <!--
end
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|even|{{{evenodd|odd}}}}}"><!--
listCell
+
--><div style="padding:{{{listpadding|0em 0.25em}}}">
:css('padding', '0px')
+
{{{list19}}}</div></td></tr>}}<!--
:cssText(args.liststyle)
 
:cssText(rowstyle)
 
:cssText(args['list' .. listnum .. 'style'])
 
:addClass('navbox-list')
 
:addClass('navbox-' .. oddEven)
 
:addClass(args.listclass)
 
:tag('div')
 
:css('padding', (index == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
 
:wikitext(processItem(listText, args.nowrapitems))
 
  
if index == 1 and args.image then
+
-->{{#if:{{{list20|}}}|<!--
row
+
--><tr style="height:2px"><td></td></tr><tr><!--
:tag('td')
+
-->{{#if:{{{group20|}}}|<td class="navbox-group" style="{{{basestyle|}}};{{#if:{{{groupwidth|}}}|width:{{{groupwidth}}};}}{{{groupstyle|}}};{{{group20style|}}}"><!--
:addClass('navbox-image')
+
-->{{{group20}}}</td><td style="text-align:left;border-left-width:2px;border-left-style:solid;|<td colspan=2 style="}}<!--
:addClass(args.imageclass)
+
-->{{#if:{{{groupwidth|}}}||width:100%;}}padding:0px;{{{liststyle|}}};{{{evenstyle|}}};{{{list20style|}}}" <!--
:css('width', '1px')              -- Minimize width
+
-->class="navbox-list navbox-{{#ifeq:{{{evenodd|}}}|swap|odd|{{{evenodd|even}}}}}"><!--
:css('padding', '0px 0px 0px 2px')
+
--><div style="padding:{{{listpadding|0em 0.25em}}}">
:cssText(args.imagestyle)
+
{{{list20}}}</div></td></tr>}}<!--
:attr('rowspan', #listnums)
 
:tag('div')
 
:wikitext(processItem(args.image))
 
end
 
end
 
  
  
--
+
---Below---
--   Tracking categories
+
-->{{#if:{{{below|}}}|<!--
--
+
-->{{#if:{{{title|}}}{{{above|}}}{{{list1|}}}{{{list2|}}}{{{list3|}}}|<tr style="height:2px;"><td></td></tr>}}<!--
 +
--><tr><td class="navbox-abovebelow" style="{{{basestyle|}}};{{{belowstyle|}}}" <!--
 +
-->colspan="{{#expr:2{{#if:{{{imageleft|}}}|+1}}{{#if:{{{image|}}}|+1}}}}">{{{below}}}</td></tr>}}<!--
  
local function needsHorizontalLists()
 
if border == 'subgroup' or args.tracking == 'no' then
 
return false
 
end
 
local listClasses = {
 
['plainlist'] = true, ['hlist'] = true, ['hlist hnum'] = true,
 
['hlist hwrap'] = true, ['hlist vcard'] = true, ['vcard hlist'] = true,
 
['hlist vevent'] = true,
 
}
 
return not (listClasses[args.listclass] or listClasses[args.bodyclass])
 
end
 
  
local function hasBackgroundColors()
+
--></table>{{#switch:{{{border|{{{1|}}}}}}|subgroup|child=<div>|none=|#default=</td></tr></table>}}<!--
for _, key in ipairs({'titlestyle', 'groupstyle', 'basestyle', 'abovestyle', 'belowstyle'}) do
 
if tostring(args[key]):find('background', 1, true) then
 
return true
 
end
 
end
 
end
 
  
local function hasBorders()
+
--><noinclude>[[Category:Templates|{{PAGENAME}}]] [[Category:Navbox templates]]</noinclude>
for _, key in ipairs({'groupstyle', 'basestyle', 'abovestyle', 'belowstyle'}) do
 
if tostring(args[key]):find('border', 1, true) then
 
return true
 
end
 
end
 
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
 
 
 
local function getTrackingCategories()
 
local cats = {}
 
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
 
if hasBorders() then table.insert(cats, 'Navboxes using borders') end
 
return cats
 
end
 
 
 
local function renderTrackingCategories(builder)
 
local title = mw.title.getCurrentTitle()
 
if title.namespace ~= 10 then return end -- not in template space
 
local subpage = title.subpageText
 
if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end
 
 
 
for _, cat in ipairs(getTrackingCategories()) do
 
builder:wikitext('[[Category:' .. cat .. ']]')
 
end
 
end
 
 
 
--
 
--  Main navbox tables
 
--
 
local function renderMainTable()
 
local tbl = mw.html.create('table')
 
:addClass('nowraplinks')
 
:addClass(args.bodyclass)
 
 
 
if args.title and (args.state ~= 'plain' and args.state ~= 'off') then
 
tbl
 
:addClass('collapsible')
 
:addClass(args.state or 'autocollapse')
 
end
 
 
 
tbl:css('border-spacing', 0)
 
if border == 'subgroup' or border == 'none' then
 
tbl
 
:addClass('navbox-subgroup')
 
:cssText(args.bodystyle)
 
:cssText(args.style)
 
else  -- regular navbox - bodystyle and style will be applied to the wrapper table
 
tbl
 
:addClass('navbox-inner')
 
:css('background', 'transparent')
 
:css('color', 'inherit')
 
end
 
tbl:cssText(args.innerstyle)
 
 
 
renderTitleRow(tbl)
 
renderAboveRow(tbl)
 
for i, listnum in ipairs(listnums) do
 
renderListRow(tbl, i, listnum)
 
end
 
renderBelowRow(tbl)
 
 
 
return tbl
 
end
 
 
 
function p._navbox(navboxArgs)
 
args = navboxArgs
 
 
 
for k, _ in pairs(args) do
 
if type(k) == 'string' then
 
local listnum = k:match('^list(%d+)$')
 
if listnum then table.insert(listnums, tonumber(listnum)) end
 
end
 
end
 
table.sort(listnums)
 
 
 
border = mw.text.trim(args.border or args[1] or '')
 
if border == 'child' then
 
border = 'subgroup'
 
end
 
 
 
-- render the main body of the navbox
 
local tbl = renderMainTable()
 
 
 
-- render the appropriate wrapper around the navbox, depending on the border param
 
local res = mw.html.create()
 
if border == 'none' then
 
local nav = res:tag('div')
 
:attr('role', 'navigation')
 
:node(tbl)
 
-- aria-labelledby title, otherwise above, otherwise lone group
 
if args.title or args.above or (args.group1 and not args.group2) then
 
nav:attr('aria-labelledby', mw.uri.anchorEncode(args.title or args.above or args.group1))
 
else
 
nav:attr('aria-label', 'Navbox')
 
end
 
elseif border == 'subgroup' then
 
-- 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
 
:wikitext('</div>')
 
:node(tbl)
 
:wikitext('<div>')
 
else
 
local nav = res:tag('div')
 
:attr('role', 'navigation')
 
:addClass('navbox')
 
:cssText(args.bodystyle)
 
:cssText(args.style)
 
:css('padding', '3px')
 
:node(tbl)
 
-- aria-labelledby title, otherwise above, otherwise lone group
 
if args.title or args.above or (args.group1 and not args.group2) then
 
nav:attr('aria-labelledby', mw.uri.anchorEncode(args.title or args.above or args.group1))
 
else
 
nav:attr('aria-label', 'Navbox')
 
end
 
end
 
 
 
renderTrackingCategories(res)
 
 
 
return striped(tostring(res))
 
end
 
 
 
function p.navbox(frame)
 
if not getArgs then
 
getArgs = require('Module:Arguments').getArgs
 
end
 
args = getArgs(frame, {wrappers = {'Template:Navbox', 'Template:Navbox subgroup'}})
 
if frame.args.border then
 
-- This allows Template:Navbox_subgroup to use {{#invoke:Navbox|navbox|border=...}}.
 
args.border = frame.args.border
 
end
 
 
 
-- Read the arguments in the order they'll be output in, to make references number in the right order.
 
local _
 
_ = args.title
 
_ = args.above
 
for i = 1, 20 do
 
_ = args["group" .. tostring(i)]
 
_ = args["list" .. tostring(i)]
 
end
 
_ = args.below
 
 
 
return p._navbox(args)
 
end
 
 
 
return p
 

Edição atual tal como às 00h14min de 6 de fevereiro de 2020