ਮੌਡਿਊਲ:Table
ਦਿੱਖ
Documentation for this module may be created at ਮੌਡਿਊਲ:Table/doc
function table( frame )
local args = frame.args
local not_nodots = args[1] == nil or mw.text.trim( args[1] ) ~= 'nodots'
-- General container (relative and non- transparent background) Table positioning
local text = string.format( '<div class="tableItem" style="position:relative;margin:%s auto;',
out_arg( args.espace, ".125em" ) )
if args.align == 'left' or args.align == 'right' then
text = text .. string.format('margin-%s:0;', args.align)
end
if args.largeur and args.largeur ~= '' then
text = text .. string.format('width:%s;', args.largeur)
end
if args.color_background and args.color_background ~= '' then
text = text .. string.format('background:%s;', args.color_background)
elseif not_nodots then
text = text .. 'background:#FFF;'
end
if args.color and args.color ~= '' then
text = text .. string.format('color:%s;', args.color)
elseif not_nodots then
text = text .. 'color:#000;'
end
text = text .. 'line-height:normal">' -- Fin de l'ouverture du div externe
-- TDM : Container with section + title + page (only necessary if page number)
if args.page and args.page ~= '' then
text = text .. string.format( '<div style="margin-right:%spx">', out_arg( args.largeurp, "0" ) )
-- LEFT + CENTER : Floating Container left with + section title (only necessary if page number)
text = text .. '<div style="float:left;width:100%">'
end
-- LEFT : left section number floating container ( if not transparent dotted )
if args.section and args.section ~= '' then
text = text .. string.format( '<div style="float:left;z-index:2;min-width:%spx;text-indent:0;text-align:%s;white-space:nowrap">',
out_arg( args.largeurs, 45), out_arg( args.aligns, 'right') )
if not_nodots then
text = text .. string.format('<span style="background:%s">', out_arg( args.color_background, '#FFF' ) )
end
text = text .. args.section .. ' '
if not_nodots then
text = text .. '</span>'
end
text = text .. '</div>'
-- CENTRE : Container title and dashed
text = text .. string.format( '<div style="position:relative;margin-left:%spx">', out_arg(args.largeurs, 45) )
end
-- Optional internal container to manage the negative margin indentation
if tonumber( out_arg(args.indentation, 0 ) ) < 0 then
text = text .. string.format( '<div style="margin-left:%s%s;text-indent:%s%s">',
-args.indentation, out_arg(args.indentation_unit, "em"), args.indentation, out_arg(args.indentation_unit, "em" ) )
end
-- The title itself ( justifiable indentable ) , the top of the container CENTRE ( if not transparent dotted )
text = text .. '<div style="position:relative;z-index:2;'
if args.text_align and args.text_align ~= 'justify' then
text = text .. string.format( 'text-align:%s;', args.text_align )
end
if tonumber( out_arg(args.indentation, 0 ) ) > 0 then
text = text .. string.format( 'text-indent:%s%s', args.indentation, out_arg(args.indentation_unit, "em" ) )
end
text = text .. '">'
if not_nodots then
text = text .. string.format('<span style="background:%s">', out_arg( args.color_background, '#FFF' ) )
end
text = text .. out_arg(args.title, '' )
if not_nodots then
text = text .. ' </span>'
end
text = text .. '</div>'
-- End of optional internal container to manage the negative margin indentation
if tonumber( out_arg(args.indentation, 0 ) ) < 0 then
text = text .. '</div>'
end
-- Prospective dotted (bunk below, requires an absolute positioning in the container CENTRE )
if not_nodots then
text = text .. '<div class="ws-noexport" style="position:relative;'
text = text .. string.format( 'margin-left:%d%s">', math.abs( tonumber( out_arg( args.indentation, "0" ) ) ) + 1, out_arg( args.indentation_unit, "em" ) )
text = text .. '<div style="position:absolute;z-index:1;bottom:.3em;width:100%;border-bottom:0.135em dotted '
text = text .. out_arg( args.color, '#000' ) .. '"></div>'
text = text .. '</div>'
end
-- CENTRE : End of title container and dotted
if args.section and args.section ~= '' then
text = text .. '</div>'
-- Extends vertically floating the left ( section number )
text = text .. '<div class="ws-noexport" style="clear:both"></div>'
end
if args.page and args.page ~= '' then
-- LEFT + CENTRE: End of container with + section title (only necessary if page number)
text = text .. '</div>'
-- RIGHT: floating container to the right of the page number (only necessary if page number)
text = text .. '<div class="ws-noexport" style="float:right">'
-- The issue , indivisible , is positioned vertically downward in the floating (not clear if dashes)
text = text .. '<div style="position:absolute;z-index:2;bottom:0;right:0;text-indent:0;text-align:right;white-space:nowrap">'
if not_nodots then
text = text .. string.format('<span style="background:%s">', out_arg( args.color_background, '#FFF' ) )
-- only to avoid sticking to the dotted line
text = text .. ' '
end
text = text .. args.page
if not_nodots then
text = text .. '</span>'
end
text = text .. '</div>'
-- RIGHT: End of floating container page number (only necessary if page number)
text = text .. '</div>'
-- Extends vertically floating the right (to move down the page number )
text = text .. '<div class="ws-noexport" style="clear:both"></div>'
-- TDM :End section of the container with + title + page (only necessary if page number)
text = text .. '</div>'
end
-- EXTERNAL: End of container
text = text .. '</div>'
return text
end
function out_arg( arg, default )
if arg and arg ~= '' then
return arg
end
return default
end
local p = {}
-- Aid debugging , returns the generated code as a string encoded
-- and as html.
function p.table_as_string( frame )
return mw.text.encode( table( frame ) ) .. '<div style="clear:both"></div>' .. table( frame )
end
function p.table( frame )
return table( frame:getParent() )
end
return p