cogAllows you to add hidden elements in the content of a page
TypeDoc (Velocity Macro)
Developed by

xwiki:XWiki.ThomasEveilleau

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

This macro has been replaced by the Spoiler Macro (Wiki Macro).

Usage

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

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

Parameters definition

For #spoilerInit()

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

Prerequisites & Installation Instructions

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
Tags:
Created by ThomasEveilleau on 2008/05/06 18:32
    

Get Connected