Dicemonger (talk | contribs) (Created page with "local p = {} function p.begin(frame) return getBeginDiv(frame) end function p.div(frame) return "</div>" .. getBeginDiv(frame) end function p.stop(frame) return "</div>" end function getBeginDiv(frame) local cols = getCols(frame) local minWidth = getMinWidth(frame, cols) return "<div style=\"display:inline-table;width:" .. getWidth(cols) .. ";min-width:" .. minWidth .. ";\">" .. "<div style=\"" .. getBorder(frame) .. getBackground(frame) .. getTextAlignmen...") |
Dicemonger (talk | contribs) mNo edit summary |
||
Line 16: | Line 16: | ||
local cols = getCols(frame) | local cols = getCols(frame) | ||
return "<div style=\"display:inline-table;width:" .. getWidth(cols) .. ";min-width:" .. getMinWidth(frame, cols) .. ";\">" .. "<div style=\"" .. getBorder(frame) .. getBackground(frame) .. getTextAlignment(frame) .. getPadding(frame) .. getMargin(frame)"\">" | |||
return "<div style=\"display:inline-table;width:" .. getWidth(cols) .. ";min-width:" .. | |||
end | end | ||
Revision as of 16:11, 9 June 2023
Documentation for this module may be created at Module:Grid/doc
local p = {}
function p.begin(frame)
return getBeginDiv(frame)
end
function p.div(frame)
return "</div>" .. getBeginDiv(frame)
end
function p.stop(frame)
return "</div>"
end
function getBeginDiv(frame)
local cols = getCols(frame)
return "<div style=\"display:inline-table;width:" .. getWidth(cols) .. ";min-width:" .. getMinWidth(frame, cols) .. ";\">" .. "<div style=\"" .. getBorder(frame) .. getBackground(frame) .. getTextAlignment(frame) .. getPadding(frame) .. getMargin(frame)"\">"
end
function getCols(frame)
local cols = frame.args['cols']
if cols == nil then
return "2"
end
return cols
end
function getWidth(cols)
if cols == "0" then
return "auto"
elseif cols == "1" then
return "100%"
elseif cols == "2" then
return "49%"
elseif cols == "3" then
return "32%"
elseif cols == "4" then
return "24%"
elseif cols == "5" then
return "19%"
elseif cols == "6" then
return "16%"
end
end
function getMinWidth(frame, cols)
if frame.args['ignoreminwidth'] == nil or frame.args['ignoreminwidth'] == false then
if cols == "0" then
return "auto"
elseif cols == "1" then
return "100%"
elseif cols == "2" then
return "500px"
elseif cols == "3" then
return "330px"
elseif cols == "4" then
return "250px"
elseif cols == "5" then
return "200px"
elseif cols == "6" then
return "160px"
end
end
return 0
end
function getBorder(frame)
if frame.args['border'] == true then
return "border:1px solid #DDDDDD;"
else
return ""
end
end
function getBackground(frame)
if not frame.args['background'] == nil then
return "background-color: " .. frame.args['background'] .. ";"
elseif frame.args['border'] == true then
return "background-color:#ffffff;"
else
return "background-color:#FFFFFF00;"
end
end
function getTextAlignment(frame)
if frame.args['center'] == true then
return "text-align:center;"
else
return ""
end
end
function getPadding(frame)
if frame.args['nomargin'] == true then
return "padding:0px;;"
elseif frame.args['center'] == true then
return "padding:20px;"
else
return "padding:10px;"
end
end
function getMargin(frame)
if frame.args['nomargin'] == true then
return "margin:0px;;"
elseif frame.args['border'] == true then
return "margin:4px;"
else
return ""
end
end
return p