Implementează {{Collapsible list}}


local p = {}

p.main = function(frame)
	local origArgs
	if frame == mw.getCurrentFrame() then
		origArgs = frame:getParent().args
	else
		origArgs = frame
	end
	local framestyle = mw.text.trim(origArgs['framestyle'] or origArgs['frame_style'] or 'border:none; padding:0;')
	local collapsed = mw.text.trim(origArgs['collapsed'] or '')
	local titlestyle = mw.text.trim(origArgs['titlestyle'] or origArgs['title_style'] or '')
	local title = mw.text.trim(origArgs['title'] or 'Listă')
	local liststyle = mw.text.trim(origArgs['list_style'] or origArgs['liststyle'] or 'text-align: left;')
	local anonArgs = {}
	for k, v in pairs(origArgs) do
		if type(k) == 'number' then
			anonArgs[k] = mw.text.trim(v)
		end
	end
	return p.display(collapsed, framestyle, titlestyle, title, liststyle, anonArgs)
end

p.display = function(collapsed, framestyle, titlestyle, titleText, liststyle, anonArgs)
	local root = mw.html.create('div'):addClass('NavFrame')
	if collapsed and collapsed ~= '' then root:addClass('collapsed') end
	root:cssText(framestyle or '')
	local title = root:tag('div'):addClass('NavHead')
	if titlestyle and titlestyle ~= '' then
		title:cssText(titlestyle)
	else
		title:css('width', '96%'):css('background', 'transparent'):attr('align', 'left')
	end
	title:wikitext(titleText or 'Listă')
	
	local first = true
	local content = root:tag('div'):addClass('NavContent'):cssText(liststyle or '')
	for idx = 1,table.maxn(anonArgs or {}) do
		if anonArgs[idx] ~= nil and anonArgs[idx] ~= '' then
			if not first then content:wikitext(tostring(mw.html.create('br'))) end
			content:wikitext(anonArgs[idx])
			first = false
		end
	end
	
	return tostring(root)
end

return p