模块:收纳表:修订间差异

跳到导航 跳到搜索
删除543字节 、​ 2022年6月30日 (星期四)
无编辑摘要
无编辑摘要
无编辑摘要
第31行: 第31行:
     ctab = {},
     ctab = {},
     citm = {},
     citm = {},
}
local CSSvalue = {
    div = {class=''},
    stab = {
        class      = '',
        display    = 'grid',
        margin    = '2.5%',
        gap        = '6px',
    },
    sitm = {
        class  = '',
        margin  = '0',
        padding = '0',
        ['font-weight'] = '700',
    },
    ctab = {
        class  = '',
        display = 'inline',
        margin  = '2.5%',
        ['margin-left'] = '0',
    },
    citm = {class=''},
}
}
local CSSvalue = {}




第68行: 第48行:
     str = str:gsub('^contentitem', 'citem')]]--
     str = str:gsub('^contentitem', 'citem')]]--
     return str:gsub("^%u", string.lower) --第一个字小写
     return str:gsub("^%u", string.lower) --第一个字小写
end
--空的数值填入预设值
local function fillWithDefaultCSS(horizontal)
    local defaults = {
        div = {class=''},
        stab = {
            class      = '',
            display    = 'grid',
            margin    = '2.5%',
            gap        = '6px',
        },
        sitm = {
            class  = '',
            margin  = '0',
            padding = '0',
            ['font-weight'] = '700',
        },
        ctab = {
            class  = '',
            display = 'inline',
            margin  = '2.5%',
            ['margin-left'] = '0',
        },
        citm = {class=''},
    }
    if horizontal then
        defaults['stab']['display'] = 'inline-grid'
        defaults['stab']['height'] = '400px'
        defaults['stab']['overflow-y'] = 'auto'
        defaults['stab']['width'] = '20%'
        defaults['ctab']['height'] = '400px'
        defaults['ctab']['overflow-y'] 'auto'
        defaults['ctab']['width'] = '60%'
    end
    for s in {'div', 'stab', 'sitm', 'ctab', 'citm'} do
        for size, dir in {height='y', width='x'} do
            if CSSvalue[s][size] then
                defaults[s]['overflow-'..dir] = 'auto'
            end
        end
        for CSS, defaultValue in defaults[s] do
            CSSvalue[s][CSS] = CSSvalue[s][CSS] or defaultValue
        end
    end
end
end


第73行: 第102行:


--处理选择栏
--处理选择栏
local function renderSelect(contents, horizontal)
local function renderSelect(contents)
     local tabs_pages = mw.html.create('div')
     local tabs_pages = mw.html.create('div')
         :addClass('tabs_pages ' .. CSSvalue['stab']['class'])
         :addClass('tabs_pages ' .. CSSvalue['stab']['class'])
         :css('grid-template-columns',
         :css('grid-template-columns',
             string.rep('1fr ', tonumber(contents['splitCount'])))
             string.rep('1fr ', tonumber(contents['splitCount'])))
    if horizontal then
        CSSvalue['stab']['display'] = CSSvalue['stab']['display'] or 'inline-grid'
        CSSvalue['stab']['height'] = CSSvalue['stab']['height'] or '400px'
        CSSvalue['stab']['overflow-y'] = CSSvalue['stab']['overflow-y'] or 'auto'
        CSSvalue['stab']['width'] = CSSvalue['stab']['width'] or '20%'
    end
    if CSSvalue['stab']['height'] ~= nil then
        CSSvalue['stab']['overflow-y'] = CSSvalue['stab']['overflow-y'] or 'auto'
    end
    if CSSvalue['stab']['width'] ~= nil then
        CSSvalue['stab']['overflow-x'] = CSSvalue['stab']['overflow-x'] or 'auto'
    end


     for _, CSS in ipairs(ordering['stab']) do
     for _, CSS in ipairs(ordering['stab']) do
第111行: 第127行:


