/
Lightbox API - v0.4

Documentation for a historical release of Infusion: 1.3
Please view the Infusion Documentation site for the latest documentation.
If you're looking for Fluid Project coordination, design, communication, etc, try the Fluid Project Wiki.

Lightbox API - v0.4

This documentation refers to the v0.4 released version of the Lightbox code. For documentation specific to the trunk, please see Lightbox API - v0.4.

Initializing the Lightbox

The Lightbox initialization function must be called in a <script> block at the end of the markup (after the container element has been parsed). The available functions are:

createLightboxFromId (containerId, options);
createLightbox (container, itemFinderFn, options);

Parameters

containerId

The containerId is the ID of the root node of the lightbox, and the prefix of the IDs of the orderable elements within the Lightbox.

container

The container parameter is the root node of the Lightbox.

itemFinderFn

The itemFinderFn is a function that returns all of the movable thumbnail elements in the Lightbox.

options

The options parameter is an optional collection of name-value pairs that configure the Lightbox:

Name

Description

Values

Default

orderChangedCallback

A function to be called each time the order of items has changed, to communicate the new order to the server.

 

A function (created by invoking fluid.defaultOrderchangedCallback(container)) that uses a form with hidden <input> elements to track order changes.

keysets

an object containing sets of keycodes to use for directional navigation, and for the modifier key used for moving a movable item.

The object must be a list of objects containing the following keys:
modifier : a function that returns true or false, indicating whether or not the required modifier(s) are activated
up
down
right
left

fluid.defaultKeysets = [{
    modifier : function (evt) {
        return evt.ctrlKey;
    },
    up : fluid.keys.UP,
    down : fluid.keys.DOWN,
    right : fluid.keys.RIGHT,
    left : fluid.keys.LEFT
},
{
    modifier : function (evt) {
        return evt.ctrlKey;
    },
    up : fluid.keys.i,
    down : fluid.keys.m,
    right : fluid.keys.k,
    left : fluid.keys.j
}];

cssClassNames

an object containing class names for styling the Reorderer. See below for a discussion of CSS styling of the Reorderer

The object must contain the following keys:
defaultStyle This class is applied to orderable elements in their default state.
selected This class is applied to the orderable element that has been selected. The selected orderable item can be moved using keystrokes.
dragging This class is applied to the orderable element that is currently being moved.
hover This class is applied to orderable elements when the mouse hovers over them.
dropMarker This class is applied to the drop target indicator when the mouse is used to drag an item.
avatar This class is applied to the avatar, the image of the orderable element as it is being dragged about by the mouse.

var defaultCssClassNames = {
    defaultStyle: "orderable-default",
    selected: "orderable-selected",
    dragging: "orderable-dragging",
    hover: "orderable-hover",
    dropMarker: "orderable-drop-marker",
    avatar: "orderable-avatar"
};

avatarCreator

a function that returns a valid DOM node to be used as the dragging avatar

 

The item being dragged will be cloned

instructionMessageId

The id of the DOM element containing instructional text for Lightbox users

 

"message-bundle:"


Customizing the Lightbox

The Lightbox is a container of thumbnail images. The Fluid library includes an HTML template file, but if you wish to create your own template, the container and the thumbnail images must be configured as follows:

Configuring the Lightbox Container

  • The orderable image thumbnails must be contained within a containing <div> element with a known "id" attribute. This ID is passed to the Lightbox upon instantiation.
  • To use the default order-changed callback, the container element must be contained within a <form> element. The form will be submitted to the server to communicate changes in the thumbnails' order.

Configuring the Thumbnails

  • Thumbnails must be <div> elements.
  • Thumbnail <div> elements must be marked with an ID that is of the form:
       containerId + "lightbox-cell:" + index + ":"
    where
       containerId is the ID of the container of the orderables, i.e. the root node of the Lightbox,
       index is any number of digits, indicating the current index of the orderable item.
  • To use the default order-changed callback, each orderable element must have a hidden <input> element associated with it, used to communicate changes to the thumbnails' order back to the server. The input element must have
    • a name
    • a value that is the index
    • an ID of the form:   containerId + "lightbox-cell:" + index + ":reorder-index"

Styling the Lightbox

The Lightbox includes CSS styles that it applies to the thumbnails. The application of styles is based on known class names. The class names are:

   orderable-default - This class is applied to thumbnail <div> elements in their default state.
   orderable-selected - This class is applied to the thumbnail that has been selected. The selected thumbnail item can be moved using keystrokes.
   orderable-hover - This class is applied to thumbnails when the mouse hovers over them.
   orderable-dragging - This class is applied to the thumbnail that is currently being moved.
   orderable-avatar - This class is applied to the avatar, the image of the thumbnail as it is being dragged about by the mouse.
   orderable-drop-marker - This class is applied to the drop target indicator when the mouse is used to drag a thumbnail.


Dependencies

The Lightbox dependencies can be met by including the minified Fluid-all.js file in the header of the HTML file:

<script type="text/javascript" src="Fluid-all.js"></script>

Alternatively, the individual file requirements are:

<script type="text/javascript" src="jquery/jquery-1.2.6.js"></script>
<script type="text/javascript" src="jquery/jARIA.js"></script>
<script type="text/javascript" src="jquery/jquery.keyboard-a11y.js"></script>
<script type="text/javascript" src="jquery/ui.core.js"></script>
<script type="text/javascript" src="jquery/ui.draggable.js"></script>
<script type="text/javascript" src="jquery/ui.droppable.js"></script>
<script type="text/javascript" src="fluid/Fluid.js"></script>
<script type="text/javascript" src="fluid/Reorderer.js"></script>
<script type="text/javascript" src="fluid/Lightbox.js"></script>