Module:Clade/labels
| This Lua module is used on approximately 260 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
local p = {}
--local args =frame:getParent().args -- get parent arguments
--local args = {}
p.getArgs = function(frame)
--return frame.args -- use frame arguments
return frame:getParent().args -- use parent arguments
end
p.main = function(frame)
args = p.getArgs(frame)
local i = 1 -- index for labels
local output = ""
--[[local groupStyle = args['style']
local topStyle = args['top']
local leftStyle = args['left']
local rightStyle = args['right']
local bottomStyle = args['bottom']
]]
-- parameters for all labels
local width = args['width'] -- or "5em;"
--local style = args['style'] or ""
--local color = args['width'] or ""
local longestString = 0
while args['label'..i] do
local label = args['label'..i] or ""
if #label > longestString then longestString = #label end
local style = args['style'..i] or args['style'] or ""
local color = args['color'..i] or args['color'] or ""
local top = args['top'..i] or args['top'] or ""
local left = args['left'..i] or args['left'] or ""
local right = args['right'..i] or args['right'] or ""
local bottom = args['bottom'..i] or args['bottom'] or ""
if top ~= "" then top = 'top:' .. top .. ';' end
if left ~= "" then left = 'left:' .. left .. ';' end
if right ~= "" then right = 'right:' .. right .. ';' end
if bottom ~= "" then bottom = 'bottom:' .. bottom .. ';' end
if color ~= "" then color = 'color:' .. color .. ';' end
--if no color:find(";", -1, true) then color = color .. ';' end
--local position = top .. left .. right .. bottom
output = output .. '<div style="position:absolute;white-space:nowrap;'
.. style .. color -- CSS styling
.. top .. left .. right .. bottom .. '">' -- position of label
.. label -- content of label
.. '</div>'
i=i+1
end
if output ~= "" then
local styleStr = ""
--widthStr = 'width:' .. (longestString*0.5)..'em;' -- can't take account of formatting or <br/>
if width then styleStr = 'style="width:' .. width .. '"' end
output = '<div ' .. styleStr ..'>' .. output .. '</div>'
end
return output
end
p.label = function(frame)
args = p.getArgs(frame)
local i = 1 -- index for labels
local output = ""
local label = args['label'..i] or args['label'] or args[1] or ""
local width = args['width']
local style = args['style'..i] or args['style'] or ""
local color = args['color'..i] or args['color'] or ""
local top = args['top'..i] or args['top'] or "-1em" -- to compensate for CSS :before {content:"\2060";} on the sublabel
local left = args['left'..i] or args['left'] or ""
local right = args['right'..i] or args['right'] or "0px"
local bottom = args['bottom'..i] or args['bottom'] or ""
if top ~= "" then top = 'top:' .. top .. ';' end
if left ~= "" then left = 'left:' .. left .. ';' end
if right ~= "" then right = 'right:' .. right .. ';' end
if bottom ~= "" then bottom = 'bottom:' .. bottom .. ';' end
if color ~= "" then color = 'color:' .. color .. ';' end
output = output .. '<div style="position:absolute;white-space:nowrap;'
.. style .. color -- CSS styling
.. top .. left .. right .. bottom .. '">' -- position of label
.. label -- content of label
.. '</div>'
if output ~= "" then
local widthStr = ''
if width then widthStr = 'width:' .. width .. ';' end
output = '<div style="position:relative;' .. widthStr .. '">' .. output .. '</div>' -- <br/> removed now using CSS :before {content:"\2060";} for the sublabel
end
return output
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.