« Module:Fix » : différence entre les versions
Contenu supprimé Contenu ajouté
supporte aussi d'éventuelles tabs dans la (ou les) ligne vide |
test avec affichage généré par le module, pour gérer correctement les . et les " dans le paramètre infobulle |
||
Ligne 3 : | Ligne 3 : | ||
function p.necessiteCadre(frame) |
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] ) |
|||
: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 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 |
end |
||
Version du 29 avril 2018 à 06:31
[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.
La documentation de ce module est générée par le modèle {{Documentation module}}.
Elle est incluse depuis sa sous-page de documentation. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (modifier).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
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] )
: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 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