A jQuery plugin for focusing in on elements by blacking out everything else.
escape
.View Project On Github Just the JavaScript, Please
Trigger unmodal on a jQuery as you would with other plugins. There are a few extra options you might want to be aware of.
Before you start, include some CSS to style the boxes:
<style type='text/css'> .unmodal { background: #000; opacity: .5; filter: alpha(opacity = 50); } </style>
Or, if you want to get fancy (like on this page), use CSS transitions:
<style type='text/css'> .unmodal { background: #000; opacity: .5; filter: alpha(opacity = 50); -webkit-transition: opacity linear .3s; -moz-transition: opacity linear .3s; transition: opacity linear .3s; } .unmodal.unmodal-hidden { opacity:0; } </style>
// This will automatically black out everything except for all divs. // Notice that it does work even with more than one element $("div").unmodal(opts);
$("div").unmodal({ hide: function() { } });
The unmodal will clear by default if the user clicks on it, or presses escape. If you would like to trigger this programmatically, use $.unmodal.clear.
$("div").unmodal(); $.unmodal.clear();
If you ever need to trigger a refresh because of an external event, just call refresh - it is essentially a noop
if there is not current unmodal.
$("div").unmodal(); $("div").html("Changed content"); $.unmodal.refresh();
The plugin will listen to input
and resize
events so that as you type and change the size of the region, the unmodal
will resize correctly. There is a fix for IE and Firefox (which don't support the input event) using DOM Mutation Events.
Click on one of the geid cells and the plugin will blackout everything except all of the other cells. and is fast enough to handle dozens of elements, even in older browsers. It is smart enough to build many rectangles using non intersection rectangle detection.