
You do not need an accout to report a problem with the wiki.
-
Module:Page tabs
From TechInfoDepot
Jump to navigationJump to search![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | Uses Lua: |
This module implements {{page tabs}}. Please see the template page for documentation.
The above documentation is transcluded from Module:Page tabs/doc. (edit | history) Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages. Subpages of this module. |
-- This module implements {{Page tabs}}.
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
local makeTab = p.makeTab
local root = mw.html.create()
root:wikitext(yesno(args.NOTOC) and '__NOTOC__' or nil)
local row = root:tag('div')
:css('background', args.Background or '#f8fcff')
:css('color', 'black')
:cssText(args.style or nil)
:addClass('template-page-tabs')
:addClass(args.class or nil)
if not args[1] then
args[1] = '{{{1}}}'
end
for i, link in ipairs(args) do
makeTab(row, link, args, i, args["class" .. i] or nil, args["style" .. i] or nil)
end
return tostring(root)
end
function p.makeTab(root, link, args, i, class, css)
local thisPage = (args.This == 'auto' and link:find('[[' .. mw.title.getCurrentTitle().prefixedText .. '|', 1, true)) or tonumber(args.This) == i
root:tag('span')
:addClass(class)
:css('background-color', thisPage and (args['tab-bg'] or 'white') or (args['tab1-bg'] or '#e0edf6'))
:css('color', 'black')
:cssText(thisPage and 'border-bottom:0;font-weight:bold' or 'font-size:95%')
:cssText(css)
:wikitext(link)
:done()
:wikitext('<span class="spacer ' .. (class or "") .. '"> </span>')
end
return p