Jump to content
Wikipedia The Free Encyclopedia

Module:Clade/labels

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
Warning 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.
The above documentation is transcluded from Module:Clade/labels/doc. (edit | history)
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.

 localp={}

 --local args =frame:getParent().args -- get parent arguments
 --local args = {}

 p.getArgs=function(frame)
 --return frame.args -- use frame arguments
 returnframe:getParent().args-- use parent arguments
 end
 p.main=function(frame)

 args=p.getArgs(frame)

 locali=1-- index for labels
 localoutput=""
 --[[local groupStyle = args['style']
  local topStyle = args['top']
  local leftStyle = args['left']
  local rightStyle = args['right']
  local bottomStyle = args['bottom']
  ]]
 -- parameters for all labels
 localwidth=args['width']-- or "5em;"
 --local style = args['style'] or ""
 --local color = args['width'] or ""

 locallongestString=0

 whileargs['label'..i]do

 locallabel=args['label'..i]or""
 if#label>longestStringthenlongestString=#labelend

 localstyle=args['style'..i]orargs['style']or""
 localcolor=args['color'..i]orargs['color']or""
 localtop=args['top'..i]orargs['top']or""
 localleft=args['left'..i]orargs['left']or""
 localright=args['right'..i]orargs['right']or""
 localbottom=args['bottom'..i]orargs['bottom']or""
 iftop~=""thentop='top:'..top..';'end
 ifleft~=""thenleft='left:'..left..';'end
 ifright~=""thenright='right:'..right..';'end
 ifbottom~=""thenbottom='bottom:'..bottom..';'end
 ifcolor~=""thencolor='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
 ifoutput~=""then
 localstyleStr=""
 --widthStr = 'width:' .. (longestString*0.5)..'em;' -- can't take account of formatting or <br/>
 ifwidththenstyleStr='style="width:'..width..'"'end

 output='<div '..styleStr..'>'..output..'</div>'
 end
 returnoutput
 end

 p.label=function(frame)

 args=p.getArgs(frame)

 locali=1-- index for labels
 localoutput=""
 locallabel=args['label'..i]orargs['label']orargs[1]or""
 localwidth=args['width']

 localstyle=args['style'..i]orargs['style']or""
 localcolor=args['color'..i]orargs['color']or""
 localtop=args['top'..i]orargs['top']or"-1em"-- to compensate for CSS :before {content:"2060円";} on the sublabel
 localleft=args['left'..i]orargs['left']or""
 localright=args['right'..i]orargs['right']or"0px"
 localbottom=args['bottom'..i]orargs['bottom']or""
 iftop~=""thentop='top:'..top..';'end
 ifleft~=""thenleft='left:'..left..';'end
 ifright~=""thenright='right:'..right..';'end
 ifbottom~=""thenbottom='bottom:'..bottom..';'end
 ifcolor~=""thencolor='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>'


 ifoutput~=""then
 localwidthStr=''
 ifwidththenwidthStr='width:'..width..';'end

 output='<div style="position:relative;'..widthStr..'">'..output..'</div>'-- <br/> removed now using CSS :before {content:"2060円";} for the sublabel
 end

 returnoutput

 end


 returnp

AltStyle によって変換されたページ (->オリジナル) /