Floatbox v4.18 - Instructions

randomous.com

Index

Quick-start

Floatbox is simple to install and use, even though it may appear at first glance to be complex due to its numerous options and capabilities. The following three steps are all you need to get floatbox content lit up on your pages.

  1. Install - Open the downloaded zip file and drag or copy the entire floatbox folder from that zip file to the root folder of your site, or push the whole floatbox folder and its contents up to your hosted site.
  2. Include - Add the following three lines to the <head> section of the pages where you want to use floatbox.
    <link type="text/css" rel="stylesheet" href="/floatbox/floatbox.css" />
    <script type="text/javascript" src="/floatbox/floatbox.js"></script>
    <script type="text/javascript" src="/floatbox/options.js"></script>
  3. Use - Create an anchor element with a class of "floatbox" and an href that points to your content. Something like:
    <a href="myPic.jpg" class="floatbox">click me</a>
  4. There is no step 4. You're done. But to get the most out of floatbox and use its more advanced features you really should read the rest of these instructions, the options reference, the programmer's API reference, the license terms, and also check out the demo page. These reference materials are in the docs folder of the downloaded zip file and also online on the randomous.com site. The online reference materials always pertain to the latest floatbox version.

Back to Index

Activating elements

Anchors (and area maps) on a page are marked to be opened in floatbox by having a class name of 'floatbox' assigned directly to them, or assigned to a containing element (usually a div). Both of the following have the same effect: <a href="pic1.jpg" class="floatbox">Foo</a>
<a href="pic2.jpg" class="floatbox">Bar</a>
...and... <div class="floatbox">
  <a href="pic1.jpg">Foo</a>
  <a href="pic2.jpg">Bar</a>
<div>

Assigning the floatbox class to each item is conceptually simpler, but if you have a number of items on a page to open in floatbox, it's probably cleaner and quicker to put the floatbox class on a containing div rather than on each item.

When using the containing div approach, there are two ways to limit which links in the containing will get activated. The first is to set the 'autoTypes' option on the containing div to the content types you want Floatbox to activate.
For example, <div class="floatbox" data-fb-options="autoTypes:image|flash"> will activate only links to images or flash files within the div. The second way is to limit which links get activated is to assign class="nofloatbox" to specific anchors you want to exclude from activation.

All the demo page examples place the floatbox class on each anchor because people seem to like pasting those examples into their own content. Since they each have their own classname assigned, the examples are functionally self-contained. If it were not for this copying, the demo page would be setup with the floatbox class placed only once on a containing div. However, the containing div approach is certainly not mandatory. It is perfectly functional to use the more traditional approach of marking each anchor with its own floatbox class.

Things to note:

In addition to the core floatbox display, the Floatbox library includes capabilities to show cycling image sets, enhanced tooltips, and popup thumbnails. These additional capabilities are also enabled by assigning class names to elements. Please see the relevant sections of these instructions for details on how to configure these capabilities.

Back to Index

Configuring options

Floatbox options are used to set appearance preferences, size the floatbox, group items into sets, assign captions, etc. There are 3 different ways to set configuration options for floatbox. In order of precedence, options can be set from:

  1. data-fb-options or rev attribute settings placed directly on an anchor (link), or inherited from a containing 'floatbox' classed element (see 'Activating elements' above). These apply only to the item(s) they are assigned to.
  2. fbPageOptions, fbChildOptions, fbTypeOptions & fbClassOptions javascript objects (associative arrays) defined on the host page. These settings apply to all floatboxed anchors on the page.
  3. globalOptions set in the floatbox/options.js file apply to floatboxed items across the entire site.

If you have a number of different floatboxed items on your site, it's a good idea to organize your option preferences based on the scope you want those options applied to. For example, a specific anchor pointing to html content may have a 'width' option set directly on it, while setting 'cornerRadius' for all image content would best be done in the typeOptions section of the globally applied floatbox/options.js file.

Details of the various option-setting methods follow. Don't overlook reading the options reference. You'll get the best understanding of the numerous other floatbox options from there. (Note that option names and values are case-sensitive.)

Back to Index

Setting options directly on anchors

Options for a particular anchor get set in that anchor's data-fb-options or rev attribute. The general syntax is:<a href="xyz" data-fb-options="option1:value1 option2:value2 etc."> Using the rev attribute is equivalent. ('data-fb-options' validates on html5 and 'rev' validates on earlier doctypes.) All the documentation samples and the demo page use the data-fb-options attribute, but there is no problem if you have a preference for placing options on the rev attribute instead. rev="option1:value1 option2:value2 etc."

When running a series of floatboxed items such as a gallery set or a slideshow, many of the options from the clicked anchor will apply globally to all items in the set. Some other options apply on a per item basis. It should usually be apparent from context which options are per item. For example, width and backgroundColor are per item whereas cornerRadius and color apply to the whole set.

There's lots of examples of options set on anchors over at the demo page. One example that some people find useful in its own right, and that should give a good sense of how options can be used, is the following anchor which will start a slideshow: <a href="" class="floatbox" data-fb-options="doSlideshow:true group:myShow showThis:false endTask:exit autoFitImages:true navType:none">Slideshow</a> Here we are telling floatbox to start a slideshow, to use the gallery set that is defined with the group string 'myShow', that the current anchor should not be part of that slideshow set, images should be scaled down to fit the screen, and no navigation controls should be shown in the floatbox.

The option string syntax is quite flexible. Name:value pairs can be separated by spaces, semi-colons, commas or ampersands. The delimiter between a name and its value can be a colon or an equals sign. Pixel values can be given with or without the 'px' suffix.
"color:red width:200", "color:red; width:200px;", "color:red, width:200" and "color=red&width=200" are all allowed and equivalent.

Back to Index

Setting page-specific options

The majority of floatbox's options are not item-specific and can be defined per page or globally rather than repeated on each anchor. Use fbPageOptions to assign option settings to all items on a page, fbChildOptions to assign settings to secondary floatboxes only, fbTypeOptions for settings to be applied to items of a particular type, and fbClassOptions for settings applied to all items on a page that have a particular class name assigned to them. Each of these sets of options are defined by a javascript object in a page's <head> section.

fbPageOptions
This example sets a shadow type, animation values and navigation type for all floatbox items on a single page:
<script type="text/javascript">
  fbPageOptions = {
    shadowType: 'halo',
    resizeDuration: 5.5,
    imageFadeDuration: 4.5,
    overlayFadeDuration: 0,
    navType: 'both'
  };
</script>
Note the syntax: there are commas after each name:value pair except for the last one.
The configurator (described below) can be used to assist in building fbPageOptions.

fbChildOptions can be defined on a page using the same structure and syntax as fbPageOptions but in this case the settings will apply only to secondary floatboxes and won't apply to the primary or first box opened.

Use fbTypeOptions and fbClassOptions to assign settings based on content type or class name. The syntax for these two is a bit different from that for fbPageOptions. Each type or class is assigned a string of name:value pairs in the same format used for an anchor's data-fb-options attribute.

