« Module:Fix » : différence entre les versions

Une page de Wikipédia, l'encyclopédie libre.
Contenu supprimé Contenu ajouté
Zebulon84 (discuter | contributions)
test avec affichage généré par le module, pour gérer correctement les . et les " dans le paramètre infobulle
Zebulon84 (discuter | contributions)
retouche de la modification précédente
Ligne 27 : Ligne 27 :
:css{ background = background }
:css{ background = background }
:attr{ title = args.titre }
:attr{ title = args.titre }
:wikitext( args[1] )
:wikitext( args[1], '\n' )
:done()
:done()
:tag( 'div' )
:tag( 'div' )
Ligne 34 : Ligne 34 :
:css{ background = background }
:css{ background = background }
:wikitext( args.message )
:wikitext( args.message )
:alldone()
:allDone()
return tostring( html )
return tostring( html )
Ligne 55 : Ligne 55 :
:cssText ( 'padding-left:2px;' )
:cssText ( 'padding-left:2px;' )
:wikitext( args.message )
:wikitext( args.message )
:alldone()
:allDone()
return tostring( html )
return tostring( html )
end
end


function affichageFix( frame )
function p.affichageFix( frame )
local args = frame.getParent and frame:getParent().args or frame
local args = frame.getParent and frame:getParent().args or frame

Version du 29 avril 2018 à 06:42

 Documentation[voir] [modifier] [historique] [purger]

Module utilisé par le métamodèle {{Fix}}, et indirectement par le modèle {{Référence nécessaire}} et dérivés.

local p = {}

function p.necessiteCadre(frame)

	local source = frame.args[1]

	if source:match('\n[ \t]*\n') or source:match('\n[*#:]') then
		return '1'
	else
		return ''
	end
end

function p.affichageBloc( args )
	local background = args.background or ''
	if background == '' then
		background = 'white'
	end
	
	local html = mw.html.create( '' )
		:wikitext( '\n' )
		:tag( 'div' )
			:cssText( 'position:relative; margin-top:0.8em;')
			:tag( 'div' )
				:addClass( 'need_ref' )
				:cssText( 'cursor:help; overflow:hidden; padding-bottom:0;' )
				:css{ background = background }
				:attr{ title = args.titre }
				:wikitext( args[1], '\n' )
				:done()
			:tag( 'div' )
				:addClass( 'need_ref_tag' )
				:cssText( 'position:absolute; top:-0.6em; left:1em; padding:0 0.5em; font-size:80%; line-height:1em;')
				:css{ background = background }
				:wikitext( args.message )
		:allDone()
		
	return tostring( html )
end

function p.affichageInline( args )
	local html = mw.html.create( '' )
	
	if args[1] and args[1] ~= '' then
		html:tag( 'span' )
				:addClass( 'need_ref' )
				:cssText( 'cursor:help;' )
				:attr{ title = args.titre }
				:wikitext( args[1] )
				:done()
	end
	
	html:tag( 'sup' )
			:addClass( 'need_ref_tag' )
			:cssText ( 'padding-left:2px;' )
			:wikitext( args.message )
		:allDone()
		
	return tostring( html )
end

function p.affichageFix( frame )
	local args = frame.getParent and frame:getParent().args or frame
	
	if args[1] and args[1] ~= '' then
		
		local messageDate = ''
		if args.date and args.date ~= '' then
			messageDate = ' (demandé le ' .. args.date .. ')'
		end
		
		args.titre = ( args.infobulle or '' )
			:gsub( '.$', '' )
			:gsub( '"', '"' )
			.. messageDate
			.. '.'
		
		if args[1]:match('\n[ \t]*\n')
			or args[1]:match('\n[*#:]')
			or args.bloc and args.bloc ~= ''
		then
			return p.affichageBloc( args )
		end
	end
	
	return p.affichageInline( args )
end

return p