Module:Collapse list
Utilisation
Affiche une version réduite d'une liste d'items et permet de la ventiler.
Exemples
- a, b, c, ... [+]
- Anémie, Méléna, Nausée, Ictère (signe clinique), Dysphagie (symptôme), ... [+]
Paramètres
Affiche une version réduite d'une liste d'items et permet de la ventiler.
Paramètre | Description | Type | État | |
---|---|---|---|---|
Liste | 1 | aucune description | Chaîne | obligatoire |
Compte | 2 | Après combien d'items est-ce qu'il faut stopper la liste.
| Nombre | facultatif |
séparateur | 3 | La chaîne qui sépare les éléments de la liste.
| Chaîne | facultatif |
-- For debugging: =p.collapse(mw.getCurrentFrame():newChild{title="Module:Collapse",args={"a, b, c, d, e, f", 3}})
local p = {}
function p.collapse( frame )
list = frame.args[1]
count = 10
if frame.args[2] then count = tonumber(frame.args[2]) end
separator = ','
if frame.args[3] then separator = frame.args[3] end
list = mw.text.split(list, separator);
output = ''
for i = 1, #list do
if i == count + 1 then
output = output .. ' ... <span class="collapsible-list" style="display:none;">'
end
output = output .. list[i]
-- if this is not the last element, add a separator
if i ~= #list then output = output .. separator end
end
-- If the list was concatenated, close the span
if # list > count then
output = output .. '</span><span class="collapsible-list-toggle" style="cursor: pointer">[+]</span>'
end
-- The JS code to make the list collapsible is in MediaWiki:Common.js and MediaWiki:Mobile.css.
return output
end
return p