Modul:Infocasetă: Diferență între versiuni
Aspect
mFără descriere a modificării |
mFără descriere a modificării |
||
| Linia 1: | Linia 1: | ||
local p = {} | local p = {} | ||
local function addRow(tableElement, label, value) | |||
if value and value ~= "" then | |||
local tr = tableElement:tag("tr") | |||
tr:tag("th") | |||
:css("text-align", "left") | |||
:css("padding", "5px") | |||
:css("width", "40%") | |||
:css("font-weight", "bold") | |||
:wikitext(label) | |||
tr:tag("td") | |||
:css("padding", "5px") | |||
:wikitext(value) | |||
end | |||
end | |||
function p.infobox(frame) | function p.infobox(frame) | ||
local args = frame:getParent().args | |||
if next(args) == nil then | |||
args = frame.args | |||
end | |||
local title = args.title or args.nume or mw.title.getCurrentTitle().text | local title = args.title or args.nume or mw.title.getCurrentTitle().text | ||
local image = args.image or "" | local image = args.image or args.imagine or "" | ||
local caption = args.caption or "" | local caption = args.caption or args.descriere_imagine or "" | ||
local root = mw.html.create("table") | local root = mw.html.create("table") | ||
| Linia 16: | Linia 33: | ||
:css("border", "1px solid #5b8a3c") | :css("border", "1px solid #5b8a3c") | ||
:css("background", "#f8fff5") | :css("background", "#f8fff5") | ||
:css("border-collapse", "collapse") | |||
:css("font-size", "88%") | |||
-- Titlul Infocasetei | |||
root:tag("tr") | root:tag("tr") | ||
:tag("th") | :tag("th") | ||
| Linia 24: | Linia 44: | ||
:css("font-size", "120%") | :css("font-size", "120%") | ||
:css("padding", "8px") | :css("padding", "8px") | ||
:css("text-align", "center") | |||
:wikitext(title) | :wikitext(title) | ||
-- Gestionare imagine și descriere | |||
if image ~= "" then | if image ~= "" then | ||
local td = root:tag("tr") | local td = root:tag("tr") | ||
:tag("td") | :tag("td") | ||
:attr("colspan","2") | :attr("colspan", "2") | ||
:css("text-align","center") | :css("text-align", "center") | ||
:css("padding", "8px") | |||
td:wikitext( | td:wikitext( | ||
string.format( | string.format( | ||
'<img src="%s" style="max-width:300px;width:100%%;height:auto;border-radius:4px;">', | '<img src="%s" style="max-width:300px;width:100%%;height:auto;border-radius:4px;display:block;margin:0 auto;">', | ||
image | image | ||
) | ) | ||
) | ) | ||
if caption ~= "" then | if caption ~= "" then | ||
td:tag("div") | |||
:css("font-size", "90%") | :css("font-size", "90%") | ||
:css("color", "# | :css("color", "#555") | ||
:css("margin-top", "4px") | |||
:wikitext(caption) | :wikitext(caption) | ||
end | end | ||
end | end | ||
return tostring(root) | return tostring(root) | ||
end | end | ||
return p | return p | ||
Versiunea de la data 7 iunie 2026 15:38
Documentația acestui modul poate fi creată la Modul:Infocasetă/doc
local p = {}
local function addRow(tableElement, label, value)
if value and value ~= "" then
local tr = tableElement:tag("tr")
tr:tag("th")
:css("text-align", "left")
:css("padding", "5px")
:css("width", "40%")
:css("font-weight", "bold")
:wikitext(label)
tr:tag("td")
:css("padding", "5px")
:wikitext(value)
end
end
function p.infobox(frame)
local args = frame:getParent().args
if next(args) == nil then
args = frame.args
end
local title = args.title or args.nume or mw.title.getCurrentTitle().text
local image = args.image or args.imagine or ""
local caption = args.caption or args.descriere_imagine or ""
local root = mw.html.create("table")
:addClass("infocaseta")
:css("width", "320px")
:css("float", "right")
:css("margin", "0 0 1em 1em")
:css("border", "1px solid #5b8a3c")
:css("background", "#f8fff5")
:css("border-collapse", "collapse")
:css("font-size", "88%")
-- Titlul Infocasetei
root:tag("tr")
:tag("th")
:attr("colspan", "2")
:css("background", "#6aa84f")
:css("color", "white")
:css("font-size", "120%")
:css("padding", "8px")
:css("text-align", "center")
:wikitext(title)
-- Gestionare imagine și descriere
if image ~= "" then
local td = root:tag("tr")
:tag("td")
:attr("colspan", "2")
:css("text-align", "center")
:css("padding", "8px")
td:wikitext(
string.format(
'<img src="%s" style="max-width:300px;width:100%%;height:auto;border-radius:4px;display:block;margin:0 auto;">',
image
)
)
if caption ~= "" then
td:tag("div")
:css("font-size", "90%")
:css("color", "#555")
:css("margin-top", "4px")
:wikitext(caption)
end
end
return tostring(root)
end
return p