Dicemonger (talk | contribs) mNo edit summary |
Dicemonger (talk | contribs) mNo edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
function p.div(frame) | function p.div(frame) | ||
return "</div>" .. getBeginDiv(frame) | return "</div></div>" .. getBeginDiv(frame) | ||
end | end | ||
function p.stop(frame) | function p.stop(frame) | ||
return "</div>" | return "</div></div>" | ||
end | end | ||
Line 47: | Line 47: | ||
function getMinWidth(frame, cols) | function getMinWidth(frame, cols) | ||
if frame.args['ignoreminwidth'] == nil or frame.args['ignoreminwidth'] == false then | if frame.args['minwidth'] then | ||
return frame.args['minwidth'] | |||
elseif frame.args['ignoreminwidth'] == nil or frame.args['ignoreminwidth'] == false then | |||
if cols == "0" then | if cols == "0" then | ||
return "auto" | return "auto" | ||
Line 53: | Line 55: | ||
return "100%" | return "100%" | ||
elseif cols == "2" then | elseif cols == "2" then | ||
return " | return "400px" | ||
elseif cols == "3" then | elseif cols == "3" then | ||
return " | return "270px" | ||
elseif cols == "4" then | elseif cols == "4" then | ||
return " | return "200px" | ||
elseif cols == "5" then | elseif cols == "5" then | ||
return " | return "150px" | ||
elseif cols == "6" then | elseif cols == "6" then | ||
return " | return "125px" | ||
end | end | ||
end | end | ||
Line 68: | Line 70: | ||
function getBorder(frame) | function getBorder(frame) | ||
if frame.args['border'] == true then | if frame.args['border'] == "true" then | ||
return "border:1px solid #DDDDDD;" | return "border:1px solid #DDDDDD;" | ||
else | else | ||
Line 78: | Line 80: | ||
if not frame.args['background'] == nil then | if not frame.args['background'] == nil then | ||
return "background-color: " .. frame.args['background'] .. ";" | return "background-color: " .. frame.args['background'] .. ";" | ||
elseif frame.args['border'] == true then | elseif frame.args['border'] == "true" then | ||
return "background-color:#ffffff;" | return "background-color:#ffffff;" | ||
else | else | ||
Line 86: | Line 88: | ||
function getTextAlignment(frame) | function getTextAlignment(frame) | ||
if frame.args['center'] == true then | if frame.args['center'] == "true" then | ||
return "text-align:center;" | return "text-align:center;" | ||
else | else | ||
Line 94: | Line 96: | ||
function getPadding(frame) | function getPadding(frame) | ||
if frame.args['nomargin'] == true then | if frame.args['nomargin'] == "true" then | ||
return "padding:0px;;" | return "padding:0px;;" | ||
elseif frame.args['center'] == true then | elseif frame.args['center'] == "true" then | ||
return "padding:20px;" | return "padding:20px;" | ||
else | else | ||
Line 104: | Line 106: | ||
function getMargin(frame) | function getMargin(frame) | ||
if frame.args['nomargin'] == true then | if frame.args['nomargin'] == "true" then | ||
return "margin:0px;;" | return "margin:0px;;" | ||
elseif frame.args['border'] == true then | elseif frame.args['border'] == "true" then | ||
return "margin:4px;" | return "margin:4px;" | ||
else | else |
Latest revision as of 08:35, 16 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></div>" .. getBeginDiv(frame)
end
function p.stop(frame)
return "</div></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['minwidth'] then
return frame.args['minwidth']
elseif 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 "400px"
elseif cols == "3" then
return "270px"
elseif cols == "4" then
return "200px"
elseif cols == "5" then
return "150px"
elseif cols == "6" then
return "125px"
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