「モジュール:Navbox/former」の版間の差分
削除された内容 追加された内容
モジュール:Navbox/former/sandbox 2016-08-12T00:06:33 UTC の版を全文転記。WP:AN/PE#モジュール:Navbox/former (差分) の依頼に基づく。 |
|||
1行目:
local p = {}
--[[
6行目:
function p.tnavbar(frame)
local args = frame.args
if not args[1] then return ' ' end
local function tf(x)
61行目:
Define Arguments
]]
local args = {}
local border
local child, none = false, false
local collapsible = ''
local colspan, rowspan = 0, 0
local basestyle = ''
local odd, even = 'odd', 'even'
local list, liststyle = {}, {}
local group, groupstyle = {}, {}
local colheader, colheadercolspan, colheaderstyle = {}, {}, {}
local col, colstyle, colwidth = {}, {}, {}
local colfooter, colfootercolspan, colfooterstyle = {}, {}, {}
local abbr, state = {}, {}
local sect, section = {}, {}
local secttitlestyle = {}
local content, contentstyle = {}
local image, imageleft = {}, {}
local result = '' --出力用
local function defArgs(frame)
args = require('Module:Arguments').getArgs(frame, {parentOnly = true})
border = args.border or args[1]
69 ⟶ 89行目:
colspan = 2 + (args.imageleft and 1 or 0) + (args.image and 1 or 0)
if args.basestyle then basestyle = args.basestyle .. ';' end
local switch = {
--common
list = function(num, v) list[num] = '\n' .. v end,
liststyle = function(num, v) liststyle[num] = v end,
group = function(num, v) group[num] = v end,
groupstyle = function(num, v) groupstyle[num] = v end,
--for with_columns
colheader = function(num,v) colheader[num] = v end,
colheadercolspan = function(num,v) colheadercolspan[num] = v end,
colheaderstyle = function(num,v) colheaderstyle[num] = v end,
col = function(num,v) col[num] = v end,
colstyle = function(num,v) colstyle[num] = v end,
colwidth = function(num,v) colwidth[num] = v end,
colfooter = function(num,v) colfooter[num] = v end,
colfootercolspan = function(num,v) colfootercolspan[num] = v end,
colfooterstyle = function(num,v) colfooterstyle[num] = v end,
--for with_collapsible_groups
abbr = function(num, v) abbr[num] = v end,
state = function(num, v) state[num] = v end,
sect = function(num, v) group[num] = v end,
section = function(num, v) group[num] = v end,
secttitlestyle = function(num, v) groupstyle[num] = v end,
content = function(num, v) list[num] = '\n' .. v end,
contentstyle = function(num, v) liststyle[num] = v end,
image = function(num, v) image[num] = v end,
imageleft = function(num, v) imageleft[num] = v end,
}
for k, v in pairs(args) do
str1, num, str2 = str1 or '', tonumber(num), str2 or ''
if switch[str1 .. str2] and num then switch[str1 .. str2](num, v) end
end
rowspan = (#list - 1) * 2 - 1
end
112 ⟶ 137行目:
end
result = result .. '<table class="
if args.title then
result = result .. ' ' .. collapsible .. (args.state or ' autocollapse')
end
if child or none then
result = result .. ' navbox-subgroup" style="margin:-2px;width:calc(100%
else
result = result .. '" style="background:transparent;color:inherit;
end
result = result .. ';min-width:100%;border-spacing:
end
129 ⟶ 154行目:
]]
local function title()
if args.titlegroup then
result = result .. '<tr><td class="navbox-group ' .. (args.titlegroupclass or '') .. '" style="' .. basestyle .. (args.groupstyle or '') .. ';' .. (args.titlegroupstyle or '') .. '">' .. args.titlegroup .. '</td><th style="
else
result = result .. '<tr><th style="'
end
result = result .. basestyle .. (args.titlestyle or '') .. '" colspan=' .. (colspan - (args.titlegroup and 1 or 0)) .. ' class="navbox-title">'
if (args.navbar == 'plain' or args.navbar == 'off') or (not args.name and (child or none)) then
result = result .. '<div style="float:left;width:6em;"> </div>'
else
local tbl = {args = {args.name, mini = '1', fontstyle = basestyle .. (args.titlestyle or '') .. ';border:none;', fontcolor = ''}}
result = result .. '<div style="float:left;
end
160 ⟶ 173行目:
args.titleclass = ''
end
result = result .. '<span ' .. args.titleclass .. ' style="font-size:' .. ((child or none) and '100' or '110') .. '%;">' .. args.title .. '</span
if args.state == 'plain' or args.state == 'off' then
result = result .. '<div style="float:right;width:6em;"> </div>'
end
result = result .. '</th></tr>'
end
167 ⟶ 185行目:
]]
local function above()
result = result
end
175 ⟶ 193行目:
--first group/list and images
local function body1()
result = result ..
if args.imageleft then
result = result .. '<td style="width:
end
if group[1] then
result = result .. '<td class="navbox-group ' .. (args.groupclass or '') .. '" style="
else
result = result .. '<td colspan=2 style="'
186 ⟶ 204行目:
result = result .. (args.groupwidth and '' or 'width:100%;') .. 'padding:0;' .. (args.liststyle or '') .. ';' .. (odd == 'odd' and (args.oddstyle or '') or (args.evenstyle or '')) .. ';' .. (liststyle[1] or '') .. '" class="navbox-list navbox-' .. (args.evenodd == 'swap' and even or args.evenodd or odd) .. ' ' .. (args.listclass or '') .. '"><div style="padding:' .. (args.list1padding or args.listpadding or '0 0.25em') .. '">' .. list[1] .. '</div></td>'
if args.image then
result = result .. '<td style="width:0
end
result = result .. '</tr>'
196 ⟶ 214行目:
for i in pairs(list) do
odd, even = even, odd
if group[i] then
result = result .. '<tr><td class="navbox-group ' .. (args.groupclass or '') .. '" style="
else
result = result .. '<tr><td colspan=2 style="'
end
result = result .. (args.groupwidth and '' or 'width:100%;') .. 'padding:0;' .. (args.liststyle or '') .. ';' .. (odd == 'odd' and (args.oddstyle or '') or (args.evenstyle or '')) .. ';' .. (liststyle[i] or '') .. '" class="navbox-list navbox-' .. (args.evenodd == 'swap' and even or args.evenodd or odd) .. ' ' .. (args.listclass or '') .. '"><div style="padding:' .. (args.listpadding or '0 0.25em') .. '">' .. list[i] .. '</div></td></tr>'
210 ⟶ 227行目:
]]
local function below()
result = result
end
263 ⟶ 280行目:
function p.with_columns(frame)
defArgs(frame)
top()
if args.title then title() end
if args.above then above() end
local cols = '</div><table class="navbox-columns-table" style="border-spacing:
--Header row
if colheader[1] then
cols = cols .. '<tr class="navbox-abovebelow" style="
colheader[1] = nil
for i in pairs(colheader) do
cols = cols .. '<td colspan=' .. (colheadercolspan[i] or '1') .. ' style="
end
cols = cols .. '</tr>'
304 ⟶ 303行目:
end
end
cols = cols .. '<td style="
col[1] = nil
for i in pairs(col) do
cols = cols .. '<td style="
args.oddcolstyle, args.evencolstyle = args.evencolstyle, args.oddcolstyle
end
314 ⟶ 313行目:
--Footer row
if colfooter[1] then
cols = cols .. '<tr class="navbox-abovebelow" style="font-weight:bold;' .. (args.colfooterstyle or '') .. '"><td colspan=' .. (colfootercolspan[1] or '1') .. ' style="
colfooter[1] = nil
for i in pairs(colfooter) do
cols = cols .. '<td colspan=' .. (colfootercolspan[i] or '1') .. ' style="
end
cols = cols .. '</tr>'
336 ⟶ 335行目:
function p.with_collapsible_groups(frame)
defArgs(frame)
top()
if args.title then title() end
if args.above then above() end
local i = 1
local function funcList()
local collapsible = (args.selected == abbr[i] or args.selected == group[i]) and '' or 'collapsible '
args.name = nil
args.state = collapsible .. (state[i] or 'collapsed')
379 ⟶ 353行目:
result = result .. '<td style="' .. (args.groupwidth and '' or 'width:100%;') .. 'padding:0;' .. (args.liststyle or '') .. ';' .. (odd == 'odd' and (args.oddstyle or '') or (args.evenstyle or '')) .. ';' .. (liststyle[i] or '') .. '" class="navbox-list navbox-' .. (args.evenodd == 'swap' and even or args.evenodd or odd) .. ' ' .. (args.listclass or '') .. '"><div>'
if args.title then
none = true
top()
392 ⟶ 365行目:
--i = 1
result = result .. '<tr>'
if args.imageleft then
result = result .. '<td style="width:0;padding:0 2px 0 0;' .. (args.imageleftstyle or '') .. '" rowspan=' .. rowspan .. '>' .. args.imageleft .. '</td>'
404 ⟶ 376行目:
--i > 2
for j in pairs(list) do
result = result ..
i = j
list[1], list[i] = list[i], nil
funcList()
end
435 ⟶ 408行目:
end
end
local result = '<table style="width:100%;border-spacing:
local h = 1
repeat
|