For example, to assign settings to items with a class of 'redThings' and other settings to 'class49': <script type="text/javascript">
  fbClassOptions = {
    redThings: 'backgroundColor:#f7f765 width:444 height:333 scrolling:no',
    class49: 'cornerRadius:8 enableDragMove:true showItemNumber:false'
  };
</script>

And, to set options based on content type: <script type="text/javascript">
  fbTypeOptions = {
    iframe: 'modal:false showNewWindow:true',
    flash: 'width:480 height:385 enableDragResize:false'
  };
</script>

Valid content types are 'image', 'html', 'media', 'tooltip', any of the html sub-types 'iframe', 'inline', 'ajax' & 'direct', any of the media sub-types 'flash', 'quicktime', 'wmp', 'silverlight' & 'pdf', and 'tooltip' (which isn't really a content type).

When running floatbox in a hierarchy of iframed pages, these page-specific option objects need to be placed on the top (base) document. The settings will apply to content within iframes on the page provided those iframes are sourced from the same domain.

Back to Index

Setting site-wide options

Global option preferences apply to all pages on your site and are defined in the options.js file located directly in the floatbox install folder. In previous Floatbox versions, global options were set by editing the floatbox.js file. This has moved to options.js specifically so that the options settings can be easily imported into subsequent versions after performing a version upgrade.

There are four sections to the options.js file, corresponding to the four places you can place page-specific options as described above. The globalOptions section should be self-explanatory: settings here apply globally across your site. The childOptions section assigns settings only for secondary floatboxes. typeOptions assigns settings across the site, but only to items of the assigned floatbox type. See fbTypeOptions above for syntax and a list of available floatbox types. classOptions is similar to typeOptions but assigns settings site-wide to items with a matching class name.

The globalOptions section of options.js also holds the floatbox license key. (See the license key section of these instructions for details.) It is a straight-forward matter to edit options.js with any text editor. You can also use the configurator described below to assist in creating the globalOptions section of options.js.

Back to Index

Using the Configurator to setup global and page-specific options

The Floatbox package includes a Configurator page that can be used to generate the globalOptions section of options.js or an fbPageOptions object definition by selecting option settings from a form. This can be quicker and less error-prone than manually typing up your preferences directly. The Configurator cannot write to a file system. It presents the globalOptions or fbPageOptions code for you to copy and paste into the floatbox/options.js file or into your individual pages. You can of course use a combination of the configurator and editing your options directly with a text editor - whatever works.

Open configurator.html in your floatbox install folder with any browser. Select your option preferences on the form and click one of the buttons to generate your globalOptions or fbPageOptions code. The object definition shown will be only those settings that differ from the floatbox builtin defaults.

Back to Index

License key

The downloaded floatbox package is for evaluation, development and testing and does not have a license key bundled with it. Without a valid license key, floatbox will periodically show a registration reminder. You can acquire a license key from the Floatbox registration page. When you have acquired and installed a license key matched to your production site's domain, you will be legally entitled to deploy the floatbox software to that site and the registration reminders will not occur. You do not need a license key for development or evalution work. The floatbox package is complete and fully functional without a license key.

License keys are installed by being placed in the floatbox/options.js file. You can edit this file directly or use the configurator.html form to assist. The location for the licenseKey in options.js looks like this: globalOptions: {
  licenseKey: "",
The key goes between the quotes.

If upgrading from a previous floatbox version, you can copy the licenseKey.js file from the previous install into the floatbox folder and it will take effect (or, better yet, copy the key from the old file into options.js as described above).

The license key can also be set directly on your page with the "fbPageOptions" script object (see "Setting page-specific options" below). A bare-bones fbPageOptions definition with a licenseKey looks like this: <script type="text/javascript">
fbPageOptions = {
  licenseKey: 'abcd1234'
};
</script>
The configurator can help build fbPageOptions.

The license key can be tested by loading a page that has floatbox included and then running javascript:fb.key() from the browser's address bar.

License keys are matched to the registered domain and all checking that the key matches is done by the floatbox code entirely within the browser. There is no check made to a registration db anywhere and no 'phoning-home' of any kind.

If you are a publisher of multiple web sites and have registered your sites for licensed floatbox usage, you have the option of generating a multi-site "master" key for all your registered domains. This is a single license key that will be valid on each of your registered domains. Using such a multi-site license key can simplify deployment by allowing use of a single distribution source with no need to match individual keys to individual deployments.

Back to Index

Installation alternatives

(You don't need to read this section if you are using the standard install location.)

The quick-start instructions above have you copying the floatbox folder to the root of your site. Some folks prefer to place the floatbox package within another sub-folder. This is fine. You just have to adjust the given include lines for floatbox.css, floatbox.js and options.js so that they match the location of the files. For example, if the floatbox files are placed in the folder /includes/floatbox/, the three include lines in the <head> section would need to be:
<link type="text/css" rel="stylesheet" href="/includes/floatbox/floatbox.css" />
<script type="text/javascript" src="/includes/floatbox/floatbox.js"></script>
<script type="text/javascript" src="/includes/floatbox/options.js"></script>

There are many supporting files included in the floatbox download. They are nearly all needed for correct functioning. Floatbox is modular. It loads its javascript modules and language localization files on demand as required, but it needs to find these files in order to do so. It is highly recommended that you keep the floatbox folder intact and not try to separate the components out to different folder locations. If the install folder is kept intact, floatbox will auto-detect its modules, graphics and languages locations. If you break up the install into different locations (not recommended), the "modules", "languages", and "graphics" paths will need to be explicitly set at the top of the floatbox.js file. If the floatbox.js file has been renamed to something else, perhaps merged with other javascript files on your site, the "installBase" path needs to be set. This will tell floatbox where to find options.js and the default location for the other folders. Use absolute, not relative, paths for these custom path settings, and place a trailing backslash on the paths. If you alter the path relationship between floatbox.css and the graphics folder, floatbox.css will also need to be updated with the correct relative paths to the background images. (Really, just leave the floatbox folder structure intact. Everyone will be happier.)

If you are developing your site on a local file system rather than working from a web server, the root of your "site" will be the root folder of your drive. If you're on C: drive on a Windows system, the floatbox files should be in the C:\\floatbox\\ folder. Alternatively, you may want to use relative paths for your include paths such as src="floatbox/floatbox.js" or src="../floatbox/floatbox.js", etc., depending on where the files are relative to the page the include lines are on. (It's easier to develop on a real web server and just use the same absolute paths everywhere.)

Back to Index

Upgrading

Upgrading to a new version of floatbox entails replacing the entire contents of your existing floatbox folder. The javascript modules, css files, graphics and languages can all change between versions and all the components need to be in sync. As of version 4.0, you can set your default preferences in the new options.js file. (The default options are no longer editable directly in the floatbox.js file.) To bring a license key in from an earlier version, either paste the key into options.js (recommended) or bring your licenseKey.js file from a previous install into the floatbox folder.

Problems resulting from visitors pulling old floatbox files from their local cache after an upgrade can be avoided by adding a querystring to the floatbox include paths. A querystring on the floatbox.js include line will be used during the dynamic load of the js modules as well. Like this: <link type="text/css" rel="stylesheet" href="/floatbox/floatbox.css?v=1.23" />
<script type="text/javascript" src="/floatbox/floatbox.js?v=1.23"></script>
<script type="text/javascript" src="/floatbox/options.js?v=1.23"></script>
When you next upgrade floatbox, change the querystring to the new version number.

Floatbox has strong backward compatibility with previous versions. While many option names and api functions may have changed, the old functions and markup are still supported. It is not necessary to modify existing working pages when you do a version upgrade.

There are two important exceptions to the above-mentioned backward compatibility.

One is that framebox.js no longer ships with floatbox. In its place, change the old framebox.js include line to use floatbox.js instead and either add a 'framed' querystring parameter to the floatbox.js path or set 'framed' to true in fbPageOptions. See below for details.

The second change is that the legacy 'compressed' folder no longer ships with floatbox (all of floatbox is compressed). If your include lines point to that folder they will need to be modified to point directly to the files in the 'floatbox' folder.

Back to Index

Doc Types

Floatbox does not support quirks mode. All pages that include floatbox content need to have a valid doctype declaration at the top of the page which will set the browser to render in standards-compliant mode. If you don't know what doctype to use, the simple HTML5 doctype declaration <!DOCTYPE html> is an excellent choice. Note that for Internet Explorer, if anything at all appears above the doctype declaration, quirks mode will be set. So please don't put an html comment or an xml declaration such as <xml version="1.0" encoding="utf-8"?> at the top of your pages.

Back to Index

IE 8 rendering mode

The rendering engine in Internet Explorer 8 is extremely slow and inefficient at javascript animations such as element resizing and opacity fades. IE7 was not great in this respect, but IE8 is very poor. There is some code in floatbox to significantly speed up IE8 animations, but the trade-off is that this results in choppiness.

To get the best effects in all browsers, it is highly recommended that all pages that show animated floatbox content send a header to IE8 to set it to IE7 compatibility mode.
Do this by adding a meta tag to your page's <head> section: <meta http-equiv="X-UA-Compatible" content="IE=7" />
Or, from php, send the header directly with header('X-UA-Compatible: IE=7');
Or, from ASP.NET C#, Response.AppendHeader("X-UA-Compatible", "IE=7");

There is a problem with sending the IE7 header unconditionally to all browers. IE9's rendering engine is excellent and it does not suffer the weaknesses of IE8, but the X-UA-Compatible header will knock IE9 (when it ships) back to IE7 compatibility mode too, which we don't want. The only way to handle this is with server side code that detects a request coming from IE8 and sends the header only to that browser.

For example, in PHP: if (strpos(\$_SERVER['HTTP_USER_AGENT'], 'Trident/4.0;') && strpos(\$_SERVER['HTTP_USER_AGENT'], 'MSIE 8.0;')) {
    header('X-UA-Compatible: IE=7');
}

Or, ASP.NET C#: if (Request.UserAgent.Contains("Trident/4.0;") && Request.UserAgent.Contains("MSIE 8.0;")) {
    Response.AppendHeader("X-UA-Compatible", "IE=7");
}

If serving plain html, there is no facility to send headers conditionally. (A meta tag to send the header won't work if placed inside conditional comments). You will need to make the choice between letting IE8 render in its horribly slow native mode or force IE9 back to IE7 compatibility mode too.

Back to Index

IE 6 end-of-life

Floatbox works fine in Internet Explorer 6 but has some reduced functionality. In particular, drop shadows and disableScroll (fixed positioning) are not available.

Many sites and template authors are now dropping support for IE 6 by no longer doing the extensive amount of work required to get pages rendered properly in IE 6. Floatbox has the capability to present an IE 6 end-of-life screen to users of that browser when they first visit a site. This popup encourages those visitors to upgrade their browsers and embeds the http://www.browserchoice.eu/ page into the floatbox. The end-of-life notice uses a session cookie to make sure it is presented only once per visit. There is a checkbox the visitor can use to turn the notice off for 75 days. The notification page is auto-translated into the visitor's native browser language whenever it is displayed. You can see the IE 6 end-of-life notice (untranslated English version) on the HTML tab of the Floatbox demo page.

The IE 6 end-of-life notice is not enabled by default, but all Floatbox users are strongly encouraged to turn it on. Do this with a direct edit of options.js or by using the configurator form to manage your default options. (The showIE6EndOfLife option is on page 2 of the configurator.)

Back to Index

File & content types

Floatbox determines what kind of content is being requested based on the file extension from an anchor's href attribute. Sometimes you may need to over-ride that detection and specify a content type directly. Content type over-ride is always required when loading ajax, and can also be needed when you have a .php or .aspx page serving images.

By default, .php and .aspx urls will be loaded as iframes. To make them load as images, set "type:image" on the anchor's data-fb-options attribute. If you're fetching AJAX content, you need a "type:ajax" over-ride in the options.

Example:
<a href="getPix.php?pic=29" class="floatbox" data-fb-options="type:image">...</a>

Back to Index

HTML content: iFrames, AJAX, inline DIVs & direct

Floatbox handles 3 broad categories of content: images, html and multi-media. This section describes handling html content.

There are 4 ways to load html into a floatbox: as an iframe, using AJAX, using content from inline hidden DIVs, and using a direct html string as the content source. Standard anchor hrefs that aren't recognized as an image or multi-media type will be loaded as iframe content by default. To load that html content with AJAX, you need to put "type:ajax" in the anchor's data-fb-options attribute. To load content from an inline div, give that div a unique id and reference that div's id in the anchor's href attribute preceeded by "#" (e.g., href="#myDiv"). A string of direct HTML can be used as the source parameter to the fb.start() API function. Direct HTML content must include at least one each of '<' and '>' to be recognized as HTML content.
See below for examples.

There's lots of useful options that can be assigned to floatboxed html content. Please look through the options reference to get an idea of what's available. Good ones to be aware of are 'width', 'scrolling', 'backgroundColor', 'autoFitHTML', 'showNewWindow', 'showPrint', and the '*Pos' positioning settings. It's also worthwhile to check out the 'Let floatbox set content height' section further down in these instructions.

Here's some examples of floatboxed anchors that load html content:
iframe: <a href="mypage.html" class="floatbox" data-fb-options="width:400 height:530 scrolling:no">...</a>
ajax: <a href="myajaxpage.html" class="floatbox" data-fb-options="type:ajax width:400">...</a>
inline div: <a href="#divID" class="floatbox">...</a> And one example of direct html in an API call:
fb.start( '<span>Eat a Peach</span>', 'width:150 showPrint:true' );

The following section gives information about loading multimedia content, either directly or as iframe content.

Back to Index

Multimedia: Flash, Silverlight, QuickTime, YouTube, PDF, etc.

Multi-media content type is recognized by floatbox based on the file extension in an anchor's href. Recognized file extensions and the associated plugins are:
Flash - .swf
Adobe Reader - .pdf
Silverlight - .xap
Quicktime - .mov, .mpe, .mpeg, .movie, .3gp, .3g2, .m4v, .mp4, .qt
Windows Media Player - .wm, .wmv, .avi, .asf
In addition to locally served multi-media files, you can load floatbox content directly from online video services such as YouTube, Yahoo Video, Vimeo, Google Video, Metacafe and many others. If the required plugin is not available on the client browser, floatbox will display a notice (localized to the site visitor's language) with a link to the plugin download page.

For flash content, floatbox assigns the following parameter default values: wmode=window, allowfullscreen=true, allowscriptaccess=always, scale=exactfit, play=true, loop=true, quality=high. You can over-ride these plus 'bgcolor', 'base', 'menu' and 'salign' by providing new values in the href url's querystring.
e.g., <a href="myflash.swf?wmode=opaque&amp;bgcolor=#ffffff&amp;scale=default" class="floatbox" data-fb-options="width:320 height:240 scrolling:no">...</a>

If your flash object requires flashvars to be set, you can put these flashvars in the href url's querystring. Flash always treats flashvars and querystring vars equivalently and it doesn't matter in which location the settings appear. If your flash content requires a minimum version of the flash plugin, this can be specified with the minFlashVersion option, described in the Options Reference.

Youtube videos have the following two additional parameters that can be set via the href's querystring: fs=0 to disable fullscreen capability, and start=xx to start playing xx seconds into the video.

Quicktime default parameters used are autoplay=true, controller=true, showlogo=false and scale=tofit. These can be overridden with a querystring in the same manner as described for flash.
All Silverlight control parameters are left as defaults and can be set through the querystring.

When loading videos from an online video service such as YouTube or Vimeo, you need to determine the href path to use and the width and height dimensions. For YouTube, Yahoo, Vimeo and Vivo, you can use the site's page url for the href, or you can use the embed path. For other online video services you must use the embed path.

Most video services show you the embed code directly or have a "share" button that will show this code. This is where you can look up the width and height. The easiest approach is to look at the examples in the Multimedia section of the demo page for the video service you are interested in, modelling your anchors after the ones given there and changing the parameters to point to the videos you are interested in loading.

PDF documents can be direct-loaded using the Adobe Reader plugin, or can be loaded as flash through the scribd.com service (see the example on the Bonus2 tab on the demo page). When direct-loading pdf, numerous parameters can be specified on the URL. The pdf sample on the Multimedia tab of the demo page opens a document that lists and describes the available parameters. Note that IE is very buggy when showing pdf files from another domain, whether direct-loaded or as iframe content. To make IE happy, bring all pdf files into your site and serve them from the same domain the host page is running on.

It is usually best to direct-load multi-media files. Floatbox direct-load code contains some fixes for troublesome objects in some browsers. But you can also load multi-media content as ajax or iframes. There may be times when you want to do this to gain more control over the displayed object. For an ajax load, just bring in the object/embed code (or the required javascript if you're using script to setup your objects). For an iframe load, you will want to have a complete and properly setup html document with a head and body section. Make sure your iframe's document body has no margin or padding: body { margin: 0; padding: 0; } Then set the floatbox width and height to the exact dimensions of your multi-media object and add "scrolling:no" to your options settings. There's a sample in the html section of the demo page.

The object element used to show multi-media in floatbox is assigned an id of "fbMedia". This can be used if script access to the object instance is required.

Back to Index

Let floatbox set content height

Floatbox will measure and set the dimensions for html content of type ajax, inline or direct. It's a good idea to let floatbox do this, especially for height, so that the box dimensions will look correct in different browsers. Different browsers layout content slightly differently from each other, and the right box height in one browser can be too short or too tall in another. The best approach is to constrain the html content's width either by setting a floatbox width option or defining a width in the html styles, and then let floatbox measure the height. Not all content can be successfully measured, but most can. Scrolling and positioned elements in the content are the most likely to measure incorrectly.

Iframe content (normal web pages shown in a floatbox) can auto-set height too, but in a different fashion. If floatbox.js is included on both the base page and the iframe content page, the base and content pages are from the same site (domain), and the scrolling option is set to 'no' for the iframe item, floatbox will auto-size itself to the iframe content height when the iframe page completes loading.

Back to Index

Cycling images and thumbnails

Floatbox includes a module for displaying a set of images or thumbnails that will fade and cycle through each image in succession. This can be an effective way to show dynamically changing images, setup a slideshow link or put a dynamic header at the top of a web page. See examples of this under the "bonus" tab on the demo page. The sample code under those demos are a good way to get started with your own cycle set.

The cycleInterval and cycleFadeDuration options are used to control timings. cycleFadeDuration controls how quickly the images fade in and out while cycleInterval controls how long the images will be displayed before fading to the next image. The cycle interval includes the time taken for the fade effect to complete. There is also a cyclePauseOnHover setting which, if set to true, will pause a cycler div when the mouse is hovered over it.

The set of images to be cycled goes inside a div with a class of "fbCycler" assigned to it.
<div class="fbCycler" style="height:420px;">
It's best to assign a specific height to that div which fits the tallest image in the set, otherwise it might look a little odd as the div grows to accommodate new images that cycle in.

The first image in the cycler set is just a normal image element and will be the only one shown if javascript is disabled: e.g., <img src="image1.jpg" />

The other images in the fbCycler div are setup a little differently and will start off hidden by floatbox.css:
<img data-fb-src="image2.jpg" />
Notice that we use the data-fb-src attribute to specify the path to the image file, instead of the normal src attribute. This is done to speed up page loading. If we assigned a src attribute to each of the hidden images, all the images in the set would be loaded at page start time. The floatbox code will move the data-fb-src values into the src attribute one at a time as the images are cycled in. (You can instead use the longdesc attribute for the alternate src reference if you like.) If you're concerned about the img elements with no src attribute failing validation, assign a tiny image like blank.gif as the initial src value.

Add a few more images and close the div and the basic cycle set is finished.

Captions can be added to the cycling images. These captions will be centered below the image. Assign a caption by bundling both the img element and span element together inside a div. Like this:
<div><img data-fb-src="image3.jpg" /><span>text for image3</span></div>

The cycling thumbnails can be anchor elements marked up for floatbox behaviour, giving a nicely integrated floatbox gallery that will open on thumbnail click. Such a set looks similar to the basic cycling image set described above but, instead of putting img elements in the set, we put anchors in and assign a floatbox class to the containing div. Like this: <div class="fbCycler floatbox" data-fb-options="group:cycle1" style="height:100px;">
  <a href="image1.jpg"><img src="thumb1.jpg" /></a>
  <a href="image2.jpg"><img data-fb-src="thumb2.jpg" /></a>
  etc...
</div>
Notice that the thumbnail img elements are using the "data-fb-src" trick to speed load time.

Caption text can be added to the cycling thumbnails or images by following the img element with a span element. Like this (for a thumbnail cycler): <a href="image3.jpg">
  <img longdesc="thumb3.jpg" />
  <span>text for thumb3</span>
</a>
(The 'longdesc' parameter is equivalent to 'data-fb-src' and is valid html4.)

cycleFadeDuration can be set only globally or per page; different cyclers on the same page cannot use different timings. The cycleInterval setting can be assigned globally, per page, or on a per-item basis giving different display times for different items in the set. Per-item cycleIntervals are assigned in an fb-data-options or rev attribute placed on the individual divs, anchors or images inside the fbCycler div. Like this (for an image cycler); <div class="fbCycler" style="height:420px;">
  <div data-fb-options="cycleInterval:6.5">
    <img src="image99.jpg" alt="" />
    <span>some dumb caption</span>
  </div>
  etc...
</div>

Back to Index

Enhanced tooltips

Any element on a web page can have an enhanced tooltip associated with it by assigning the element a class of "fbTooltip". The tooltip shown on mouseover of such an element is a non-modal floatbox which can contain any content type and can by styled with all the standard floatbox options.

In addition to the fbTooltip class, the host element needs to have a 'data-fb-tooltip' attribute which provides information about the tooltip to be shown. The only mandatory entry in data-fb-tooltip is 'source', which points to the source content to be shown as the tooltip. Additional options available for tooltips are described in the options reference and include attachToHost, moveWithMouse, placeAbove, timeout, delay, mouseSpeed, fadeDuration and defaultCursor.

The tooltip options can be specified per element in the data-fb-tooltip attribute, per page by being assigned to to the tooltip type in fbTypeOptions, or site-wide by being assigned to the tooltip type in options.js.

An example showing a span element with an enhanced tooltip: <span class="fbTooltip" data-fb-tooltip="source:#hiddenDivID moveWithMouse:true">Tooltip will appear when the mouse is hovered over this text.</span> See the 'Bonus2' tab of the demo page for some live examples with markup shown.

An enhanced tooltip can be assigned to the content shown in a standard floatbox using the tooltip option in the originating anchor's data-fb-options attribute. The value of the tooltip option is the source of the tooltip content. Optional settings for the tooltip can be provided in the 'tooltipOptions' setting.
An example: <a href="image1.jpg" data-fb-options="tooltip:#myTooltipDivId tooltipOptions:`moveWithMouse:true backgroundColor:#123456`">click me quick</a>

Back to Index

Popup thumbnails

You can configure anchors to have a popup thumbnail that appears when the mouse is over the anchor and disappears when the mouse moves off. The popup thumbnails can be clicked to load an associated image in floatbox. Combining popup thumbnails with floatbox's ability to zoom from a thumbnail to an image makes for a nice effect. Popup thumbnails are enabled by assigning a class of "fbPopup" to the <a>nchor element.
Here's an example: <a class="fbPopup floatbox" href="myImage.jpg">clickable text<img src="myThumbnail.jpg" /></a>

Popup thumbnails set with "fbPopup" appear just above the hovered anchor. Use "fbPopdown", "fbPopleft" or "fbPopright" if you prefer the thumbnails to show on those sides of the anchor.
The floatbox class assigned in the example is not required and is independent from the fbPopup class name. This anchor is marked for both popup thumb behaviour when hovered and to open in a floatbox when clicked.

As you might guess, there's samples in the 'Bonus' section of the demo page.

Back to Index

Captions

The standard way to show a caption in the floatbox frame area is to set the 'caption' option in an anchor's data-fb-options (or rev) attribute. When doing this, the caption text usually needs to be wrapped in backquotes (`) so that the options string will be parsed correctly.

You can show two captions on the same item. To do so, assign the second caption to the 'caption2' option in the same manner as the first caption.

If the 'titleAsCaption' option is set to true (which it is by default) and a caption is not defined, the anchor's title attribute will be used as the caption. Be aware that browsers display an anchor's title as a tooltip when the user mouses over the anchor. If you don't want the tooltip to occur, set your caption using the caption option rather than placing it in the title attribute.

Here's two examples:

Floatbox captions can be built from, or contain, HTML elements. There's two ways to get HTML into your captions. The first is to put your caption's HTML inside a hidden div on the page and reference that div by id in the caption option. Like this: <a href="image1.jpg" data-fb-options="caption:#myCaptionDiv">...</a>
...
<div id="myCaptionDiv" style="display:none;">
  <span style="color:#123456;">Here's an HTML caption with <a href="http://example.com">a link</a></span>
</div>

The second way is to assign the HTML caption directly in data-fb-options. When assigned directly to the caption option all HTML entity characters (& " < >) will need to be encoded (&amp; &quot; &lt; &gt;) so that browsers can correctly parse the page. This can get messy and can be harder to get right than the hidden div approach. For example, the same caption assigned in the hidden div above looks like this when encoded and placed directly in the options: <a href="image1.jpg" data-fb-options="caption:`&lt;span style=&quot;color:#123456;&quot;&gt;Here's an HTML caption with &lt;a href=&quot;http://example.com&quot;&gt;a link&lt;/a&gt;&lt;/span&gt;
`"
>...</a>
(I told you it could get messy.)

If you set your caption to the string "href", the displayed caption will be the value of the anchor's href attribute. This might be useful when displaying iframed content or if you want to display the path/filename of the current image.

Back to Index

Info box for secondary content

There are occasions when it is helpful to display additional information about your floatbox content. For photogrpahs, this might be descriptive text, EXIF information or a popup location map. Forms or other html content may have associated help or other information that can be effectively presented in a second floatbox. Floatbox's info box capability addresses this usage. When enabled, a link will appear in the lower left of the floatbox frame which activates the information box.

There are four options you can set in your anchor's data-fb-options attribute to enable and configure the info box.
1) Assign the url that points to the information source using the option "info". E.g., info:myInfoPage.html or info:#myInfoDiv
2) Set floatbox options for the secondary info box using the option "infoOptions". E.g., infoOptions:`color:white width:400 height:300` (The backquotes are required to enable correct parsing.)
3) By default the link in the floatbox frame will display the text "Info..." or its localized language equivalent. You can override this with the "infoText" option. E.g., infoText:`EXIF data...`
4) Use infoLinkPos to position the info link within floatbox border area. E.g., infoLinkPos:bl

An anchor with an associated info box could look like this:
<a href="myPhoto.jpg" class="floatbox" data-fb-options="info:#myInfoDiv infoOptions:`color:white width:400 height:300`">click here</a>

Yes, there's an example or two on the demo page (in the 'Bonus' section).

Back to Index

Print contents

If you set "showPrint:true" in a floatboxed anchor's data-fb-options attribute, a "Print..." link will be shown in the floatbox border area. When clicked, this link will invoke a second browser instance that will display just the contents of the floatbox window and will show the print dialog for this new browser instance. The contents that will be printed will be just that from the floatbox display, not the surrounding eye candy and not the host page content. Use the printLinkPos option to control where in the floatbox border the "Print..." link will appear. Use the 'printText' option to change the displayed "Print..." link to any other desired text.

In some circumstances you may find that you want to add css styling to the print window contents. You can do this with the printCSS option. If printCSS is a URL path to a css file, that css file will be attached to the print window. Or, you can just put css assignments directly into this option, surrounded by backquotes. For example: data-fb-options="showPrint:true printCSS:/css/print.css" or data-fb-options="showPrint:true printCSS:`p {font-size: 11px;} etc...`" You often don't need to add any css stuff for printing, but it's there if you need it.

Note that printing is not available for iframe content that comes from a different domain than the base page (cross-site script blocking). If you are displaying a cross-domain iframe in floatbox, the "Print..." option will not be displayed.
As usual, see the demo page ('Bonus' section) for an example.

Back to Index

Open in a new window

You may have occasion to offer your site visitors a way to open the current floatbox content into its own new window. Do this by setting 'showNewWindow' to true in an anchor's option string (rev or data-fb-options attribute). This will place a link in the floatbox frame that can be clicked to open the new window.

The string displayed in the new window link is localized in the language files and will be shown in the site visitor's native browser language. If the option 'showNewWindowIcon' is set to true (its default setting), a small new-window icon will be shown alongside the text link. The option 'closeOnNewWindow' (false by default) will cause the current floatbox to end when the new-window link is clicked.

Index links in a gallery

Galleries of multiple images (or other content) can have a series of simple numbered links shown in the floatbox border area. If there are thumbnails associated with linked images, these thumbnails will be displayed as small popups when the numbered link is hovered with the mouse.

Primary control over the display of index links is done with the numIndexLinks option. If this is zero, index links will not be shown. If it is -1, there is no limit on the number of index links shown - there will be a link for each image in the gallery group. Any positive integer and the number of links shown will be limited to this amount (in case you don't want a huge list of numbered links for your gallery of 479 pictures).

Four other options affect index links. Setting showIndexThumbs to false turns off the thumbnail popups within the index links. The pipIndexThumbs default setting of true shows the index thumbs overtop of the current floatbox content image as a 'picture-in-picture' popup in the closest corner. If pipIndexThumbs is set to false, the index thumbs will appear immediately above or below the correspondind index link. You can use maxIndexThumbSize to scale down large thumbnail popups in the index links so that their largest side does not exceed the given given size. And you can control the location of the index links with the indexLinksPos option. (See the "Layout" section of these instructions for details.)

You can see index links in action on the "Include Index Links" sample on the demo page.

Back to Index

Navigation and controls

Floatbox includes controls for moving to previous and next items in a group, resizing, playing and pausing a slideshow, and exiting. These controls are graphical and loaded from the graphics folder. If the configuration setting "graphicsType" is set to the default "auto", browsers that are configured with a localized language other than English will see graphics-only controls. Localized English browsers will see control graphics that include English words.

There are two sets of previous/next controls for grouped items. "Overlay" navigation displays a small graphics on top of the displayed image when the mouse is over the left or right side of the image. "Button" navigation displays a clickable << prev || next >> (or the international equivalent) in the box frame outside of the content. You can use either or both of these by setting the navType option. My favourite setting is to set navType to "both" and set showNavOverlay to "never". This allows navigation to occur by clicking on the image (or on the button nav control) but does not display the popup graphic over top of the image.

When the floatbox content has been shrunk from its native size to fit the screen, or when it is displayed larger than the current screen size, a resize control will be displayed which can be used to toggle the item's size. The "resizeTool" option controls whether the resize control will be a custom maginfying-glass cursor or a small graphic in the top left corner. If the custom cursor is used and overlay navigation is enabled, click-resizing is active only in the space between the two upper navigation areas. (Opera always gets the graphic in the top left corner because it can't do custom cursors.)

When enableKeyboardNav is set to true, the following keys can be used in place of mouse-clicking the controls:

If the Ctrl key is used together with the left or right arrow, floatbox will jump 5 items ahead or back in the sequence. This is to facilitate quick navigation when using floatbox as a poor-man's PowerPoint.

Back to Index

Layout

There are many things that can appear inside the floatbox frame area: the two captions, an info link, print link, new-window link, item number for gallery sets, index links and the close button and navigation controls. You can control the positioning of these items with the *pos options: captionPos, caption2Pos, infoLinkPos, printLinkPos, newWindowLinkPos, itemNumberPos, indexLinksPos and controlsPos.

The available positions are 'tl', 'tc', 'tr', 'bl', 'bc', and 'br' corresponding to top-left, top-center, bottom-left, etc. You cannot fill all 6 positions. You can use only two positions at the top and two at the bottom. So for example, if you have something assigned to the bottom-left, you can place something else either at bottom-center or bottom-right, but not both. If you make a positioning request that cannot be filled, the frame items will be moved to other locations in the frame.

The close button and navigation controls cannot be assigned to a center position (tc or bc), but you can set the centerNav option to true to move the navigation controls to the center of the frame while leaving the close button off to the side.

Back to Index

Appearance

There's lots of control over floatbox's appearance. Many of Floatbox's options are for configuring appearance. You can set the colors, round corners, border sizes, display of controls, shadow effect, transparencies and various animation effects through the configuration options. See the options reference for details on the use of these (and other) options. It's a good idea to play with the "Set Options" form on the demo page to try out the different option settings that are available.

Floatbox has 6 pre-configured color themes: white, black, blue, red, yellow and custom. When no color option is specified, Floatbox defaults to black for images, white for html content, and blue for multi-media. The 'color' option can be set globally, per page, or per item to override these per-type defaults. The backgroundColor option sets the background color inside the floatbox content area and is useful if the displayed content has transparent areas.

The 'custom' color setting is for creating and using your own customized color scheme for floatbox. Look at the top of floatbox.css for settings pertaining to the custom scheme. The settings are well documented with comments in the css and allow you to easily modify the default colors. The control widget backgrounds such as for the close or prev/next buttons can be replaced with custom background images. If you do this, be sure to change the various control widths and heights in the css as described in the comments.

Back to Index

Custom background image

You can use a graphic as an overlay background image by providing a background-image style for the overlay element. In a css file, it would look something like this:
#fbOverlay {
    background-image: url(bkgrnd.gif);
}
The background-image setting can be placed in an external css file together with the appropriate include in the head section of your page, or it can be placed directly inside a <style type="text/css"></style> section in the page head. Of course, background-image can also be added to floatbox.css if you want it universally applied, but this will prove to be a pain when you upgrade to a new version.

