Module:OOOInfoBox: Difference between revisions

No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 115: Line 115:


   local box = mw.html.create('table'):addClass('ooo-infobox')
   local box = mw.html.create('table'):addClass('ooo-infobox')
  -- optional width (keeps CSS default if omitted)
  local w = tonumber((frame:getParent() or frame).args.width)
  if w and w >= 240 and w <= 600 then
    box:css('width', w .. 'px')
  end
 
  -- default is right via CSS; only add class when overriding
   local align = trim(args.align)
   local align = trim(args.align)
   if align == 'left' then box:addClass('ooo-infobox--left')
   if align == 'left' then
   elseif align == 'right' then box:addClass('ooo-infobox--right') end
    box:addClass('ooo-infobox--left')
   elseif align == 'none' then
    box:addClass('ooo-infobox--none')
  elseif align == 'center' then
    box:addClass('ooo-infobox--center')
  end


  -- keep optional extra classes
   local extra_class = trim(args.class)
   local extra_class = trim(args.class)
   if extra_class and extra_class ~= '' then
   if extra_class and extra_class ~= '' then