Content deleted Content added
m 'width:' .. |
add successionlinks, ifblank |
||
Line 6:
local notblank = function (v) return (mw.text.trim(v or "") ~= "") end
local ifblank = function (v, a) return notblank(v) and v or a end
local ucfirst = function (s) return mw.ustring.upper(mw.ustring.sub(s,1,1)) .. mw.ustring.gsub(mw.ustring.sub(s,2), '_', ' ') end
Line 100 ⟶ 101:
end
-- Party name --
threeCells('party', ifblank(
-- Alliance name --
threeCells('alliance', '', false, true) -- alliance, not alternative title, don't always show, use shortname
Line 187 ⟶ 188:
end
return name or ''
end
function p._successionlinks(sargs)
local output = {}
local dqhm = function (s) return require('Module:MultiReplace').main({s, '%[%[ *([%?-]) *%]%]', '%1', '%[%[ *[%?-] *| *(.-) *%]%]','%1'}) end
if notblank(sargs.center) then
table.insert(output, '<table style="width:100%; margin:1px; display:inline-table;"><tr>')
table.insert(output, '<td style="text-align:left; vertical-align:middle; padding:0 0.5em 0 0;' .. (sargs.leftstyle or '') .. '" class = "noprint">')
table.insert(output, (notblank(sargs.left) and ('← ' .. dqhm(sargs.left or '')) or '') .. '</td>')
table.insert(output, '<td style="text-align:center; vertical-align:middle; padding:0 1px;' .. (sargs.centerstyle or '') .. '">')
table.insert(output, sargs.center .. '</td>')
table.insert(output, '<td style="text-align:right; vertical-align:middle; padding:0 0 0 0.5em;' .. (sargs.rightstyle or '') .. '" class="noprint">')
table.insert(output, (notblank(sargs.right) and (dqhm(sargs.right or '') .. ' →') or '') .. '</td>')
table.insert(output, '</tr></table>')
elseif notblank(sargs.left) or notblank(sargs.right) then
table.insert(output, '<div style="width:100%">')
if notblank(sargs.left) then
table.insert(output, '<div style="float: left; text-align:left;padding-right:0.5em;' .. (sargs.leftstyle or '') .. ' class="noprint">')
table.insert(output, '← ' .. dqhm(sargs.left or '') .. '</div>')
end
if notblank(sargs.right) then
table.insert(output, '<div style="float: right; text-align:right;padding-left:0.5em;' .. (sargs.rightstyle or '') .. ' class="noprint">')
table.insert(output, dqhm(sargs.right or '') .. ' →</div>')
end
table.insert('</div>')
end
return table.concat(output, '\n')
end
Line 215 ⟶ 243:
local pagetitle = frame:getParent() and frame:getParent():getTitle() or frame:getTitle()
local etype = mw.ustring.lower(args.type or '')
local linkifexists = function(link, title, alttitle)
if notblank(title) and notblank(link) and mw.title.new(link).exists then
return '[[' .. link .. '|' .. title .. ']]'
elseif notblank(alttitle) or notblank(title) then
return ifblank(altitle, title)
end
end
local iargs = {
templatestyles = 'Infobox election/styles.css',
['child templatestyles'] = 'Screen reader-only/styles.css',
child = ifblank(args.child
bodyclass = 'ib-election infobox-table' .. (notblank(args.election_date) and 'vevent' or ''),
bodystyle = '',
titleclass = 'summary',
title = (ifblank(args.child
and (notblank(args.election_name) and '<div style="background-color:#ddd; font-size:120%; font-weight:bold">'..args.election_name..'</div>')
or ifblank(
subheader1 = notblank(args.flag_image)
and (InfoboxImage(
Line 242 ⟶ 278:
} }
) .. "<hr />") ),
subheader2 = (notblank(args.previous_year) or notblank(args.election_date) or notblank(args.next_year)) and (
_successionlinks({leftstyle = 'width:20%;', centerstyle = 'width:60%;', rightstyle = 'width:20%;',
left = linkifexists(args.previous_election, args.previous_year),
center = notblank(args.election_date) and ("'''" .. args.election_date .. "'''") or nil,
right = linkifexists(args.next_election, args.next_year)
})
) or (
nil
),
subheader3 = (notblank(args.previous_seat_year) or notblank(args.next_seat_year)) and (
_successionlinks({leftstyle = 'width:35%;text-align:center;', rightstyle = 'width:35%;text-align:center;',
left = linkifexists(args.previous_seat_election, args.previous_seat_year),
right = linkifexists(args.next_seat_election, args.next_seat_year)
})
) or (
nil
),
subheader4 = (notblank(args.outgoing_members) or notblank(args.previous_mps) or notblank(args.elected_members) or notblank(args.elected_mps)) and (
_successionlinks({leftstyle = 'width:40%;text-align:center;', rightstyle = 'width:40%;text-align:center;',
left = linkifexists(ifblank(args.outgoing_members, args.previous_mps or ''), 'outgoing members', ifblank(args.outgoing_members, args.previous_mps or '')),
right = linkifexists(ifblank(args.elected_members, args.elected_mps or ''), 'elected members', ifblank(args.elected_members, args.elected_mps or ''))
})
) or (
nil
),
header1 = (etype == 'primary' or etype == 'presidential') and (
notblank(args.votes_for_election) and (
Line 318 ⟶ 376:
divider = '<hr />',
ongoing = args.ongoing or 'no',
party_color =
image_size = args.image_size or '150x150px',
image_upright = args.image_upright,
Line 357 ⟶ 415:
end
rargs['color' .. tostring(j)] =
rargs['party' .. tostring(j) .. '_name'] =
rargs['alliance' .. tostring(j) .. '_name'] =
end
|