「モジュール:Navbox/former」の版間の差分
削除された内容 追加された内容
Template:Navbox with columnsにおいてcol指定が不連続な場合にエラーが表示される不具合を修正; 不具合の報告による |
Module:Navbox/former/sandbox (固定リンク)より全文転記; Template talk:Navbox#不具合の報告 (固定リンク)による |
||
91行目:
if args.basestyle then basestyle = args.basestyle .. ';' end
local sortable_mt = {
__lt = function(a, b) return a.index < b.index end,
__concat = function(a, b)
local strA = (type(a) == 'table') and a.content or a or ''
local strB = (type(b) == 'table') and b.content or b or ''
return strA .. strB
end
}
local function sortable_args(tbl, index, content)
table.insert(tbl, {index = index, content = content})
setmetatable(tbl[#tbl], sortable_mt)
end
local switch = {
--common
list = function(num, v) sortable_args(list
liststyle = function(num, v) liststyle[num] = v end,
group = function(num, v) group[num] = v end,
101 ⟶ 113行目:
colheadercolspan = function(num,v) colheadercolspan[num] = v end,
colheaderstyle = function(num,v) colheaderstyle[num] = v end,
col = function(num, v) sortable_args(col
colstyle = function(num,v) colstyle[num] = v end,
colwidth = function(num,v) colwidth[num] = v end,
113 ⟶ 125行目:
section = function(num, v) group[num] = v end,
secttitlestyle = function(num, v) groupstyle[num] = v end,
content = function(num, v)
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
local str1, num, str2 = string.match(k, '(%D+)(%d+)(%D*)')
124 ⟶ 137行目:
end
table.sort(list)
end
165 ⟶ 175行目:
result = result .. basestyle .. (args.titlestyle or '') .. '" colspan=' .. (colspan - (args.titlegroup and 1 or 0)) .. ' class="navbox-title">'
if (args.navbar == 'plain
result = result .. '<div style="float:left;width:6em;"> </div>'
elseif args.navbar ~= 'off' then
local tbl = {args = {args.name, mini = '1', fontstyle = basestyle .. (args.titlestyle or '') .. ';border:none;', fontcolor = ''}}
result = result .. '<div style="float:left;width:6em;text-align:left;">' .. p.tnavbar(tbl) .. '</div>'
179 ⟶ 189行目:
result = result .. '<span ' .. args.titleclass .. ' style="font-size:' .. ((child or none) and '100' or '110') .. '%;">' .. args.title .. '</span>'
if args.state == 'plain
result = result .. '<div style="float:right;width:6em;"> </div>'
end
201 ⟶ 211行目:
result = result .. '<td style="width:0;' .. (args.imageleftstyle or '') .. '" rowspan=' .. rowspan .. '>' .. args.imageleft .. '</td>'
end
if group[j] then
result = result .. '<td class="navbox-group ' .. (args.groupclass or '') .. '" style="' .. basestyle .. (args.groupwidth and ('width:' .. args.groupwidth .. ';') or '') .. (args.groupstyle or '') .. ';' .. (groupstyle[j] or '') .. '">' .. group[j] .. '</td><td style="text-align:left;'
else
result = result .. '<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[
if args.image then
result = result .. '<td style="width:0;' .. (args.imagestyle or '') .. '" rowspan=' .. rowspan .. '>' .. args.image .. '</td>'
215 ⟶ 226行目:
--remaining groups/lists
local function body2()
for i = 2, #list do
odd, even = even, odd
if group[j] then
result = result .. '<tr><td class="navbox-group ' .. (args.groupclass or '') .. '" style="' .. basestyle .. (args.groupwidth and ('width:' .. args.groupwidth .. ';') or '') .. (args.groupstyle or '') .. ';' .. (groupstyle[j] or '') .. '">' .. group[j] .. '</td><td style="text-align:left;'
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[
end
end
284 ⟶ 295行目:
function p.with_columns(frame)
defArgs(frame)
table.sort(col)
mw.log(#col)
top()
if args.title then title() end
if args.above then above() end
if col[1] then
local j = col[1].index
local cols = '</div><table class="navbox-columns-table" style="border-spacing:2px;border-collapse:separate;text-align:left;margin:-2px;' .. ((colheader[j] or args.fullwidth) and 'width:100%;width:calc(100% + 4px);' or 'margin:0 auto;') .. (args.coltablestyle or '') .. '">'
--Header row
cols = cols .. '<tr class="navbox-abovebelow" style="font-weight:bold;' .. (args.colheaderstyle or '') .. '">'
for i = 1, #col do
local j = col[i].index
if
cols = cols .. '<td colspan=' .. (colheadercolspan[j] or '1') .. ' style="' .. (colheaderstyle[j] or '') .. '">' .. colheader[j] .. '</td>'
end
end
cols = cols .. '</tr>'
end
--Main columns
cols = cols .. '<tr style="vertical-align:top;' .. (args.colstyle or '') .. '">'
if not (colheader[
if
cols = cols .. '<td style="width:' .. (args.padding or '5em;') .. '"> </td>'
end
end
for i
local j = col[i].index
cols = cols .. '<td style="padding:0;' .. (args.oddcolstyle or '') .. ';' .. (colstyle[j] or '') .. ';width:' .. (colwidth[j] or args.colwidth or '10em;') .. '">' .. col[i] .. '</td>'
args.oddcolstyle, args.evencolstyle = args.evencolstyle, args.oddcolstyle
end
cols = cols .. '</tr>'
--Footer row
if colfooter[j] then
cols = cols .. '<tr class="navbox-abovebelow" style="font-weight:bold;' .. (args.colfooterstyle or '') .. '">'
for i = 1, #col do
local j = col[i].index
if
cols = cols .. '<td colspan=' .. (
end
end
cols = cols .. '</tr>'
end
cols = cols .. '</
table.insert(list, 1, cols)
table.insert(liststyle, 1, nil)
table.insert(group, 1, nil)
table.insert(groupstyle, 1, nil)
rowspan = rowspan + 1
end
body1()
365 ⟶ 360行目:
function p.with_collapsible_groups(frame)
defArgs(frame)
table.sort(content)
top()
if args.title then title() end
371 ⟶ 367行目:
local i = 1
local function funcList()
list[i] = list[i] or content[i]
local j = list[i].index collapsible = (args.selected and (args.selected == abbr[ args.state = state[
args.name = nil
args.titlestyle = basestyle .. (args.groupstyle or '') .. ';' .. (args.secttitlestyle or '') .. ';' .. (groupstyle[
args.liststyle = (args.liststyle or '') .. ';' .. (args.contentstyle or '') .. ';' .. (liststyle[
args.title, group[
args.image = image[
args.imageleft = imageleft[
colspan = 2 + (args.imageleft and 1 or 0) + (args.image and 1 or 0)
rowspan = 1
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[
if args.title then
none = true
403 ⟶ 401行目:
result = result .. '<td style="width:0%;padding:0 0 0 2px;' .. (args.imagestyle or '') .. '" rowspan=' .. rowspan .. '>' .. args.image .. '</td>'
end
--i > 2
for
result = result .. '<tr>'
list[1] = list[
funcList()
end
|