You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

jQuery Tools / Expose - Make your HTML elements stand out

Demo

Start entering text on the fields below and you'll see the exposing effect:



The story

Expose is a JavaScript tool that exposes selected HTML elements on the page so that the surrounding elements will gradually fade out. The exposing effect was first introduced in the overlay tool. Usually the effect is an integral part of the program and cannot be used separately. This tool takes the idea of exposing a little further. It is a separate tool that can be used as a general purpose expose utility. You can use it for overlays, forms, images, videos or Flash objects.

You can use CSS to tweak the look of the semi-transparent surrounding layer which we refer to as the "mask".

This tool uses a simple and natural syntax and has an advanced programming API. You can extend it with callback methods or with your own plugins. This tool has a similar structure and feel as the other tools. Learn to use this tool and you will know how to use the rest.

This tool is a mature project and is actively maintained. The source code is clean, professional and easy to follow. It passes Douglas Crockford's JavaScript Verifier and it it doesn't assign any global variables. Active forums keep this tool alive and you can expect to see new releases coming out in the future.

Usage

We believe that the best way to learn is through demos. The following demos are fully documented and a standalone page is provided to get expose working on your site. It's really important to study the first demo "Minimal setup for expose" because it teaches you the basics of using the library.

Expose and Flowplayer demos

These demos show how to use a video player together with the expose tool:

Initialization

There are many other ways of using this tool than the demos provided here. It is important to realize that you can have many exposing instances on the page simultaneously and each of them can have different configurations. You can initialize the exposing effect without any configuration variables like this:

// initialize exposing for selected elements
var elements = $("div.to_be_exposed").expose();

With this JavaScript one-liner you have silently configured the exposing tool with the default dark blue background color #456 and now you need to call the load API method for the exposing to take effect. Here is how it happens:

// grab the exposing API (with another expose() call) and call load method
elements.expose().load();

Of course, you can do this with one single call like this:

// return api upon initialization and call load immediately. api is returned
var api = $("div.to_be_exposed").expose({api: true}).load();

expose Graphics

Download tooltip graphics

You can use our graphics as the basis for your design. You can freely change the design as you see fit. Click the image on the right to download a zip file. Before using the graphics, you should consult the User's Guide on how graphics can be used when designing the look and feel of the tools.

Here are a few examples of what is included in the zip file:


Configuration

The simplest form of configuration is to simply supply the background color as a string:

// a custom background color.
$("div.to_be_exposed").expose("#987ccc");

You can also supply the configuration as an object with many configuration variables. Here is the generic method of using expose:

// selects one or more elements to be exposed
$("JQUERY SELECTOR").expose({
	/* expose configuration goes here */

	// one configuration property
	color: '#ccc',

	// another property
	opacity: 0.7,

	// ... the rest of the configuration properties
});

You select one or more elements to be exposed with the jQuery selector. By default, the return value is a jQuery object associated with the selection. Here is a a full list of available configuration options:

property default description
color '#456' The background color of the mask. This will dramatically affect how it appears. If you supply a value of null here, you can control the background color with CSS. See the maskId property below for more information.
opacity 0.8 The transparency setting of the mask. A decimal value from 0 to 1. A bigger value means less transparency while a value of 0 is fully transparent (invisible).
loadSpeed 'slow' How fast the mask will appear. Possible values are 'slow', 'normal' and 'fast or you can supply this in milliseconds. For example, a value of 2000 will cause the the mask to appear in 2 seconds. By setting this to zero there is no animation and the mask appears immediately.
closeSpeed 'fast' How fast the mask disappears. Possible values are 'slow', 'normal' and 'fast or you can supply this in milliseconds. For example, a value of 2000 will cause the the mask to disappear in 2 seconds. by setting this to zero there is no animation and the mask disappears immediately.
maskId 'exposeMask' The mask is a normal DIV element placed at the bottom of your page whose size is automatically adjusted to cover the user's screen completely. You can style it normally with CSS just like any other element on the page. By default, the mask's id is set to exposeMask, but you can change this with the configuration option.
closeOnClick true Specifies whether the exposing disappears when the mask is clicked. By default, this is set to true.
closeOnEsc true Specifies whether exposing disappears when the ESC key is pressed from the keyboard. By default, this is set to true.
zIndex 9998 This is the z-index CSS property for the mask. The zIndex specifies the placement of the element along the z-axis of the document. The default zIndex value is very high, so it is unlikely that you will need to alter it; however, this value must be greater than the z-index of any other element on the page so that the overlay will always be visible when called.
api false When this tool is initialized (constructed), the return value is a jQuery object associated with the selector. By setting this property to true, the return value is the JavaScript API instead. If the selector returns multiple elements, the API of the last element will be returned. Read more about accessing the tool API for more information.
onBeforeLoad This callback function is triggered before the exposing effect. Returning false or calling event.preventDefault in the callback prevents exposing from occurring.
onLoad This callback function is triggered after exposing takes place.
onBeforeClose This callback function is triggered before exposing is closed. Returning false or calling event.preventDefault in the callback prevents it from closing.
onClose This callback function is triggered when expose is closed.

Using callback functions

Here is an example of an onBeforeLoad callback function. Inside any callback function the this variable is a pointer to the expose scripting API.

$("#myDiv").expose({

	// before exposing begins ...
	onBeforeLoad: function(event) {

		// grow the exposed elements smoothly by 100 pixels
		this.getExposed().animate({width: '+=100'});
	}
});

See the Using Callback Functions section in the User's Guide for a more detailed description about this important topic.

Scripting API

This tool has a useful API for scripters. A lot of effort has been put into it and you can enrich the exposing experience with it. You can get a handle to the API in numerous ways as described in the Users Manual. Here is an example of how to access the API:

// initialize expose and return the API
var api = $("#myDiv").expose({api: true});

// expose programmatically with this call
api.load()

// close the expose
api.close();

// register a callback function
api.onLoad(function() {
	// alter exposed elements upon loading
	this.getExposed().css({backgroundColor: 'black'});
});

Method listing

method return value description / example
load(event) API Performs exposing. Only available if expose has been initialized. An optional event object can be supplied as the argument and it will be handed to the callback functions. A convenient way to pass data to the callbacks.
close(event) API Closes exposing. An optional event object can be supplied as the argument and it will be handed to the callback functions. A convenient way to pass data to the callbacks.
isLoaded() boolean Returns true if exposing is active.
getMask() jQuery Returns the mask as a jQuery object. You can use jQuery methods such as css or animate to modify it.
getExposed() jQuery Returns exposed elements as a jQuery object.
getConf() Object Returns the exposing configuration.
onBeforeLoad(fn) API Registers a new callback function that is triggered before the exposing effect. Returning false or calling event.preventDefault in the callback prevents exposing from occurring. The callback is given as the argument. You can assign multiple onBeforeLoad listeners with this command.
onLoad(fn) API Registers a new callback function that is triggered after exposing takes effect. The callback is given as the argument. You can assign multiple onLoad listeners with this command.
onBeforeClose(fn) API Registers a new callback function that is triggered before exposing is closed. Returning false or calling event.preventDefault in the callback prevents it from closing. The callback is given as the argument. You can assign multiple onBeforeClose listeners with this command.
onClose(fn) API Registers a new callback function that is triggered when exposing is closed. The callback is given as the argument. You can assign multiple onClose listeners with this command.
bind(names, fn) API Register one or more callbacks to be triggered. See using callbacks for more information.
unbind(names) API Removes callback functions from the tool. See using callbacks for more information.