Модуль:Carousel
Материал из YastreWiki
Дополнительные действия
Для документации этого модуля может быть создана страница Модуль:Carousel/doc
local p = {}
function p.render(frame)
local parent = frame:getParent()
local args = parent and parent.args or frame.args
local root = mw.html.create('div')
:addClass('yastre-carousel-container')
local inner = root:tag('div')
:addClass('yastre-carousel')
local files = {}
local i = 1
while args ~= nil do
local file = mw.text.trim(args)
if file ~= '' then
table.insert(files, file)
end
i = i + 1
end
local total = #files
if total == 0 then
return "<!-- Карусель пуста -->"
end
for index, file in ipairs(files) do
local item = inner:tag('div'):addClass('carousel-item')
if index == 1 then
item:addClass('active')
elseif index == 2 then
item:addClass('next')
elseif index == total and total > 2 then
item:addClass('prev')
else
item:addClass('hidden')
end
item:tag('div')
:addClass('carousel-image')
:wikitext(']')
end
return tostring(root)
end
return p