VIVO Tools
In VIVO 1.1, there are 8 tools. Many of these tools are vivo wrappers to widgets/effects in script.aculo.us or prototype.
- vivo:autocomplete
- vivo:batchlink
- vivo:collapsible
- vivo:draggable
- vivo:droppable
- vivo:inpagetooltip
- vivo:inplaceeditor
- vivo:tab
vivo:autocomplete
This tool provides Google Suggest-like behavior on a text field.
| Parameter |
Default |
Description |
|
resultsElement |
null |
The id of the element containing the search results. Usually a blank <div> |
|
url |
null |
The url to query for autocomplete results. The content returned from this query is placed in resultsElement. This should return an <li> for each autocompletion option. |
|
paramName |
id of element |
The name of the parameter submitted to the url. The value of the parameter is the value of the autocomplete text field. |
| tokens | [] |
See Autocompleter.Base |
| frequency | 0.4 | How frequently the search should take place. |
| minChars | 1 | The minimum number of characters to input before the list is generated. |
| afterUpdateElement | null | Hook for the function called after the element has been updated (i.e. when the user has selected an entry). The function receives two parameters, the autocompletion input field and the selected item (the <li> item selected) |
Example:
<input name="search" id="search" type="text" vivo:autocomplete="resultsElement=results|url=suggest.jsp|paramName=q" /> <div id="results" />
Notes:
The result of the url query is the contents of a <ul> (e.g. a list of <li>'s). The contents of each <li> can be arbitrary html. The afterUpdateElement callback can be used to take specific data from the selected item and palce it somewhere (e.g. a hidden field) where it can later be submitted.
A good example of this is an autocomplete form to lookup person information. Start typing the person's name, and the autocompletion shows matching names with photos. In this case, afterUpdateElement should be used to pull the name of the person and place it in the text field.
vivo:batchlink
This tool is used to navigate between pages of data (e.g. search results, photo galleries, etc) without reloading the entire document. The batchlink tools typically reside within the panel that is refreshed.
| Parameter |
Default |
Description |
| contentElement | null |
The element containing the batch results. |
|
url |
null |
The url to the next batch of results. The tool falls back to the tool elements 'href' attribute, if it exists. (i.e. the tool element is an <a>) |
| afterComplete | null |
Callback function which is called after the new batch is inserted into the DOM. |
Example:
<div id="batch-container">
<a href="http://altepeter.net/nextbatch/fulldocument"
vivo:batchlink="ontentElement=gallery-images|url=url_to_next_batch_container"
Notes:
The contentElement element is replaced by the new content. This is different from many other vivo tools, that only replace the contents of the contentElement (i.e.. target element).
The batchlink tool can be an html anchor. If desired, the anchors 'href' can link to the full page for the next set of results, and the url parameter can return just the content of the next batch. If implemented in this fashion, this tool will continue to work in browsers with javascript disabled. Cerainly a useful feature for a photo gallery.
The afterComplete callback can be used if extra non-vivo initialization is needed within the new batch content. For example, the 'Silva UCL Gallery' uses lightbox, which has it's own initialization that needs to be called on the new content.
vivo:collapsible
| Parameter |
Default |
Description |
|
collapsibleElement |
null |
The target element that is collapsed when the collapsible tool element is clicked. |
|
action |
click |
The mouse action that causes the the element to expand or collapse. |
|
initialState |
open |
The initial state of the element (open or close). |
|
callback |
function() {
if (self.collapsibleElement.style.display == "none") {
self.collapsibleElement.style.display = "block";
}
else {
self.collapsibleElement.style.display = "none";
}
}
|
Callback function. Function to be called after the action occurs. |
vivo:draggable
A script.aculo.us component. See Drag And Drop: Draggables, Droppables, Sortables for more information.
| Parameter |
Default |
Description |
|
handle |
none |
Sets whether the element should only be draggable by an embedded handle. The value must be an element reference or element id or it may be a string referencing a CSS class value. The first child/grandchild/etc. element found within the element that has this CSS class value will be used as the handle. |
|
revert |
false |
If set to true, the element returns to its original position when the drags ends. Or it can also be an arbitrary function reference, called when the drag ends. |
|
snap |
false |
If set to false no snapping occurs. Otherwise takes the forms – xy or [x,y] or function(x,y){ return [x,y] }. |
|
zindex |
1000 |
The css zindex of the draggable item. |
|
constraint |
none |
If set to "horizontal" or "vertical" the drag will be constrained to take place only horizontally or vertically. |
|
change |
none |
Callback Function. Called whenever the Draggable is moved by dragging. The called function gets the Draggable instance as its parameter. |
vivo:droppable
A script.aculo.us component. See Drag And Drop: Draggables, Droppables, Sortables for more information.
| Parameter |
Default |
Description |
|
action |
none |
Set accept to a string or an array of strings describing CSS classes. The Droppable will only accept Draggables that have one or more of these CSS classes. |
| containment |
none |
The droppable will only accept the Draggable if the Draggable is contained in the given elements (or element ids). Can be a single element or an array of elements. This option is used by Sortables to control Drag-and-Drop between Sortables. |
|
overlap |
none |
If set to "horizontal" or "vertical" the droppable will only react to a Draggable if its overlapping by more than 50% in the given direction. Used by Sortables. |
|
greedy |
true |
If true stops processing hovering (don’t look for other Droppables that are under the Draggable) |
|
onHover |
none |
Callback Function. Called whenever a Draggable is moved over the Droppable and the Droppable is affected (would accept it). The callback gets three parameters: the Draggable, the Droppable element, and the percentage of overlapping as defined by the overlap option. Used by Sortables. |
|
onDrop |
none |
Callback Function. Called whenever a Draggable is released over the Droppable and the Droppable is accepts it. The callback gets two parameters: the Draggable element, and the Droppable element. |
vivo:inpagetooltip
Tooltips in html are usually displayed on mouseover of elements with the title attribute set. These tooltips are restricted to text only. Instead of using the title attribute, this tool creates a tooltip out of an arbitrary DOM element (e.g. a <div>), so the tooltip can contain arbitrary html and be fully styled using css.
| Parameter |
Default |
Description |
|
tooltipElement |
null |
ID of the element containing the tooltip |
|
displayType |
click |
When to display the tooltip. Currently only on click is supported, but on hover is the other planned option. |
| offsetX |
5 |
Number of pixels to offset on X axis centered on mouse. |
| offsetY |
5 |
Number of pixels to offset on Y axis centered on mouse. |
|
alignX |
left |
Align tooltip box with left or right edge centered on mouse. |
|
alignY |
top |
Align tooltip box with top or bottom edge centered on mouse. |
Example:
<a id="tooltip-link" href="#" onclick="return false" vivo:inpagetooltip="tooltipElement=tooltip-text|alignX=right">Click for more info</a> <div id="tooltip-text">More information</div>
Notes:
A neat extension to this tool could be loading the tooltips on the fly, instead of containing them in the document.
vivo:inplaceeditor
A wrapper around Ajax.InPlaceEditor.
|
Parameter |
Default |
Description |
|
okText |
"ok" |
The text of the submit button that submits the changed value to the server. |
| cancelText |
"cancel" |
The text of the link that cancels editing. |
|
savingText |
"Saving" |
The text shown while the text is sent to the server. |
|
formId |
id of element to edit + "InPlaceForm" |
The id given to the <form> element. |
| externalControl |
null |
ID of an element that acts as an external control used to enter edit mode. The external control will be hidden when entering edit mode and shown again when leaving edit mode. |
| rows |
1 |
The row height of the input field (anything greater than 1 uses a multiline textarea for input). |
|
cols |
none |
The number of columns the text area should span (works for both single line or multi line). |
|
size |
none |
Synonym for "cols" when using single-line (rows=1) input. |
|
highlightcolor |
Ajax.InPlaceEditor.defaultHighlightColor |
The highlight color |
|
highlightendcolor |
#FFFFFF"" |
The color which the highlight fades to. |
|
saving<Class Name> |
"inplaceeditor-saving" |
CSS class added to the element while displaying "Saving" (removed when server responds). |
|
form<Class Name> |
"inplaceeditor-form" |
CSS class used for the in place edit form. |
|
loadTextURL |
null |
Will cause the text to be loaded from the server (useful if your text is actually textile and formatted on the server). |
|
loadingText |
"Loading:" |
If the loadTextURL option is specified then this text is displayed while the text is being loaded from the server. |
|
callback |
function(form) {Form.serialize(form)} |
A function that will get executed just before the request is sent to the server. It should return the parameters to be sent in the URL. Will get two parameters, the entire form and the value of the text control. |
|
ajaxOptions |
{} |
Options specified to all AJAX calls (loading and saving text), these options are passed through to the prototype AJAX classes. |
vivo:tab
This tool provides for the creation of a panel containing a list of tab titles, and a content panel containing the contents of the active tab. The tab contents are loaded from a url.
| Parameter |
Default |
Description |
|
contentElement |
null |
The container of the tab contents. Shared between all tabs in a panel. |
|
tabGroupElement |
null |
The element containing all tabs in a group. |
|
url |
null |
The url to retrieve the contents of the tab. |
| action |
click |
The mouse action that causes the the element to expand or collapse. |
|
initialState |
close |
The initial state of the element (open or close). |
|
reload |
yes |
Determines if the content associated with the tab should be reloaded everytime that tab is clicked or if it should cache it and display the previous state. Values are yes and no. |
|
loadingText |
loading... |
The text that displays when the tab's content is loading. |
|
onComplete |
function(content) {
if ($("vivo-loading-tab") != null) {
self.contentElement.removeChild($("vivo-loading-tab"));
}
if (content != null && content.length > 0) {
self.fragment.innerHTML = content;
}
self.fragment.style.display = "block";
var tabs = self.tabGroupElement.getElementsByTagName("li");
for (var i = 0; i < tabs.length; i++) {
if (tabs[i].nodeType == 1 && tabs[i].className.length > 0) {
tabs[i].className = "";
}
}
self.element.className = "active";
}
|
Callback function. Function to call when the tab's content is finished loading. The only thing you may want to change here is what class it turns on and off to make the tabs active or not active. By default the class is "active". |
|
onLoading |
function() {
var loadingDiv = document.createElement("div");
loadingDiv.id = "vivo-loading-tab";
loadingDiv.innerHTML = self.options.loadingText;
self.contentElement.appendChild(loadingDiv);
}
|
Callback function. Function is called when the tab's content is being loaded. By default it displays the loadingText. |