Module:TabsHeader

local styles = { header = { tab = 'tabheader-tab', active = 'tabheader-active', outer = 'tabheader-top' },	title = { tab = 'titletabs-tab', active = 'titletabs-active', outer = 'titletabs-tabs' } }

local p = {}

function p.fromArgs(frame) if frame == mw.getCurrentFrame then args = require('Module:ProcessArgs').merge(true) else frame = mw.getCurrentFrame end

local output = {} local this = tonumber(args.This) local title = mw.title.getCurrentTitle.prefixedText if args.links then names = args.names and mw.text.split(args.names,'%s*,%s*') or {} links = args.links:gsub('_',' ') for k, v in ipairs(mw.text.split(links,'%s*,%s*')) do			output[k] = string.format('%s',				v,				args['name' .. k] or names[k] or v			) if v == title then this = k			end end else local i = 1 while args['link' .. i] do			output[i] = string.format('%s',				args['link' .. i],				args['name'.. i] or args['link' .. i]			) i = i + 1 end end return p.main(output, this, args) end

function p.fromTables(names, links, this, settings) local output = {} for k, v in ipairs(links) do		output[k] = string.format('%s',			v,			names[k] or v		) end return p.main(output, this, settings) end

function p.main(links, this, settings) if not settings then settings = {} end local style = settings.tabstype or 'header' local tbl = p.initialize(settings, style) for k, v in ipairs(links) do		p.makeTab(tbl, style, v, k == this) end local f = mw.getCurrentFrame f:callParserFunction('#vardefine:tabThis',this) return tostring(tbl) end

function p.initialize(settings, style) return mw.html.create('div') :addClass(styles[style].outer) :css({ ['background-color'] = settings.backgroundcolor }) end

function p.makeTab(tbl, style, v, isthis) tbl:tag('div') :addClass(styles[style].tab) :addClass(isthis and styles[style].active or '') :wikitext(v) return end

return p