This macro isn't bundled with any XWiki product by default.
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 page

Usage

#spoilerInit()  ## Allow you to add as many #spoiler() as you want on a page

#spoiler("Link text" "Hidden content")

Parameters definition

For #spoilerInit()

Warning: No parameters

For #spoiler()

NameOptionalAllowed valuesDefault valueDescription
Link textnostring / imagenoneText on which users will click to display the hidden part
Hidden contentnostring / imagenoneHidden 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

lostspoiler.png

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

Version 10.1 last modified by VincentMassol on 19/06/2008 at 22:13

Comments 0

No comments for this document

Attachments 1

Image
lostspoiler.png 1.2
PostedBy: ThomasEveilleau on 06/05/2008 (12kb )

Creator: ThomasEveilleau on 2008/05/06 18:32
This wiki is licensed under a Creative Commons license
1.4.1.10194