Leaguepedia | League of Legends Esports Wiki
Advertisement
Leaguepedia | League of Legends Esports Wiki

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

local util_args = require('Module:ArgsUtil')
local util_cargo = require("Module:CargoUtil")
local util_html = require("Module:HtmlUtil")
local util_map = require('Module:MapUtil')
local util_math = require("Module:MathUtil")
local util_table = require("Module:TableUtil")
local util_text = require("Module:TextUtil")
local util_vars = require("Module:VarsUtil")
local i18n = require("Module:I18nUtil")
local lang = mw.getLanguage('en')
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
Advertisement