Homepage
Games
News
News βΎ
All
Transfers
Drama
Business
Sponsors
Mergers
Investors
Hires
Companies
More
People
Tournaments
Brands
Brands βΎ
Companies
Organizations
Sponsors
Other
Locations
Search
Editing
Module:Tabs
From TwogPedia
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local getArgs = require('Module:Arguments').getArgs local Tabs = {} function Tabs.main(frame) local args = getArgs(frame) local tabCount = Tabs.number_of_tabs(args) local currentTitle = mw.title.getCurrentTitle().prefixedText local activeTab = nil local outerDiv = mw.html.create('div') :addClass('tabs-container') local ul = outerDiv:tag('ul') :attr('class', 'tabs') for i = 1, tabCount do local link = args['link' .. i] local tabName = args['name' .. i] local text -- If there is no name, then use last part of the link if tabName == nil and link ~= nil then tabName = mw.text.split(link, '/')[#mw.text.split(link, '/')] text = '[[' .. link .. '|' .. tabName .. ']]' elseif link ~= nil then text = '[[' .. link .. '|' .. tabName .. ']]' else text = tabName end local li = ul:tag('li') :wikitext(text) -- if (link == currentTitle) then if (args.org) then if (currentTitle:sub(1, #link) == link) then activeTab = i li:addClass('active') end else if (link == currentTitle) then activeTab = i li:addClass('active') end end end -- optionally add more tab bars beneath local extra = '' if activeTab and args['tabs' .. activeTab] ~= nil then extra = args['tabs' .. activeTab] end return tostring(outerDiv) .. extra end -- Computes the number of tabs requested function Tabs.number_of_tabs(args) args = args or {} local i = 0 while args['name' .. (i + 1)] ~= nil or args['link' .. (i + 1)] ~= nil do i = i + 1 end if i == 0 then error('The Tabs template needs name and link arguments.') end return i end return Tabs
Summary:
Please note that all contributions to TwogPedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TwogPedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:Tabs/doc
(
edit
)
No categories
Edit