Module:Vertical header
Jump to navigation
Jump to search
Implements {{Vertical header}}
.
Code
local p = {}
function p.cell(frame)
local text = frame.args.text
local sortable = frame.args.sortable
local vAlign = frame.args.vAlign
local maxWidth = frame.args.maxWidth
local noBold = frame.args.noBold
local style = frame.args.style:gsub("\"", """)
local cellStyle = frame.args.cellStyle:gsub("\"", """)
local height = 0
local lines = 1
local sortPadding = ""
local textAlign = ""
local wikiText = "class=\"nowrap"
if sortable ~= "" then
sortPadding = "21px"
else
sortPadding = "0.4em"
wikiText = wikiText .. " unsortable"
end
wikiText = wikiText .. "\" style=\"background-position: 50% 0.4em !important; line-height: 99%; max-width: "
if maxWidth ~= "" then
height = maxWidth
else
for eachMatch in text:gmatch("<[bB][rR] */? *>") do
lines = lines + 1
end
height = lines * 0.875
end
wikiText = wikiText .. height .. "em; min-width: " .. height .. "em; overflow: hidden; padding: " .. sortPadding
wikiText = wikiText .. " 0.4em 0.2em; vertical-align: " .. vAlign .. "; width: " .. height .. "em;"
if cellStyle ~= "" then
wikiText = wikiText .. " " .. cellStyle
end
wikiText = wikiText .. "\" | <div style=\"display: inline-block; padding-left: 1px; text-align: "
if vAlign == "top" then
textAlign = "right"
elseif vAlign == "middle" then
textAlign = "center"
else
textAlign = "left"
end
wikiText = wikiText .. textAlign .. "; transform: rotate(0.5turn); writing-mode: vertical-rl;"
if style ~= "" then
wikiText = wikiText .. " " .. style
end
wikiText = wikiText .. "\">"
if noBold ~= "" then
wikiText = wikiText .. "<span style=\"font-weight: normal;\">" .. text .. "</span>"
else
wikiText = wikiText .. text
end
wikiText = wikiText .. "</div>"
return wikiText
end
return p