## ## Check for a blank first parameter ## #if($param0 && $param0.length()>0) #set($expandtitle=$param0) #else #set($expandtitle="Click here to expand...") #end #if ($req.getAttribute('lastToggleId')) #set($toggleId = $req.getAttribute('lastToggleId') +1) #else #set($toggleId = 0) #end $!req.setAttribute('lastToggleId', $toggleId) ## ## Construct a confluence-page-friendly anchor name ## For confluence anchors ## 1) anchor name is preceeded by page name and a hyphen ## 2) spaces, + and - are removed from both page and anchor names ## 3) Non-alpha numeric characters are removed (note, . @ and ? are also allowed in anchors but are unusual excpetions) ## 4) string is made (i.e. translate space to + and ? to %3F) ## #set($linkname=$webwork.urlEncode($content.getRealTitle().replaceAll("[+ -]","").concat("-").concat($expandtitle.replaceAll("[+ -]","").replaceAll("[^a-zA-Z0-9.@?]","")))) ## ## ## Show html output for DHTML action. Note: using lots of these in a page creates many redundant script tags and javascript functions ## <script> function ExpandMacroToggleAnswer(id) { var answer = document.getElementById("answer-" + id); var icon = document.getElementById("icon-" + id); ExpandMacroToggle(answer); if (answer.style.display == 'none') { icon.src="${bootstrap.webAppContextPath}/images/icons/arrow_closed_active_16.gif"; } else { icon.src="${bootstrap.webAppContextPath}/images/icons/arrow_open_active_16.gif"; } } function ExpandMacroToggle(el) { if ( el.style.display != 'none' ) { el.style.display = 'none'; } else { el.style.display = ''; } } // preload open image (variable not used elsewhere) openIcon = new Image(); openIcon.src = "${bootstrap.webAppContextPath}/images/icons/arrow_open_active_16.gif"; </script> ## ## Show anchor ## <a name="$linkname"/> ## ## Show title ## <div style="cursor: pointer" onclick="ExpandMacroToggleAnswer('$toggleId')"><img id="icon-$toggleId" src="${bootstrap.webAppContextPath}/images/icons/arrow_closed_active_16.gif" style="vertical-align: middle"> <expand-title style="vertical-align: middle">$generalUtil.htmlEncode($expandtitle)</expand-title></div> ## ## Show content ## <div id="answer-$toggleId" class="toggle-answer" style="display: none">$!body</div>

Comments (1)
Sep 12, 2007
James Mortimer says:
See Expand Text User Macro for documentation