مستخدم مجهول
Optional rowclass
(أنشأ الصفحة ب'-- This module implements {{aligned table}} local p = {} local function isnotempty(s) return s and s:match( '^%s*(.-)%s*$' ) ~= '' end function p.table(frame) local...') |
(Optional rowclass) |
||
سطر ٣٩: | سطر ٣٩: | ||
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 | ||
سطر ١٠٨: | سطر ١١٢: | ||
-- start a new row | -- start a new row | ||
local row = root:tag('tr') | local row = root:tag('tr') | ||
row:css('vertical-align', 'top') | if isnotempty(args['rowstyle']) then | ||
-- loop over the cells in | row:cssText(args['rowstyle']) | ||
else | |||
row:css('vertical-align', 'top') | |||
end | |||
if isnotempty(args['rowclass']) then | |||
row:addClass(args['rowclass']) | |||
end | |||
-- loop over the cells in the row | |||
for i=1,cols do | for i=1,cols do | ||
local cell | local cell | ||
if isnotempty(args['row' .. tostring(j) .. 'header']) then | if isnotempty(args['row' .. tostring(j) .. 'header']) then | ||
cell = row:tag('th') | cell = row:tag('th'):attr('scope','col') | ||
elseif isnotempty(args['col' .. tostring(i) .. 'header']) then | |||
cell = row:tag('th'):attr('scope','row') | |||
else | else | ||
cell = row:tag('td') | cell = row:tag('td') | ||
سطر ١٢٤: | سطر ١٣٧: | ||
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 | ||
سطر ١٣٤: | سطر ١٥١: | ||
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']) | ||
سطر ١٤١: | سطر ١٦٢: | ||
end | end | ||
end | end | ||
cell:wikitext(args[cols*(j - 1) + i] or '') | cell:wikitext(mw.ustring.gsub(args[cols*(j - 1) + i] or '', '^(.-)%s*$', '%1') or '') | ||
end | end | ||
end | end |