Spoiler Macro
This is a Velocity macro, which isn't bundled with any XWiki product by default.
Macro contributed by Thomas Eveilleau.
This macro cannot currently be downloaded separately.
Macro contributed by Thomas Eveilleau.
This macro cannot currently be downloaded separately.
Spoiler Macro
Allow you to add hidden elements in the content of a pageUsage
#spoilerInit() ## Allow you to add as many #spoiler() as you want on a page
#spoiler("Link text" "Hidden content")Parameters definition
For #spoilerInit()
For #spoiler()
| Name | Optional | Allowed values | Default value | Description |
|---|---|---|---|---|
| Link text | no | string / image | none | Text on which users will click to display the hidden part |
| Hidden content | no | string / image | none | Hidden content |
Example
#spoilerInit()
#spoiler("Show me the truth" "At the end of the last episode of Lost season 3, Jack is attacked by 3 bears coming from Jupiter !")Result
Installation
This a Velocity macro. Since it's not bundled by default you'll have to copy/paste the following code to use it:#macro(spoilerInit)
#set ($i = 0)
<script>
function visibilite(thingId)
{
var targetElement;
targetElement = document.getElementById(thingId) ;
if (targetElement.style.display == "none")
{
targetElement.style.display = "" ;
} else {
targetElement.style.display = "none" ;
}
}
</script>
#end
#macro(spoiler $linktext $hiddentext)
<a href="javascript:visibilite('spoiler_$i');">$linktext</a>
<div id="spoiler_$i" style="display:none;border:1px solid grey;background-color:#FEFF9F;padding:5px;font-style:italic;">$hiddentext</div>
#set ($i = $i + 1)
#end