Module:TabsTitle

From Leaguepedia | League of Legends Esports Wiki
Jump to: navigation, search

Documentation for this module may be created at Module:TabsTitle/doc

local util_args = require('Module:ArgsUtil')
local util_title = require('Module:TitleUtil')
local util_vars = require('Module:VarsUtil')
local util_text = require('Module:TextUtil')

local TabsAbstract = require('Module:TabsAbstract')

local Tabs = TabsAbstract:extends()
local TabsFromLua = Tabs:extends()

local p = {}
local h = {}

function p.fromArgs(frame)
	local args = util_args.merge()
	return Tabs():run(args)
end

function p.fromTables(names, links, This)
	return TabsFromLua():run(links, names, This)
end

function Tabs:init()
	self.tabClass = 'titletabs-tab'
	self.activeClass = 'titletabs-active'
	self.outerClass = 'titletabs-tabs'
end

function Tabs:printOneTab(output, tabDisplay)
	local tab = output:tag('div')
		:addClass(self.tabClass)
		:wikitext(tabDisplay)
	return tab
end

function TabsFromLua:run(links, names, This)
	self.title = mw.title.getCurrentTitle().prefixedText
	self.This = This
	self.links = self:getLinksFromTables(links, names)
	self:setThisVar()
	return self:makeOutput()
end

function TabsFromLua:getLinksFromTables(links, names)
	local ret = {}
	for i, link in ipairs(links) do
		ret[#ret+1] = {
			link = link,
			name = names[i]
		}
	end
	return ret
end

return p