--处理内容栏
--处理内容栏
local function renderContent(contents, horizontal)
local function renderContent(contents)
     local tabs_contents = mw.html.create('div')
     local tabs_contents = mw.html.create('div')
         :addClass('tabs-contents ' .. CSSvalue['ctab']['class'])
         :addClass('tabs-contents ' .. CSSvalue['ctab']['class'])


    if horizontal then
        CSSvalue['ctab']['height'] = CSSvalue['ctab']['height'] or '400px'
        CSSvalue['ctab']['overflow-y'] = CSSvalue['ctab']['overflow-y'] or 'auto'
        CSSvalue['ctab']['width'] = CSSvalue['ctab']['width'] or '60%'
    end
    if CSSvalue['ctab']['height'] ~= nil then
        CSSvalue['ctab']['overflow-y'] = CSSvalue['ctab']['overflow-y'] or 'auto'
    end
    if CSSvalue['ctab']['width'] ~= nil then
        CSSvalue['ctab']['overflow-x'] = CSSvalue['ctab']['overflow-x'] or 'auto'
    end
     for _, CSS in ipairs(ordering['ctab']) do
     for _, CSS in ipairs(ordering['ctab']) do
         tabs_contents:css(CSS, CSSvalue['ctab'][CSS])
         tabs_contents:css(CSS, CSSvalue['ctab'][CSS])
第157行: 第162行:
         end
         end
     end
     end
    table.sort(args)


    --处理CSSvalue
     local validArgs = {stab=true, sitm=true, ctab=true, citm=true}
     local validArgs = {stab=true, sitm=true, ctab=true, citm=true}
     for k, v in pairs(args) do
     for k, v in pairs(args) do  
         k = '' .. k; v = '' .. v
         k = '' .. k; v = '' .. v
         if not (notCSS[k] or k:match('^content%d+')) then
         if not (notCSS[k] or k:match('^content%d+')) then
第169行: 第174行:
                 local CSS = k:sub(5)
                 local CSS = k:sub(5)
                 CSSvalue[prefix][CSS] = v
                 CSSvalue[prefix][CSS] = v
                if not (CSS == 'class') then table.insert(ordering[prefix], CSS) end
             else
             else
                table.insert(ordering['div'], k)
                 CSSvalue['div'][k] = v
                 CSSvalue['div'][k] = v
             end
             end
         end
         end
     end --由于args被排序过了,因此ordering内的阵列也是排序好的
     end
    fillWithDefaultCSS(args['textDisplay']=='left' or args['textDisplay']=='right')


     local mainDiv = mw.html.create('div')
     --处理ordering
    local horizontal = args['textDisplay'] == 'left' or args['textDisplay'] == 'right'
    for s in {'div', 'stab', 'sitm', 'ctab', 'citm'} do
    if horizontal then
         for k, _ in CSSvalue[s] do table.insert(ordering[s], k) end
         CSSvalue['div']['display'] = CSSvalue['div']['display'] or 'flex'
         table.sort(ordering[s])
         args['splitCount'] = args['splitCount'] or 1
     end
     end
    args['splitCount'] = args['splitCount'] or 5


    local mainDiv = mw.html.create('div')
     mainDiv:addClass('tabs-container ' .. CSSvalue['div']['class'])
     mainDiv:addClass('tabs-container ' .. CSSvalue['div']['class'])
     for _, divCSS in ipairs(ordering['div']) do
     for _, divCSS in ipairs(ordering['div']) do
第191行: 第194行:


     if args['textDisplay'] == 'top' or args['textDisplay'] == 'left' then
     if args['textDisplay'] == 'top' or args['textDisplay'] == 'left' then
         mainDiv:node(renderContent(args, horizontal))
         mainDiv:node(renderContent(args))
         mainDiv:node(renderSelect(args, horizontal))
         mainDiv:node(renderSelect(args))
     else
     else
         mainDiv:node(renderSelect(args, horizontal))
         mainDiv:node(renderSelect(args))
         mainDiv:node(renderContent(args, horizontal))
         mainDiv:node(renderContent(args))
     end
     end


导航菜单