When a custom background image is used, you may want to also set overlayOpacity to 100, or maybe play with lower values to fade the background. For an example of a custom background and the use of autoStart and loadPageOnClose, check out the APOD slideshow on the demo page.

Back to Index

Language localization

Floatbox includes language localization files for 35 languages. The strings in these files are used as tool tip hints for the floatbox controls, the "image x of y" display, the text displayed on "Info.." and "Print..." links, and the strings shown when a required multimedia plugin is not present. The correct language file will be selected for use based on the localization settings or your site visitor's browsers. You can set floatbox to always use one particular language file by setting the "language" option. But it is recommended that you not do this. By leaving language as "auto", your visitors will get the correct language for themselves.

There are two sets of graphics used for the floatbox controls. One set has English text on the controls ("Close", "Next", etc.), while the other set is purely graphical. In the default setting, the English controls will be served to people with English-localized browsers and all other users will get the non-graphical, international controls. You can use international controls for everybody, including English speaking folk, by setting graphicsType to "international".

The Floatbox API has a library function fb.translate which provides an interface to the Google translation service. This function can be used to translate any floatbox content, or other page content, from and to a variety of languages. See the API reference for details.

Back to Index

Auto-start and exit tasks

You can have floatbox content appear directly on page load by using the autoStart option. Put "autoStart:true" into the data-fb-options attribute of the floatbox-enabled item that you want to run automatically. As soon as the page loads, floatbox will start with this item displayed. You can use "autoStart:once" to have that tagged item display only on the first page load of the session. Doing this sets a session cookie when the item is first shown and that item will not be auto-shown again as long as that session cookie is present.

