Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Lightbox is a Fluid component designed to provide the ability to re-order images within a collection. Let's suppose you have some simple markup displaying a small collection of images. To use the Lightbox, your image thumbnails must each be within a <div> element, and the collection of thumbnails must be contained within an element. A simple example of this could be:

Code Block
typehtml
html
<html>
  <head>
    <title>Image Collection</title>
  </head>

  <body>

    <div>
      <div><img src="img1.jpg"/></div>
      <div><img src="img2.jpg"/></div>
      <div><img src="img3.jpg"/></div>
    </div>

  </body>
</html>

...

The first step is to include the Fluid component library code in your file. Do this by adding a script tag to the header referencing the Fluid-all.js javascript file:

Code Block
typehtml
html
<head>
  <title>Image Collection</title>
  <script type="text/javascript" src="Fluid-all.js"></script>
</head>

...

First, add an ID to the element that contains all of the image thumbnails. This ID can be anything unique. For this example, we'll use "image-collection":

Code Block
typehtml
html
<div id="image-collection">
  ...
</div>

Next, we need to add a unique ID to each of the thumbnail <div> s. This ID must be of a specific form: it must start with the string that was used for the container ID, followed by "lightbox-cell:", a number indicating the index, and finally a ":". This is shown below for our example:

Code Block
typehtml
html
<div id="image-collection">
  <div id="image-collectionlightbox-cell:1:"><img src="img1.jpg"/></div>
  <div id="image-collectionlightbox-cell:2:"><img src="img2.jpg"/></div>
  <div id="image-collectionlightbox-cell:3:"><img src="img3.jpg"/></div>
</div>

...

The third step is to actually create the Lighbox by calling the initialization script. This initialization function has the form

Code Block
typejavascript
javascript
fluid.lightbox.createLightboxFromId (containerId, options);

The Lightbox initialization function allows you to pass in a number of optional parameters to configure some aspects of the Lightbox, including a 'callback' function. The callback communicates changes in the ordering of images back to the server. In its "out-of-the-box" form, the Lightbox includes a default callback function that uses a form with hidden <input> elements in the markup to record the indexes of the elements. For our example, we will disable the default callback by specifying an empty function as one of the optional parameters:

Code Block
typehtml
html
<script type="text/javascript">
  fluid.lightbox.createLightboxFromIds ("image-collection", { orderChangedCallback : function(){} });
</script>

Step 4: Define styles

...

The first style is the default style to be applied to any image thumbnail.

css
Code Block
type
.orderable-default{
    background-color: #eee;
    float: left;
}
type
Code Block
css
.orderable-hover{
    background-color: lightyellow;
    cursor: move;
    float: left;
}
Code Block
typecss
.orderable-selected{
    background-color: #ddd;
    float: left;
}
css
Code Block
type
.orderable-dragging {
    background-color: lightyellow;
    float: left;
}
type
Code Block
css
.orderable-avatar {
    opacity: 0.55;
    width: 300px;
    border: 0;
}
css
Code Block
type
.orderable-drop-marker{
    height: 10px !important;
    width: 4px;
    background-color: red;
    float: left;
}