Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 03:37, 10 June 2016 by commons>Jarekt
Module documentation[ view · edit · history · purge ]
This documentation is transcluded from Module:Infobox/doc.

Examples

Code Render Comment
{{#invoke:Infobox|Infobox_1_line|field_name=PI|field_value = 3.14159}}
local p = {}

function p._InfobarLayout(lang, class, style)
	local dir = mw.language.new(lang):getDir() or 'ltr'
	return string.format('cellpadding="2" class="toccolours mw-content-%s layouttemplate %s" style="width: 100%; direction: %s; %s" lang="%s"', lang, class, dir, style, lang)
end

function p.InfobarLayout(frame)
	local args = frame.args
	if not (args.lang and mw.language.isSupportedLanguage(args.lang)) then 
		args.lang = mw.message.new( "lang" ):plain() -- get user's chosen language 
	end
	return p._InfobarLayout(args.lang, args.class or '', args.style or '')
end

function p._Infobox_1_line(lang, field_name, field_value)

	local style = _InfobarLayout(lang, 'commons-file-information-table', '')
	local results = string.format('<tr><td class="type fileinfo-paramfield">%s</td><td>\n%s\n</td></tr>', field_name, field_value)
	results = string.format('<table %s>%s</table>\n', style, results)
end

function p.Infobox_1_line(frame)
	local args = frame.args
	if not (args.lang and mw.language.isSupportedLanguage(args.lang)) then 
		args.lang = mw.message.new( "lang" ):plain() -- get user's chosen language 
	end
	return p._Infobox_1_line(args.lang, args.field_name, args.field_value)
end


function p._Infobox_1_line_(lang, field_name, field_value)
	local dir = mw.language.new(lang):getDir() or 'ltr'
	local row = mw.html.create('tr')
		:attr('valign', 'top')
		:tag('td')
			:attr('id', id)
			:addClass('fileinfo-paramfield')
			:wikitext(field_name)
		:tag('td')
			:wikitext(field_value)
		:allDone()
		
	local infobox = mw.html.create('div')
		:addClass('hproduct commons-file-information-table')
		:tag('table')
			:addClass('toccolours mw-content-' .. lang)
			:attr('direction', dir)
			:css({width = '100%', cellpadding = '2'})
		:node(row)
		:allDone()
	return tostring(infobox)
end

return p
Contents
Cookies help us deliver our services. By using our services, you agree to our use of cookies.