You can also invoke an auto-start through a query string on the url used to invoke the page. For example, a url of "http://example.com/mypage.html?autoStart=myimage.jpg" will auto-start myimage.jpg provided there is an anchor on the page that is setup for floatbox and that has that image as its href value. Note that the query string value only has to match the right-hand side of the anchor's href. The given example would match an href of "/images/this_is_myimage.jpg".

Floatbox can automatically load or reload a web page in the browser when it exits. The "loadPageOnClose" option is used to make this happen. Set loadPageOnClose to the string 'self' to refresh the host page on exit. This can be useful if your floatboxed content has modified some back-end content and the host page needs to be refreshed to reflect the changes. If you set loadPageOnClose to the string 'back', the previous page in the browser's history list will be loaded. This is used in the APOD slideshow on the demo page. If loadPageOnClose is neither 'self' nor 'back', it is assumed to be a valid url and the browser will be instructed to load that page. If you set loadPageOnClose to a url inside an option string, you must surround the url with backquotes (`) so as not to break parsing of the option string.

Firefox has buggy history/back button behaviour when iframes are on the page. These bugs prevent loadPageOnClose='back' from working when closing iframe content in Firefox. For this reason, it is recommended that you don't use the 'back' instruction when showing iframe (a normal html page) content. The Firefox history bugs do not occur with ajax content and 'back' will work just fine in Firefox if you load your content as type:ajax.

