Editing Module:Aligned table
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 39: | Line 39: | ||
colstyle[1] = 'text-align:left;' | colstyle[1] = 'text-align:left;' | ||
colstyle[2] = 'text-align:right;' | colstyle[2] = 'text-align:right;' | ||
end | end | ||
for i = 1,cols do | for i = 1,cols do | ||
Line 48: | Line 44: | ||
colstyle[ i ] = colstyle[ i ] or '' | colstyle[ i ] = colstyle[ i ] or '' | ||
if isnotempty(args['colstyle']) then | if isnotempty(args['colstyle']) then | ||
colstyle[ i ] = args['colstyle'] .. ';' | colstyle[ i ] = args['colstyle'] .. ';' | ||
end | end | ||
if isnotempty(args['colalign' .. tostring(i)]) then | if isnotempty(args['colalign' .. tostring(i)]) then | ||
Line 97: | Line 93: | ||
-- 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 |