Module:Aligned table: Difference between revisions

no edit summary
(colstyle and colclass and colalign and colnowrap)
No edit summary
Line 12: Line 12:
local colstyle = {}
local colstyle = {}
local cols = tonumber(args['cols']) or 2
local cols = tonumber(args['cols']) or 2
local class = args['class'] or ''
 
local style = args['style'] or ''
local leftright = args['leftright'] or ''
local fullwidth = args['fullwidth'] or ''
if leftright ~= '' then
colstyle[1] = 'text-align:left;'
colstyle[2] = 'text-align:right;'
end
-- create the root table
-- create the root table
local root = mw.html.create('table')
local root = mw.html.create('table')
-- add table style for fullwidth
-- add table style for fullwidth
if fullwidth ~= '' then
if isnotempty(args['fullwidth']) then
root
root
:css('width', '100%')
:css('width', '100%')
Line 31: Line 24:
:css('border', 'none')
:css('border', 'none')
end
end
-- add table classes
-- add table classes
if class ~= '' then
if isnotempty(args['class']) then
root:addClass(class)
root:addClass(args['class'])
end
end
-- add table style
-- add table style
if style ~= '' then
if isnotempty(args['style']) then
root:cssText(style)
root:cssText(args['style'])
end
end
-- build arrays with the column styles and classes
-- build arrays with the column styles and classes
if isnotempty(args['leftright']) then
colstyle[1] = 'text-align:left;'
colstyle[2] = 'text-align:right;'
end
for i = 1,cols do
for i = 1,cols do
colclass[ i ] = colclass[ i ] or ''
colclass[ i ] = colclass[ i ] or ''
Anonymous user