Floatbox v5.0 - Instructions

floatboxjs.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 two 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>
  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 floatboxjs.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 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, caption and contentBackgroundColor are per item whereas cornerRadius and colorTheme 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. (Not all the assigned options in this example are required to get the slideshow functionality, and if you're copying this example for use on your own pages you will no doubt remove some options, maybe add some others, and set things to the way you want them to be.)

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.
"colorTheme:red width:200", "colorTheme:red; width:200px;", "colorTheme:red, width:200" and "colorTheme=red&width=200" are all allowed and equivalent.

Note that options assigned directly on anchors, or as parameters to the fb.start API function, override or replace the same options assigned by the more global methods described below. To cancel an inherited option without setting a value for it, assign 'null' to the option.

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 placed in a page's <head> or <body> 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. A comma after the last one will break IE.
A standard Floatbox options string can also be used as an alternate syntax for defining fbPageOptions. E.g.: <script type="text/javascript">
  fbPageOptions = 'shadowType:halo resizeDuration:5.5';
</script>
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: 'colorTheme:red 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:true'
  };
</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.

The license key can also be set directly on your page with the "fbPageOptions" script object (see the "Setting page-specific options" section of these instructions). 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 as well as the globalOptions in options.js.

If upgrading from a previous floatbox version that used licenseKey.js, you will need to copy the license key from that old file into options.js as described above.

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

