Module:TabsHeader

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 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 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.makeTab(tbl, v, isthis) class = isthis and 'tabheader-active' or '' tbl:tag('div') :addClass('tabheader-tab') :addClass(class) :wikitext(v) return end

function p.main(links, this, settings) frame = mw.getCurrentFrame frame:callParserFunction{ name = '#vardefine:hastabs', args = 'true' } tbl = mw.html.create('div') :css({ ['background-color'] = settings.backgroundcolor }) :addClass('tabheader-top') for k, v in ipairs(links) do		p.makeTab(tbl, v, k == this) end return tostring(tbl) end

return p