Module:Tabs

-- Author: Vogan for Liquipedia --

local p = {} -- p stands for package

local getArgs = require('Module:Arguments').getArgs local args

-- Creates static tabs function p.static(frame) args = getArgs(frame)

local tabs = p.number_of_tabs(args) local this = tonumber(args['This'])

local outerDiv = mw.html.create('div') :addClass('tabs-static')

local list = outerDiv:tag('ul') :attr('class', 'nav nav-tabs navigation-not-searchable tabs tabs' .. tabs)

for i = 1, tabs do       local link = args['link' .. i]       local tabName = args['name' .. i]       local text = '' if (link ~= nil) then text =  .. tabName ..  else text = tabName end

local li = list:tag('li') :wikitext(text) if this == i then li:addClass('active') end end

return outerDiv

end -- Creates dynamic tabs function p.dynamic(frame) args = getArgs(frame)

local this = tonumber(args['This']) or 1 local hideShowAll = args['hide-showall'] local tabs = p.number_of_tabs(args)

local list = '\n' local innerDiv = '\n '

local i = 1 while(i <= tabs) do       local text = args['name' .. i]       local li = '\n' .. text .. ''        list = list .. li

local content = args['content' .. i]       if content ~= nil then local contentDiv = '\n' .. '\n' .. content .. ' '           innerDiv = innerDiv .. contentDiv end i = i + 1 end

if (hideShowAll == nil) then local li = 'Show All' list = list .. li   end list = list .. '\n'

local outerDiv = ' ' outerDiv = outerDiv .. list .. innerDiv

if args['content1'] ~= nil then outerDiv = outerDiv .. '\n \n ' -- close off both inner and outer end

return outerDiv

end

-- Returns the number of tabs requested function p.number_of_tabs(args) local i = 1 while (args['name' .. i] ~= nil) do       i = i + 1 end return i - 1 -- Counting stops WHEN name is null, thus the actual number is -1 end

return p