Module:ExpandImage

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search

local p = {}

function p.main(frame)

    local args = frame.args

    local file = args[1]
    local size = args[2] or "125x125px"
    local align = args[3] or ""

    if not file or file == "" then
        return ""
    end

    local id = mw.hash.hashValue("adler32", file .. mw.getCurrentFrame():getTitle())

    local content1 = id .. "Content1"
    local content2 = id .. "Content2"

    local html = mw.html.create("div")
    html:addClass("morphcontainer")

    html:tag("div")
        :attr("id", content1)
        :addClass("morphcontent")
        :tag("span")
            :addClass("morphlink showhidetext")
            :attr("data-correspondingcontent", content2)
            :wikitext("[[File:" .. file .. "|" .. size .. "|" .. align .. "|link=]]")

    html:tag("div")
        :attr("id", content2)
        :addClass("morphcontent hiddentext")
        :tag("span")
            :addClass("morphlink showhidetext")
            :attr("data-correspondingcontent", content1)
            :wikitext("[[File:" .. file .. "|" .. align .. "|link=]]")

    return tostring(html)

end

return p