Editing Module:Side box

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. Read the Privacy Policy to learn what information we collect about you and how we use it.

If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
-- This module implements {{side box}}.
-- This module implements {{side box}}.
local yesno = require('Module:Yesno')


local p = {}
local p = {}
Line 27: Line 25:
-- Main table classes
-- Main table classes
data.classes = {}
data.classes = {}
if yesno(args.metadata) ~= false then
if args.metadata and args.metadata:lower() ~= 'no' then
table.insert(data.classes, 'metadata')
table.insert(data.classes, 'metadata')
end
end
Line 36: Line 34:
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 54: Line 47:
-- Body row
-- Body row
'text',
'text',
'image',
'imageright',
'imageright',


Line 71: Line 65:
-- 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', color = '#000'}
root:css{border = '1px solid #aaa', ['background-color'] = '#f9f9f9'}
if data.style then
if data.style then
root:cssText(data.style)
root:cssText(data.style)
Line 82: Line 75:
-- The "above" row
-- The "above" row
if data.above then
if data.above then
local aboveCell = root:newline():tag('tr'):tag('td')
local aboveCell = root:tag('tr'):tag('td')
aboveCell
aboveCell
:attr('colspan', data.imageright and 3 or 2)
:attr('colspan', data.imageright and 3 or 2)
Line 92: Line 85:
aboveCell:cssText(data.abovestyle)
aboveCell:cssText(data.abovestyle)
end
end
aboveCell
aboveCell:wikitext(data.above)
:newline()
:wikitext(data.above)
end
end


-- The body row
-- The body row
local bodyRow = root:newline():tag('tr'):newline()
local bodyRow = root:tag('tr')
if data.image then
if data.image then
bodyRow:tag('td')
bodyRow:tag('td')
Line 106: Line 97:
bodyRow:tag('td'):css('width', '1px')
bodyRow:tag('td'):css('width', '1px')
end
end
local textCell = bodyRow:newline():tag('td')
local textCell = bodyRow:tag('td')
textCell:addClass('mbox-text plainlist')
textCell:addClass('mbox-text plainlist')
if data.textstyle then
if data.textstyle then
Line 113: Line 104:
textCell:wikitext(data.text)
textCell:wikitext(data.text)
if data.imageright then
if data.imageright then
bodyRow:newline():tag('td')
bodyRow:tag('td')
:addClass('mbox-imageright')
:addClass('mbox-imageright')
:wikitext(data.imageright)
:wikitext(data.imageright)
Line 120: Line 111:
-- The below row
-- The below row
if data.below then
if data.below then
local belowCell = root:newline():tag('tr'):tag('td')
local belowCell = root:tag('tr'):tag('td')
belowCell
belowCell
:attr('colspan', data.imageright and 3 or 2)
:attr('colspan', data.imageright and 3 or 2)
Line 130: Line 121:
end
end


root:newline()
return tostring(root)
return tostring(root)
end
end


return p
return p
Please note that all contributions to Nonbinary Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see Nonbinary Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page: