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.

Module:Infobox: Difference between revisions

From Neodyland Wiki
Created page with 'local p = {} function _InfobarLayout(lang, class, style) local dir = mw.language.new(lang):getDir() or 'ltr' return string.format('cellpadding="2" class="toc...'
 
No edit summary
Line 1: Line 1:
local p = {}
local p = {}


function _InfobarLayout(lang, class, style)
function p._InfobarLayout(lang, class, style)
local dir = mw.language.new(lang):getDir() or 'ltr'
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)
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
end


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


function _Infobox_1_line(lang, field_name, field_value)
function p._Infobox_1_line(lang, field_name, field_value)


local style = _InfobarLayout(lang, 'commons-file-information-table', '')
local style = _InfobarLayout(lang, 'commons-file-information-table', '')
Line 21: Line 21:
end
end


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




function _Infobox_1_line_(lang, field_name, field_value)
function p._Infobox_1_line_(lang, field_name, field_value)
local dir = mw.language.new(lang):getDir() or 'ltr'
local dir = mw.language.new(lang):getDir() or 'ltr'
local row = mw.html.create('tr')
local row = mw.html.create('tr')

Revision as of 03:03, 10 June 2016

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._Infobar-Layout(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(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.