Открыть меню
Переключить меню настроек
Открыть персональное меню
Вы не представились системе
Ваш IP-адрес будет виден всем, если вы внесёте какие-либо изменения.

Модуль: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 = {}
    for k, v in ipairs(args) do
        local file = mw.text.trim(v)
        if file ~= '' then
            table.insert(files, file)
        end
    end

    local total = #files

    if total == 0 then
        return "<!-- Карусель пуста -->"
    end

    for i, file in ipairs(files) do
        local item = inner:tag('div'):addClass('carousel-item')
        
        if i == 1 then
            item:addClass('active')
        elseif i == 2 then
            item:addClass('next')
        elseif i == 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