For faster navigation, this Iframe is preloading the Wikiwand page for Mòdul:Side box.

Mòdul:Side box

Icona de documentació de mòdul Documentació del mòdul [ mostra ] [ modifica el codi ] [ mostra l'historial ] [ refresca ]

Mòdul Side box (codi · ús · discussió · proves · tests · casos prova | subpàgines · enllaços)

A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]


Implementa ((Caixa lateral)). Per a proves podeu utilitzar Mòdul:Side box/proves.

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

local function makeData(args)
	local data = {}

	-- Main table classes
	data.classes = {}
	if yesno(args.metadata) ~= false then
		table.insert(data.classes, 'metadata')
	end
	if args.position and args.position:lower() == 'left' then
		table.insert(data.classes, 'side-box-left')
	elseif args.position and args.position:lower() == 'center' then
		table.insert(data.classes, 'side-box-center')
	else
		table.insert(data.classes, 'side-box-right')
	end
	
	if args.collapsible then
		table.insert(data.classes, 'mw-collapsible')
		if args.collapsible == "collapsed" then
			table.insert(data.classes, 'mw-collapsed')
		end
		data.collapsible = true
	end

	table.insert(data.classes, args.class)
	
	-- Image
	if args.image and args.image ~= 'none' then
		data.image = args.image
	end

	-- Copy over data that does not need adjusting
	local argsToCopy = {
		-- aria qualities
		'role',
		'labelledby',
		
		-- Classes
		'textclass',
		

		-- Styles
		'style',
		'textstyle',
		'templatestyles',

		-- Above row
		'above',
		'abovestyle',

		-- Body row
		'text',
		'imageright',

		-- Below row
		'below',
	}
	for i, key in ipairs(argsToCopy) do
		data[key] = args[key]
	end

	return data
end

local function renderSidebox(data)
	-- Renders the sidebox HTML.

	-- Table root
	local root = mw.html.create('div')
	root:attr('role', data.role)
		:attr('aria-labelledby', data.labelledby)
		:addClass('side-box')
	for i, class in ipairs(data.classes or {}) do
		root:addClass(class)
	end
	if data.style then
		root:cssText(data.style)
	end

	-- The "above" row
	if data.above then
		local above = root:newline():tag('div')
		above:addClass('side-box-abovebelow')
			:newline()
			:wikitext(data.above)
		if data.textstyle then
			above:cssText(data.textstyle)
		end
		if data.abovestyle then
			above:cssText(data.abovestyle)
		end
	end

	-- The body row
	local body = root:newline():tag('div')
		body:addClass('side-box-flex')
			:addClass(data.collapsible and 'mw-collapsible-content')
			:newline()
	if data.image then
		body:tag('div')
			:addClass('side-box-image')
			:wikitext(data.image)
	end
	local text = body:newline():tag('div')
	text:addClass('side-box-text')
		:addClass(data.textclass or 'plainlist')
	if data.textstyle then
		text:cssText(data.textstyle)
	end
	text:wikitext(data.text)
	if data.imageright then
		body:newline():tag('div')
			:addClass('side-box-imageright')
			:wikitext(data.imageright)
	end

	-- The below row
	if data.below then
		local below = root:newline():tag('div')
		below
			:addClass('side-box-abovebelow')
			:wikitext(data.below)
		if data.textstyle then
			below:cssText(data.textstyle)
		end
	end

	root:newline()
	local frame = mw.getCurrentFrame()
	local templatestyles = ''
	if data.templatestyles then
		templatestyles = frame:extensionTag{
			name = 'templatestyles', args = { src = data.templatestyles }
		}
	end
	return frame:extensionTag{
		name = 'templatestyles', args = { src = 'Module:Side box/styles.css' }
	} .. templatestyles .. tostring(root)
end

function p._main(args)
	local data = makeData(args)
	return renderSidebox(data)
end

function p.main(frame)
	local origArgs = frame:getParent().args
	local args_ca = {["imatge"]="image", ["imatge_dreta"]="imageright", ["posició"]="position", ["estil"]="style",
		["estil_de_text"]="textstyle", ["dalt"]="above", ["estil_de_dalt"]="abovestyle", ["sota"]="below"}
	local position_ca = {["esquerra"]="left", ["centre"]="center"}
	local args = {}
	for k, v in pairs(origArgs) do
		v = v:match('%s*(.-)%s*$')
		if v ~= '' then
			args[args_ca[k] or k] = position_ca[v] or v
		end
	end
	return p._main(args)
end

return p
{{bottomLinkPreText}} {{bottomLinkText}}
Mòdul:Side box
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?