Member:
Markus ⋅
Date: February 13, 2010, 03:02 AM
⋅ Subject: "Re: Feature Request - Collapsible boxes."
And to complete things, an explanation of what's happening above.
Unit Parameters: Every parameter entered for an unit is available for the unit templates as a tag, and can also be evaluated with the templating script. (More on Unit parameters). In this case, we have a new parameter called "display" which is available under the [[DISPLAY]] tag.
Conditional Expressions: Here you see two of the basic conditional expressions of Wiccle Templating Script in action. They simply check whether a variable with that name is defined and populated ("not_empty") or undefined/zero-length ("empty"). If "display" parameter is empty, the regular unit code is displayed. If it's in use, the alternative collapse-code will be displayed.
JavaScript Functions: The bundled writeInner() function is a shortcut for inserting text or HTML code to any HTML container (such as span or div) containing an ID. The syntax is writeInner('element_id', 'Your content');.
The other two common javascript functions used are showHide() and openClose(). showHide shows a div if it's hidden, and hides if it's visible. (Also: justShow / justHide, which go only one way.) You could, for example, add an id="" tag for the snippet containing the "click to view more" text, and add a justHide() to the click actions to hide it when clicked (instead of changing to "less"). openClose just controls the open/collapse graphic. There's lots more useful and usable you will find skimming through the /javascripts folder for templates for mini-mods like this.
Unit Identifier Use: Since each unit that's opened or collapsed requires a unique identifier to be individually available for the javascript, we are using the [[UNIT_ID]] tag, which corresponds to the unit's unique database number, and will be different for each unit. This is a tag that comes in handy for many purposes.
In general, things like this are easy enough to produce. This one is now a feature in the next release. Don't be shy with requests if you have more ideas like this!