Editing Module:Aligned table
From MINR.ORG WIKI
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. 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 save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 43: | Line 43: | ||
colclass[ i ] = colclass[ i ] or '' | colclass[ i ] = colclass[ i ] or '' | ||
colstyle[ i ] = colstyle[ i ] or '' | colstyle[ i ] = colstyle[ i ] or '' | ||
− | |||
− | |||
− | |||
if isnotempty(args['colalign' .. tostring(i)]) then | if isnotempty(args['colalign' .. tostring(i)]) then | ||
colstyle[ i ] = 'text-align:' .. args['colalign' .. tostring(i)] .. ';' .. colstyle[ i ] | colstyle[ i ] = 'text-align:' .. args['colalign' .. tostring(i)] .. ';' .. colstyle[ i ] | ||
Line 93: | Line 90: | ||
-- build the table content | -- build the table content | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
for j=1,rows do | for j=1,rows do | ||
-- start a new row | -- start a new row | ||
local row = root:tag('tr') | local row = root:tag('tr') | ||
− | + | row:css('vertical-align', 'top') | |
− | + | -- loop over the cells in each row | |
− | |||
− | |||
− | |||
− | -- loop over the cells in | ||
for i=1,cols do | for i=1,cols do | ||
− | local | + | local cell = row:tag('td') |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
if args['class' .. tostring(j) .. '.' .. tostring(i)] then | if args['class' .. tostring(j) .. '.' .. tostring(i)] then | ||
cell:addClass(args['class' .. tostring(j) .. '.' .. tostring(i)]) | cell:addClass(args['class' .. tostring(j) .. '.' .. tostring(i)]) | ||
− | + | elseif args['rowclass' .. tostring(j)] then | |
− | + | cell:addClass(args['rowclass' .. tostring(j)]) | |
− | + | elseif args['row' .. tostring(j) .. 'class'] then | |
− | + | cell:addClass(args['row' .. tostring(j) .. 'class']) | |
− | + | elseif colclass[i] ~= '' then | |
− | + | cell:addClass(colclass[i]) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
if args['style' .. tostring(j) .. '.' .. tostring(i)] then | if args['style' .. tostring(j) .. '.' .. tostring(i)] then | ||
cell:cssText(args['style' .. tostring(j) .. '.' .. tostring(i)]) | cell:cssText(args['style' .. tostring(j) .. '.' .. tostring(i)]) | ||
− | + | elseif args['rowstyle' .. tostring(j)] then | |
− | + | cell:cssText(args['rowstyle' .. tostring(j)]) | |
− | + | elseif args['row' .. tostring(j) .. 'style'] then | |
− | + | cell:cssText(args['row' .. tostring(j) .. 'style']) | |
− | + | elseif colstyle[i] ~= '' then | |
− | + | cell:cssText(colstyle[i]) | |
− | |||
− | |||
− | |||
end | end | ||
− | cell:wikitext | + | cell:wikitext(args[cols*(j - 1) + i] or '') |
end | end | ||
end | end |