The quick-start section of these instructions recommend copying the floatbox folder to the root of your site. It is actually beneficial to provide a unique (non-standard) folder for the Floatbox files. (See "Cache control" in these instruction for details. The include lines for floatbox.css and floatbox.js need to be adjusted so that they match the location of the files. For example, if the floatbox files are placed in the folder /includes/floatbox_500/, the two include lines in the <head> section would need to be:
<link type="text/css" rel="stylesheet" href="/includes/floatbox_500/floatbox.css" />
<script type="text/javascript" src="/includes/floatbox_500/floatbox.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), you will need to set "graphicsPath", "languagesPath" and "modulesPath" in an fbPageOptions definition. The fbPageOptions definition will need to appear before the include line for floatbox.js, the paths should be absolute and not relative, and all paths must be terminated with a slash/. If you alter the path relationship between floatbox.css and the graphics folder, floatbox.css will 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 and you want to use the default recommended include paths, 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

Be sure to read the "Cache control" section of these instructions, immediately below this section. Managing brower cache is a critical part of a smooth upgrade.

Options, features, and API functions and properties can change, disappear or be extended and enhanced with new releases. To the extent possible, Floatbox always maintains backwards compatibility for pages configured to use earlier versions. For example, an option may be replaced or renamed, but the old option will still be recognized.

Internally, version 5 is a massive change from version 4, with a new architecture and code base. If upgrading from an earlier Floatbox version, be sure to review the changes listed on the Download and Change Log page to see if anything there will affect your implementation. If you are using the more advanced features of Floatbox such as the API in a complex heirarchy of framed pages, be sure to thoroughly test your pages before production release and refer to the API Reference for new usage if changes are required. (This will be very rare, and will not effect the vast majority of Floatbox users.)

If upgrading from a version 3 release, note the following changes:

Back to Index

Cache control

When upgrading to new versions of Floatbox (or any script), it's a good idea to implement a strategy for avoiding stale cached files in visitor's browsers. Without a cache control strategy, repeat visitors (and your own testing) may fail due to new version files mixing with old version modules coming from the browser cache.

The way to avoid cache problems is to modify the include paths being used for floatbox.css and floatbox.js, on every page that uses Floatbox. For example, when upgrading to version 5.0.0, you may want to place the new version files into a new folder called "floatbox_500", instead of using the default "floatbox" folder. The include lines will then become something like
<link type="text/css" rel="stylesheet" href="/floatbox_500/floatbox.css" />
<script type="text/javascript" src="/floatbox_500/floatbox.js"></script>
Using this strategy, there is no risk of mixing in old cached files from the previous version.

A slightly inferior but effective strategy is to continue to use the default "floatbox" folder while modifying the query string parameters on the include paths. For example:
<link type="text/css" rel="stylesheet" href="/floatbox/floatbox.css?v=500" />
<script type="text/javascript" src="/floatbox/floatbox.js?v=500"></script>
When changing versions, change the query string values to something (anything) new. Query string values used for loading floatbox.js will also be used in the dynamic loading of the Floatbox modules.

The reason why the query string approach is inferior to the folder name change approach is that the presence of query strings can interfere with the correct operation of some caching devices. Also, replacing everything in the default "floatbox" folder makes it more difficult to rollback to the previous version should that be necessary.

Note that options.js is always fetched from the server and never gets cached by browsers. This ensures that any changes made to the settings in options.js will get sent to repeat visitors.

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

IE8 needs our help

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 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 allowing choppy animation in IE8's slow native mode or forcing 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 //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 the showIE6EndOfLife setting in options.js or by using the configurator form to manage your default options.

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

Images: galleries and slideshows

Floatbox's default behaviour for showing images is to open a single image by itself. A gallery set can be created by assiging an identical 'group' option to two or more anchors that reference image files. Grouping image references adds navigation to the floatbox that lets the viewer move through the grouped set using 'previous' and 'next' navigation buttons, keyboard arrow keys, and/or index links. (Index links are described below in these instructions.) An 'item number' display also becomes available that will show 'image x of y' in the floatbox's frame area. See the 'Galleries' section of the Options Reference for option settings that control gallery set behaviours.

A gallery set can be shown as a slideshow by setting the 'doSlideshow' option to true. This will cause the gallery set to auto-advance through the images on an interval set by the 'slideInterval' option. See the 'Slideshows' section of the Options Reference for more options that control slideshow behaviour.

The easiest way to setup a gallery set is to take advantage of Floatbox's ability to propagate the 'floatbox' class and option settings from a containing div to the anchor elements in that div. Also note that anchors used to define gallery set members do not have to have clickable content such as a thumbnail image or text. The anchors can be empty. Here's an example:
<div class="floatbox" data-fb-options="group:1 doSlideshow:true">
  <a href="image1.jpg"><img src="thumb1.jpg" /></a>
  <a href="image2.jpg"></a>
  <a href="image3.jpg"></a>
</div>

Back to Index

HTML content: iFrames, AJAX, inline DIVs & direct

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', 'contentBackgroundColor', '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' );

Back to Index

Video: YouTube, Vimeo, DailyMotion & iFrame video

YouTube, Vimeo and DailyMotion offer video embedding services as iframe content rather than traditional flash-based object/embed elements. This allows delivery of a format suitable for the platform being used - e.g., flash content for desktop browsers, HTML5 video for iPhones and other non-flash agents. When showing videos from these online services, Floatbox will use the iframe content format, and thus reap the benefits of its flexibility.

Floatbox will also query the API services of these video providers and fetch information that can be used to auto-assign captions, determine default video dimensions, and get references to thumbnails that can be auto-inserted into links to the videos.

A quick way to understand Floatbox's video service capabilities, and to learn how to configure and use these capabilities, is to check out the 'iframed video embeds' section of the 'Multimedia' tab on the demo page. Here are some pointers on setting up video:

While somewhat complex, you can create your own locally served video sources to be presented as iframe embeds in Floatbox. An excellent guide for doing this can be found at //diveintohtml5.org/video.html. You may also want to use an iframe source for videos if you need more control over presentation or handling than direct-loading with a plugin will provide. To show an iframe video embed of your own, or one from a service other than the three discussed here, point the href to the iframe source and assign "type:video" in the options.

Back to Index

Multimedia: Flash, Silverlight, QuickTime, Windows Media & PDF

In addition to the iframe-based video services discussed above, Floatbox can directly load most multi-media content using available browser plugins. The content type, and the plugin to be used, is determined by the file extension on the href, unless explicitly assigned using the 'type' option. Recognized file extensions and the associated plugins are:

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.

Both Windows Media Player and Quicktime can display content of type mpg, mpeg, avi, m1v and mpe. For these file types, the visitor's browser will be queried for available plugins and the video will be shown with whichever plugin is present.

For flash content, floatbox assigns the following parameter default values: wmode=window, allowfullscreen=true, allowscriptaccess=always, scale=exactfit, play=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">...</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. The 'minFlashVersion' option, described in the Options Reference, can be used to set the version of the Flash plugin that must be present to show the content.

Quicktime default parameters are autoplay=true, bgcolor='', controller=true, kioskmode=true, loop=false, showlogo=false and scale=tofit. Windows Media Player default parameters are autoStart=1, showControls=1, showDisplay=0, showStatusBar=0, loop=0, animationAtStart=1 and transparentAtStart=0. All Silverlight control parameters are available and left as defaults. All supported parameters can be over-ridden with new values passed on the href or URL's querystring in the same manner as described for flash.

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

Flash content can be loaded directly from many online video services. To do this, get the embed source path and the video dimensions from the service's 'share' or 'embed' code. Be sure to use the 'legacy' embed path where both traditional flash embed and new iframe embed code is available. An example of direct-loading flash video from Vevo.com can be found on the demo page.

While YouTube, Vimeo and DailyMotion will each have their content displayed in iframe embed format by default, they can also be set to display as traditional flash plugin content by assigning "type:flash" to their options. The one advantage to taking this approach is that folks who don't have the Flash plugin loaded will get a link to the plugin download page translated to their localized language. In the case of YouTube, mobile Safari devices such as iPads may succeed in showing the 'type:flash' content by way of the device's YouTube app.

PDF content is supported but is somewhat problematic. Not everyone has the required PDF Reader Plugin installed, some folks may have their browsers configured to download rather than display the PDF document, and the PDF plugin does not install correctly for most browsers on Mac OS X. Because of these realities, display of PDFs in Floatbox cannot be said to be reliable across all browsers.

As is standard with all direct-loaded multi-media content, if the visitor does not have the required plugin, a notice and a link will be shown to plugin download page. For PDFs, there will be an additional link shown that can be used to open the PDF document in a new window, or to download it. This link is how Mac users can get to the PDF content when their plugins don't work.

Note that PDFs can also be displayed using the Flash plugin and the scribd.com online service (see the example on the Bonus2 tab of the demo page.)

When direct-loading PDF, numerous parameters can be specified as a query string following a hash character on the href path. The PDF sample on the Multimedia tab of the demo page shows the usage of parameters and opens a document that lists and describes the parameters that are available in most browsers.

On Mobile Safari devices, PDF documents will open in a new window by default because navigation and handling can be awkward inside a floatbox due to the absence of scrollbars. This behaviour can be over-ridden by setting "mobileNewWindow:false" in the options.

Back to Index

Let floatbox set content height

Floatbox can measure and set the dimensions for HTML content. 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 for ajax, inline and direct html is to constrain the 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. When no height is specified for these content types, the height will be measured and adjusted automatically. Not all content can be successfully measured, but most can. Scrollable and positioned elements in the content are the most likely to measure incorrectly.

Iframe content (normal web pages shown in a floatbox) that originates from the same domain as the host page can auto-set height too, but in a slightly different fashion. If measureHTML is set to 'yes' for the floatbox that is showing the iframe, or if measureHTML is set to 'auto' and the scrolling option is set to 'no', the floatbox height will be adjusted to the content height once the iframe completes loading. If you don't want a particular iframe to have its box height set automatically, set 'measureHTML:no'.

Cross-domain iframe content cannot be measured by script; consequently, box height cannot be automatically set for cross-domain iframe content.

Any content that uses a style of 'height:100%' will not measure successfully. Remove that style, or set the measureHTML option to 'no' for this content.

iPhones and other Mobile Safari based agents behave a little differently than what is described above for standard desktop browsers. Scrollbars are automatically turned off for all html content, the content's full height is measured, and the floatbox is displayed using the measured full content height. On touch devices, scrolling individual elements such as a floatbox is difficult and awkward, and even when the element is scrollable there is no visual indication of this (such as scrollbars) for the user. Displaying content at full height on these devices allows the content to be viewed using standard touch-drag gestures.

It can sometimes be useful to set the 'mobileNewWindow' option to true for large content that may not be suitable to show in a floatbox on a small mobile device screen. This will cause the floatbox content to open in a new browser window for Mobile Safari devices while retaining standard Floatbox display for all other agents.

Because cross-domain iframe content cannot be measured, default behaviour on Mobile Safari devices is for it to be opened in a new window. Set mobileNewWindow to false to override this default behaviour.

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. Tooltip source content is typical HTML and can come from any of Floatbox's supported HTML content sources: a hidden div, an AJAX fetch, an external page loaded as an iframe, or an encoded string of HTML assigned directly to the 'source' option.

Additional options available for tooltips are described in the options reference and include placement, attachToHost, moveWithMouse, 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.

Here's 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 contentBackgroundColor:#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", "fbPopright" or "fbPopcenter" 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="//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;//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

Header and Footer

The header and footer areas are transparent divs immediately above and below the floatbox frame area. These can be used to display content attached to, but outside of the box, such as alternate captions or any html. One possible use is for branding of the floatbox display, or attaching a company logo. See a footer in action under "Appearance Modifications" on the Images tab of the demo page.

Header and footer can be assigned in exactly the same way as captions, described above - as direct text, encoded html, or a reference to a hidden div. The names of the options to set are 'header' and 'footer'. Pulling header and footer content from a hidden div is probably the most common and trouble-free approach. Here's an example: <a href="somePage.html" data-fb-options="header:#myHeaderDiv">...</a>

Back to Index

Alternate Close button

The traditional Floatbox close button is displayed in the frame area as an 'english' or 'international' control (see the 'controlsType' option). An alternate close button is available but not shown by default. This close button is a round disc with an 'X' in it and is displayed at the top right or top left corner of the floatbox.

To enable this 'outerClose' button, set showOuterClose to true. Which corner it is displayed in is controlled by 'outerClosePos', which can be set to 'tr' or 'tl' and defaults to 'tr'. If you wish to always use the outerClose button and not the traditional close button, set both 'showClose:false' and 'showOuterClose:true' in options.js.

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:`colorTheme: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:`colorTheme: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.

The print link will not appear for Mobile Safari devices (iphones etc.) because handheld devices don't have printers.
Also, 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 set

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 corresponding 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 "controlsType" 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 and Colors

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 colorTheme option is specified, Floatbox defaults to black for images, white for html content, and blue for multi-media. The 'colorTheme' option can be set globally, per page, or per item to override these per-type defaults. The 'contentBackgroundColor' option sets the background color inside the floatbox content area and is useful if the displayed content has transparent areas.

Colors of various Floatbox components can be specified directly using color options. In addition to colorTheme and contentBackgroundColor, the following are available: boxColor, overlayColor, innerBorderColor, outerBorderColor, textColor and strongTextColor. These should be fairly self-explanatory from their names, but it is worth noting that 'textColor' applies to the 'item x of y' display, index links, and the 'open in a new window' link, while strongTextColor applies to captions, info and print links, and the new window link when it's hovered. The strongControls option sets the control's (close, prev/next, etc.) background images to their 'on' or hovered state which may help match them against a custom boxColor or textColor settings.

The floatbox frame area can be shown with a color gradient effect by assigning two css colors, separated by '|', to to the boxColor option. For example: boxColor:#123456|#edca98

Setting customized colors through options is best done by assigning the options to a class defined in fbClassOptions or the global classOptions in options.js and then placing that class name on the floatboxed links. See the Instruction sections on setting page-specific and site-wide options for details.

The 'custom' color setting is for creating and using your own customized color scheme via css. 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 controlsType to "international".

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 "//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 will likely need to surround the url with backquotes (`) so as not to break parsing of the option string.

You can set loadPageOnClose in the usual option setting way (fbPageOptions or the data-fb-options 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. The floatbox.js and floatbox.css files need 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 the floatbox files included in the deep iframe, the parent of that iframe, and the root document. (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 are not coming from the same domain and using the same protocol. (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 set the 'framed' option in an fbPageOptions definition, and ensure that the script element for this is placed above the include line for floatbox.js. Something like:
<script type="text/javascript">
fbPageOptions = {
  framed: true
};
</script>
<script type="text/javascript" src="/floatbox/floatbox.js"></script>

The second way to constain Floatbox to an iframe or frame document is to place "framed" in the querystring on the floatbox.js include source path. The include lines could then look like this:
<link type="text/css" rel="stylesheet" href="/floatbox/floatbox.css" />
<script type="text/javascript" src="/floatbox/floatbox.js?framed"></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" option set, 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 fb.activate 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 fb.activate 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.activate().

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.activate();
}
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.

A jQuery ajax fetch which launches fb.activate on completion could look like this: $.get('someURL.php', function(data) {
  $('.myXhrDiv').html(data);
  fb.activate();
});

But really, the simplest approach is to use floatbox's built-in ajax function and get fb.activate executed for free. fb.ajax({ source:'someURL.php', updateNode:'myXhrDiv' });

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

Or... as an alternative to getting the fb.activate 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.

Flash ActionScript can navigate to a URL on a click event, and a URL can be defined as a javascript action. This allows us to launch Floatbox using its javascript fb.start() API function as the target of an ActionScript navigation URL. Let's walk through setting that up.

Create a button in a flash object and give it a name. Let's call ours "button1". Now define a click action on that 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 the layer object.

First, we'll get the click action to simply show a javascript alert. On the layer's action panel, define an action like the following (this is ActionScript 2):
button1.onRelease = function() {
    getURL("javascript:alert(99)");
};

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:alert(99)");
    navigateToURL(request, "_self");
}
button1.addEventListener(MouseEvent.CLICK, myFunc);

The idea of using the simple alert is that we can test that the ActionScript is working first before involving Floatbox. Assuming that it's working fine, let's replace the alert with the fb.start() call to open a floatbox. Checking the API reference we see that the fb.start function takes two string parameters. The first is the path to the content to be shown and the second is any Floatbox options that we want to set for that content.

The AS2 code with the fb.start command will look something like this: button1.onRelease = function() {
    getURL("javascript:fb.start('gumby.jpg', 'roundCorners:none')");
};
And the equivalent AS3 code would be: function myFunc(event:MouseEvent):void {
    var request:URLRequest = new URLRequest("javascript:fb.start('gumby.jpg', 'roundCorners:none')");
    navigateToURL(request, "_self");
}
button1.addEventListener(MouseEvent.CLICK, myFunc);
I've used an arbitrary option here just to show where the options go. The options parameter is optional (no pun intended), and the simple fb.start('gumby.jpg') is perfectly legal.

That's it. Providing you've got the Floatbox files properly included on the page and the content reference in the fb.start command points to something that exists, you should have Floatbox opening from a click on a flash button. If it's not working, confirm that the simple alert(99) works from the click action. If it does, then try pasting and running the javascript action directly into a browser's address bar and running it from there. If javascript:fb.start('pathToYourContent') doesn't work from the address bar, you need to look for the reason why.

There's a couple of samples 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 an API to many of its internal functions that allows it be used as an effective javascript library in contexts beyond the base Floatbox functionality. 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