Editing Module:Aligned table

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 12: Line 12:
local colstyle = {}
local colstyle = {}
local cols = tonumber(args['cols']) or 2
local cols = tonumber(args['cols']) or 2
local noblankrows = args['noblankrows'] or ''


-- create the root table
-- create the root table
Line 39: Line 40:
colstyle[1] = 'text-align:left;'
colstyle[1] = 'text-align:left;'
colstyle[2] = 'text-align:right;'
colstyle[2] = 'text-align:right;'
end
if isnotempty(args['rightleft']) then
colstyle[1] = 'text-align:right;'
colstyle[2] = 'text-align:left;'
end
end
for i = 1,cols do
for i = 1,cols do
Line 117: Line 114:
row:css('vertical-align', 'top')
row:css('vertical-align', 'top')
end
end
if isnotempty(args['rowclass']) then
-- skip blank rows, if feature is enabled
row:addClass(args['rowclass'])
local showrow = 1
if isnotempty(noblankrows) then
showrow = 0
for i=1,cols do
if isnotempty(args[cols*(j - 1) + i] or '') then
showrow = 1
break
end
end
end
end
-- loop over the cells in the row
-- loop over the cells in the row
if showrow then
for i=1,cols do
for i=1,cols do
local cell
local cell
Line 137: Line 143:
elseif args['row' .. tostring(j) .. 'class'] then
elseif args['row' .. tostring(j) .. 'class'] then
cell:addClass(args['row' .. tostring(j) .. 'class'])
cell:addClass(args['row' .. tostring(j) .. 'class'])
elseif args['rowevenclass'] and math.fmod(j,2) == 0 then
cell:addClass(args['rowevenclass'])
elseif args['rowoddclass'] and math.fmod(j,2) == 1 then
cell:addClass(args['rowoddclass'])
end
end
if colclass[i] ~= '' then
if colclass[i] ~= '' then
Line 151: Line 153:
if args['rowstyle' .. tostring(j)] then
if args['rowstyle' .. tostring(j)] then
cell:cssText(args['rowstyle' .. tostring(j)])
cell:cssText(args['rowstyle' .. tostring(j)])
elseif args['rowevenstyle'] and math.fmod(j,2) == 0 then
cell:cssText(args['rowevenstyle'])
elseif args['rowoddstyle'] and math.fmod(j,2) == 1 then
cell:cssText(args['rowoddstyle'])
elseif args['row' .. tostring(j) .. 'style'] then
elseif args['row' .. tostring(j) .. 'style'] then
cell:cssText(args['row' .. tostring(j) .. 'style'])
cell:cssText(args['row' .. tostring(j) .. 'style'])
Line 163: Line 161:
end
end
cell:wikitext(mw.ustring.gsub(args[cols*(j - 1) + i] or '', '^(.-)%s*$', '%1') or '')
cell:wikitext(mw.ustring.gsub(args[cols*(j - 1) + i] or '', '^(.-)%s*$', '%1') or '')
end
end
end
end
end
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: