FANDOM


-- Implements {{tl|Thumbnail}} and associated layout.
local Thumbnail = {}
local HF = require('Module:HF')
local getArgs = require('Module:Arguments').getArgs
 
function Thumbnail.main(frame) -- Implements {{Thumbnail}}
	local args = getArgs(frame)
	return Thumbnail._thumbnail(args)
end
 
function Thumbnail.container(frame) -- Implements {{Thumbnail/container}}
	local args = getArgs(frame)
	return Thumbnail._container(args)
end
 
function Thumbnail._thumbnail( args )
	-- Variables
	local image = args[1] or args['image'] or 'Stock person bw.png'
	local label = args[2] or args['label'] or ''
	local article = args[3] or args['article'] or ''
	local size = args['size'] or '140x140px'
	local labelLink = ''
 
	if not HF.isempty( article ) then
		labelLink = ' [['..article..'|'..label..']]'
	  elseif HF.isempty(article) and not HF.isempty(label) then
		labelLink = ' '..label
	end
	local imageLink = '[[File:'..image..'|'..size..'|'..label..'|alt='..article..'|link='..article..']]'
 
	-- Process
	local thumbnailTbl = mw.html.create('table')
		:addClass('thumbnail')
		:css('background','#880d08'):css('border','1px solid black')
		:css('-webkit-border-radius','5px'):css('-moz-border-radius','5px')
		:css('border-radius','5px'):css('display','inline-flex'):css('margin','2px')
		if not HF.isempty( args['float'] ) then
			thumbnailTbl:css( 'float', args['float'] )
		end
		thumbnailTbl:tag('tr'):attr('align','center'):css('text-align','center')
		:tag('td')
		:tag('div'):addClass('envelope')
			:css('position','relative'):css('height','90px'):css('width','100px')
		 :tag('div'):addClass('label-background')
			:css('position','absolute'):css('top','77px'):css('left','0px')
			:css('width','100px'):css('overflow','hidden'):css('line-height','12px')
			:css('z-index','3'):css('text-align','right')
		  :tag('div'):addClass('label-text')
			:css('font-size','0.7em'):css('color','black'):css('background-color','white')
			:css('margin-left','auto'):css('border-top-left-radius','8px')
			:css('border-top-right-radius','0'):css('float','right'):css('padding','1px')
			:wikitext(labelLink):done()
		 :done()
		:tag('div'):addClass('porthole')
			:css('position','absolute'):css('top','0px'):css('left','0px')
			:css('height','90px'):css('width','100px'):css('overflow','hidden')
		 :tag('div'):addClass('image-background')
			:css('position','absolute'):css('top','0px'):css('left','0px')
			:css('z-index','2')
			:wikitext(imageLink):done()
		:done()
		:allDone()
	return tostring(thumbnailTbl)
end
 
function Thumbnail._container ( args )
	local contents = ''
	local fullcontainer = mw.html.create('div')
	  :addClass( 'thumbnail-container' )
	  :css( 'display', 'block' )
	if not HF.isempty( args['float'] ) then fullcontainer:css( 'float', args['float'] ) end
	if not HF.isempty( args['width'] ) then fullcontainer:css( 'width', args['width'] ) end
	if not HF.isempty( args['title'] ) then
	  local titlecntnr = mw.html.create('div')
	    :css('display', 'block'):css('font-weight','bold'):css('text-align','center')
	    :wikitext( args['title'] )
	  if not HF.isempty( args['float'] ) then titlecntnr:css( 'float', args['float'] ) end
	  if not HF.isempty( args['width'] ) then titlecntnr:css( 'width', args['width'] ) end  
	  fullcontainer:node(titlecntnr)
	end
	for i, row in ipairs( args ) do contents = contents .. row end 
 
	local cntnr = mw.html.create('div')
	:addClass('mainpage-row')
	:css('align-content','space-around'):css('justify-content','space-around')
	:css('flex-wrap','wrap')
	:wikitext( contents )
	if not HF.isempty( args['float'] ) then cntnr:css( 'float', args['float'] ) end
	if not HF.isempty( args['width'] ) then cntnr:css( 'width', args['width'] ) end  
	fullcontainer:node(cntnr)
	return tostring(fullcontainer)
end
 
return Thumbnail

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.