Modul:Collapse

This is [[MediaWiki:Tagline]]. Set to <code>display:none</code> by chameleon skin.
Version vom 12. Januar 2016, 08:07 Uhr von imported>Oetterer
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu:Navigation, Suche
Documentation icon Module documentation[view] [edit] [history] [purge]

This module DOES NOT implement template {{Collapse}}. It copies that template's function, though.

Usage

{{#invoke:Collapse|main}}

local p = {}
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')

function p._main(args)
	local html = mw.html.create('table')
	html:addClass('navbox')
		:addClass('mw-collapsible')
		:addClass(not yesno(args.expand) and 'mw-collapsed')
		:cssText('text-align: left; border: ' .. (args.expand or '1px') .. ' solid silver; margin-top: 0.2em; background: ' .. (args.bg1 or 'transparent') .. (args.width and '; width: ' .. args.width or ''))
		:tag('tr')
			:tag('th')
				:cssText('background-color: ' .. (args.bg or '#CFC') ..'; text-align: ' .. (yesno(args.left) and 'left' or 'center') .. '; font-size:112%; color: ' .. (args.fc or 'black'))
				:wikitext(args[1] or args.title or args.reason or args.header or args.heading or 'Extended content')
				:done()
			:done()
		:tag('tr')
			:tag('td')
				:cssText('border: solid ' .. (args.border2 or '1px silver') .. '; padding: ' .. (args.padding or '8px') .. '; background-color: ' .. (args.bg2 or 'white') .. '; font-size: 112%')
				:wikitext(args[2] or args.text or args.content)
				:done()
			:done()
	return tostring(html)
end

function p.main(frame)
	local args
	if frame == mw.getCurrentFrame() then
		args = getArgs(frame)
	else
		args = frame
	end
	return p._main(args)
end

return p