You can set loadPageOnClose in the usual option setting way (fbPageOptions or rev attribute), but you can also set it dynamically with javascript. For example, your script could say fb.loadPageOnClose = 'somePage.html'; (or parent.fb.loadPageOnClose if you're running from a floatboxed iframe page that does not have the floatbox files included on it).

When closing floatbox by calling the API end function, the equivalent to loadPageOnClose can be passed directly as an argument to that function like this: fb.end( 'somePage.html' ).

Be sure to see the API reference for information about the Floatbox callbacks that are available to run custom code on such events as floatbox or item start and end.

Back to Index

Image map areas

Floatbox can work with image map areas the same way it does for standard <a> elements. To do this, set up the class and options attributes as described above, but for image maps these attributes go on the map's <area> elements. There's an example in the 'Bonus' section of the demo page.

Back to Index

Running in iFramed pages

You can run floatbox from iframed pages if you like, and those iframes can be nested as deep as you want. Floatbox.js needs to be included in the root (top) page and on every page in a nested chain down to and including the last child page that has floatbox content on it. For example, if you have a page with iframes nested two deep and floatbox content only in the deepest iframe, you need floatbox.js included in the deep iframe, the parent of that iframe, and the root document. The floatbox.css and options.js files have to be included in the root page, but do not need to be on the child iframe pages. (See the iFrames section of the demo page for an example of a floatbox-enabled page with iframes nested two deep.)

Note that browsers restrict cross-site scripting. Floatbox (and any other lightbox-type script) will not be able to function from within an iframe if the top page and iframed child page do not have identical host name portions of their URLs. (You can use the 'framed' setting in these circumstances. See below.)

Back to Index

Constraining floatbox to a particular iFrame (or frameset child)

Floatbox normally occupies the entire browser window when displaying content by attaching itself to the top document. You can, if you like, have floatbox appear only inside a particular iframe and constrain itself to the dimensions of that iframe (or to a frameset child document). There are two ways to do this.

The first is to place a querystring of "framed" on the floatbox.js include path. The include lines then look like this:
<link type="text/css" rel="stylesheet" href="/floatbox/floatbox.css" />
<script type="text/javascript" src="/floatbox/floatbox.js?framed"></script>
<script type="text/javascript" src="/floatbox/options.js"></script>

The second way to get framed behaviour is to set the 'framed' option in an fbPageOptions definition. Something like:
<script type="text/javascript">
fbPageOptions = {
  framed: true
};
</script>

For frameset pages, you must use the 'framed' option to attach floatbox to one or more of the child frame pages. A frameset master page cannot render content itself and consequently cannot have floatbox attached to it. If you are licensing floatbox for use on a frameset site, the registered domain should be the domain that the frame content is loading from. This frame holds the window object that Floatbox will attach to, and it is the domain of this window that needs to match the license key.

With the "framed" parameter in place, Floatbox attaches itself to the current window's document, rather than the top document.

Back to Index

Accessible content (Section 508)

Floatbox provides two options, 'altContent' and 'attachTo', that can be used to provide accessible content for people with disabilities. These options designate alternate content for images and iframes and provide correct sequencing or placement of content opened in a floatbox. These capabilities allow floatboxed content to be correctly handled by screen readers, making the Floatbox content compatible with sites intended to meet US Section 508 requirements. 'altContent' is described here and 'attachTo' in the section that follows.

Use 'altContent' to assign a text string of alternate content to specific floatbox items. When set on an image link or start call, the altContent text will be assigned to the 'alt' tag of the floatbox image element. This will be the text read by a screen reader in place of showing the image. When set for iframe content, the text will be assigned to the iframe's 'title' attribute and will also provide the text for a link to the iframe page in the iframe's alternate content.

For example - from a link on the page:
<a href="tulips.jpg" data-fb-options="altContent:`dozens of tulips in a field`">go</a>
results in a displayed img element of:
<img src="tulips.jpg" alt="dozens of tulips in a field" />

Or, an iframe from an fb.start() call:
fb.start( 'lesson1.html', 'altContent:`tutorial on building accessible sites`' );
results in a displayed iframe element of:
<iframe src="lesson1.html" title="tutorial on building accessible sites"><a href="lesson1.html">tutorial on building accessible sites</a></iframe>
Notice how a link to the lesson1 page is provided for agents such as screen readers that can't display the iframe.

Use of 'attachTo' for correct content sequencing is described below.

Back to Index

Attach to a specific document element

Default behaviour for Floatbox is to attach itself to a page's body element as the last child of the body. The 'attachTo' option can be used to direct floatbox to append itself to a particular element other than the body. There are two reasons why you might want to do this. First, page content needs to appear in the correct sequence to be compatible with screen readers and compliant with US Section 508 accessibility requirements. Second, ASP.NET pages can contain only one form and so any form content presented in a floatbox needs to be attached inside this one form to function correctly.

Set attachTo to 'click' to have the floatbox attach in the document immediately following the clicked item that started the box. This is a good choice to meet accessibility requirements of correct content sequencing. The attachTo option can also be set to the id of an existing element (usually a div or a form) to have the floatbox appended to that element. This is how you would attach a floatbox to an ASP.NET form.

Using attachTo does not make the content appear inline with the host page content. It still appears as normal in the floatbox, but is logically placed at the requested location in the page's document tree. Note that when attaching floatboxed html content (other than an iframe) to a document element, the content may inherit some css settings from the parent element that would not be inherited had the floatbox attached directly to the body.

Back to Index

Dynamically loading floatbox content via AJAX or UpdatePanel

When floatbox first loads on a page, it runs its activateElements function to inventory all the floatbox-enabled anchors and area maps on the page, and to add the required onclick action to those anchors. It also activates any cycler sets, enhanced tooltips and popup thumbnails defined in the content. Floatbox's built in fb.ajax() function will automatically run activateElements against any new content brought in using that function. If you dynamically update a portion of your page using any other method, any floatbox-enabled anchors in that content won't be in floatbox's inventory and won't have the required click or mouseover actions attached to them. To give those new anchors floatbox behaviour you need to re-run fb.activateElements().

Your existing AJAX content insertion might look something like this:
if (xhReq.readyState == 4) {
  document.getElementById('myXhrDiv').innerHTML = xhReq.responseText;
}

Light up the floatbox anchors in that dynamic content by adding the following line after that insertion:
if (xhReq.readyState == 4) {
  document.getElementById('myXhrDiv').innerHTML = xhReq.responseText;
  fb.activateElements();
}
This clears the existing inventory of anchors and then re-inventories the entire document, including the freshly added new content. Now your new floatbox anchors will work.

But really, it's simpler just to use floatbox's builtin ajax function and get activateElements executed for free. fb.ajax({ source: 'someURL.php', updateNode: 'myXhrDiv' });

If you are using an ASP.NET UpdatePanel, you can set a callback function to fire the floatbox activation after your panel has finished updating. Put this javascript on the page:
function pageLoad(sender, args) {
  if (args.get_isPartialLoad()) {
    fb.activateElements();
  }
}

Or... as an alternative to getting the fb.activateElements function to fire at the right time, you could setup your new anchors with their own onclick action instead of giving them a class of "floatbox". For example, the following anchor will fire up in floatbox when clicked without needing to be activated: <a href="somePage.html" onclick="fb.start(this); return false;">do it</a> You can add options to the above sample anchor in the usual way by adding the desired data-fb-options or rev attribute settings.

(The legacy fb.tagAnchors function is still supported and still works.)

Back to Index

WordPress and other templated systems

The recommended and supported approach to using Floatbox on a templated site such as WordPress is to directly edit the site's html as described in these instructions and shown on the demo page. Doing so gives you access to all of Floatbox's capabilities and support. Floatbox support does not extend to any third-party tools or plugins.

Please see this WordPress post for some getting-started pointers useful for adding Floatbox to the html of any template-based site.

Back to Index

Launching floatbox from flash ActionScript

This topic has very little to do with floatbox, and everything to do with authoring behaviours in flash objects. But there's a demand for this information so perhaps the little bit here can be some help.

The generic task to be solved is one of getting a click action on a flash object to fire a javascript function on the host page. The specific floatbox task is then the simple one of getting that javascript function to fire floatbox. There are different ways to approach this. I'm giving just one of those ways here, but I think this is a clean way to do it.

Create a button in your flash object. Give it a name. Let's call ours "button1". Now define a click action on the button. In ActionScript 2, that click action can be set on the button's action panel with on(release) { ... }. However, I think it's cleaner to define all actionscript on the generic action panel of your layer object.

On the layer's action panel, define an action like the following (this is ActionScript 2):
button1.onRelease = function() {
    getURL("javascript:button1Click()");
};

ActionScript 3 does not have a getURL function. For AS3, use the more complex:
function myFunc(event:MouseEvent):void {
    var request:URLRequest = new URLRequest("javascript:button1Click()");
    navigateToURL(request, "_self");
}
button1.addEventListener(MouseEvent.CLICK, myFunc);

That's it. Now we're all done with the flash object. What we've got now is a button that when clicked will fire a javascript function named "button1Click" on the host page. We just need to define that javascript function in the head of our page to do whatever we want when the flash button is clicked. Here you should refer to the floatbox API reference to learn about launching floatbox from javascript.

But here's a hint. If you've got a standard floatbox anchor setup on the page, and you give that anchor a unique id, like "myAnchor", your button1Click function might look like this:
button1Click = function() {
    fb.start('myAnchor');
};

Or... instead of passing the fb.start function an anchor that's setup for floatbox behaviour, we can use the direct launching syntax of fb.start (see the API reference):
button1Click = function() {
    fb.start( 'somePage.html', 'width:xxx height:yyy someOption:someValue' );
};

It's that easy. One word of warning though: Dont' return anything from the js button1Click function or the page will try to navigate to that return value. There's a couple of samples (done a little differently than described here) in the 'Code' section of the floatbox demo page.

Back to Index

Serving gzip compressed files on Apache and IIS

Warning: This section discusses modifying your .htaccess file and using mod_rewrite on your Apache server. This is a bit of a black art. What works on one server configuration may not work another. No support or assistance is provided for modifying your .htaccess file or for serving the gzip files.

The modules folder contains gzipped versions of the .js and .css files in it. The gzip files are a fraction of the size of the original files, but serve exactly the same content to the browser. You can direct your Apache server to serve these gzip files through your .htaccess file. The .htaccess file can be located in the floatbox or modules folder itself if you only want to serve floatbox gzipped files. If you want to enable gzipped files across your site, the .htaccess directives can go in your site's root folder.

Here's the suggested (but unsupported) htaccess directives to enable gzip file serving.
<IfModule mod_rewrite.c>
<IfModule mod_headers.c>

Options -MultiViews
RewriteEngine on
# if folder aliases are in use, set the correct RewriteBase for this folder
# RewriteBase /

<FilesMatch "\.js\.gz$">
ForceType text/javascript
Header set Content-Encoding: gzip
</FilesMatch>

<FilesMatch "\.css\.gz$">
ForceType text/css
Header set Content-Encoding: gzip
</FilesMatch>

RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteRule ^(.+)$ $1.gz [L]

</IfModule>
</IfModule>

Options.js is not provided in gzip format because it is intended to be edited with your implementation preferences. If you want to serve a gzipped version of this file, first edit (or use the configurator) to set your option preferences and then gzip the modified file. (GNU.org - Gzip for Windows)

IIS does not use the gzip files that are provided in the Floatbox package. Instead, compression is enabled and configured within IIS and IIS will generate its own compressed version of the served files. A search on "gzip iis" will locate information on how to enable and configure compression in IIS.

Back to Index

Using the library functions

Floatbox exposes many of its internal functions in a way that allows it be used as a small but effective javascript library. In many cases, you can avoid loading other libraries such as jquery or mootools and instead use the floatbox calls that are already loaded on your page. The Floatbox library includes a simple to use, robust and flexible AJAX utility, language translation, event handling, an image preloader, easy flash object creation, some helpful DOM manipulation routines, and more. For a complete list of available Floatbox functions, please see the API reference.

Back to Index