438
edits
(fix metadata logic) |
m (13 revisions imported from wikipedia:Module:Side_box: see Topic:Vtixlm0q28eo6jtf) |
||
(10 intermediate revisions by 4 users not shown) | |||
Line 36: | Line 36: | ||
end | end | ||
table.insert(data.classes, args.class) | table.insert(data.classes, args.class) | ||
-- Image | |||
if args.image and args.image ~= 'none' then | |||
data.image = args.image | |||
end | |||
-- Copy over data that doesn't need adjusting | -- Copy over data that doesn't need adjusting | ||
Line 49: | Line 54: | ||
-- Body row | -- Body row | ||
'text', | 'text', | ||
'imageright', | 'imageright', | ||
Line 67: | Line 71: | ||
-- Table root | -- Table root | ||
local root = mw.html.create('table') | local root = mw.html.create('table') | ||
root:attr('role', 'presentation') | |||
for i, class in ipairs(data.classes or {}) do | for i, class in ipairs(data.classes or {}) do | ||
root:addClass(class) | root:addClass(class) | ||
end | end | ||
root:css{border = '1px solid #aaa', ['background-color'] = '#f9f9f9'} | root:css{border = '1px solid #aaa', ['background-color'] = '#f9f9f9', color = '#000'} | ||
if data.style then | if data.style then | ||
root:cssText(data.style) | root:cssText(data.style) | ||
Line 77: | Line 82: | ||
-- The "above" row | -- The "above" row | ||
if data.above then | if data.above then | ||
local aboveCell = root:tag('tr'):tag('td') | local aboveCell = root:newline():tag('tr'):tag('td') | ||
aboveCell | aboveCell | ||
:attr('colspan', data.imageright and 3 or 2) | :attr('colspan', data.imageright and 3 or 2) | ||
Line 87: | Line 92: | ||
aboveCell:cssText(data.abovestyle) | aboveCell:cssText(data.abovestyle) | ||
end | end | ||
aboveCell:wikitext(data.above) | aboveCell | ||
:newline() | |||
:wikitext(data.above) | |||
end | end | ||
-- The body row | -- The body row | ||
local bodyRow = root:tag('tr') | local bodyRow = root:newline():tag('tr'):newline() | ||
if data.image then | if data.image then | ||
bodyRow:tag('td') | bodyRow:tag('td') | ||
Line 99: | Line 106: | ||
bodyRow:tag('td'):css('width', '1px') | bodyRow:tag('td'):css('width', '1px') | ||
end | end | ||
local textCell = bodyRow:tag('td') | local textCell = bodyRow:newline():tag('td') | ||
textCell:addClass('mbox-text plainlist') | textCell:addClass('mbox-text plainlist') | ||
if data.textstyle then | if data.textstyle then | ||
Line 106: | Line 113: | ||
textCell:wikitext(data.text) | textCell:wikitext(data.text) | ||
if data.imageright then | if data.imageright then | ||
bodyRow:tag('td') | bodyRow:newline():tag('td') | ||
:addClass('mbox-imageright') | :addClass('mbox-imageright') | ||
:wikitext(data.imageright) | :wikitext(data.imageright) | ||
Line 113: | Line 120: | ||
-- The below row | -- The below row | ||
if data.below then | if data.below then | ||
local belowCell = root:tag('tr'):tag('td') | local belowCell = root:newline():tag('tr'):tag('td') | ||
belowCell | belowCell | ||
:attr('colspan', data.imageright and 3 or 2) | :attr('colspan', data.imageright and 3 or 2) | ||
Line 123: | Line 130: | ||
end | end | ||
root:newline() | |||
return tostring(root) | return tostring(root) | ||
end | end | ||
return p | return p |