Leaguepedia | League of Legends Esports Wiki

Edit the documentation or categories for this module. This module has an i18n file.


local util_math = require("Module:MathUtil")
local util_vars = require("Module:VarsUtil")
local i18n = require("Module:I18nUtil")

local h = {}
local p = {}
function p.printToggles(output, COLUMNS)
	i18n.init('ColumnShowHide')
	if not output then output = mw.html.create() end
	output:wikitext(i18n.print('introText'), mw.getCurrentFrame():callParserFunction{
		name = '#widget',
		args = h.getWidgetArgs(COLUMNS)
	})
	return output
end

function p.printTableClass(tbl)
	if not tbl then tbl = mw.html.create('table') end
	tbl:addClass('column-show-hide-' .. h.getTableIndex())
	return tbl
end

function h.getWidgetArgs(COLUMNS)
	local ret = {
		'ColumnShowHide',
		table = h.setTableIndex()
	}
	for i, col in ipairs(COLUMNS) do
		ret['columns.' .. util_math.padleft(i, 2)] = i18n.print(col) or col
	end
	return ret
end

function h.getTableIndex()
	return util_vars.getGlobalIndex('COLUMN_SHOW_HIDE_WIDGET_INDEX')
end

function h.setTableIndex()
	return util_vars.setGlobalIndex('COLUMN_SHOW_HIDE_WIDGET_INDEX')
end

return p