Module:Collapse list
Utilisation
Affiche une version réduite d'une liste d'items et permet de la ventiler.
Exemples
- a, b, c, ... [+]</htm> <html>
- Anémie, Méléna, Nausée, Ictère (signe clinique), Dysphagie (symptôme), ... <html>[+]</htm>
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="collapsed-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><html><span class="colasped-list-toggle" style="cursor: hand" onclick="if($(this).html() == \'[+]\') { $(this).html(\'[-]\').previous().fadeIn(); } else { $(this).html(\'[+]\').previous().fadeOut(); }">[+]</span></htm>'
end
return output
end
return p