Module:OOOInfoBox: Difference between revisions

No edit summary
No edit summary
 
(2 intermediate revisions 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)
  if align == 'left' then
    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)
  if extra_class and extra_class ~= '' then
    for c in mw.text.gsplit(extra_class, '%s+') do box:addClass(c) end
  end


   -- Title
   -- Title