Facebook-style Lightbox/Modalbox powered by jQuery and MooTools
Posted on March 12, 2010, Filled under MooTools, jQuery,
Bookmark it
Famspam is sharing Facebox, a Facebook-style Lightbox useful to display images, DIVs, or entire remote pages using AJAX. The download package comes with the JavaScript and CSS files, a loading image, a close label, four corners, and solid border images.
Implementation Example
1) Load Dependencies – First, you need to load jQuery before Facebox.
<script src="jquery.js" type="text/javascript"></script> <link href="facebox.css" media="screen" rel="stylesheet" type="text/css"/> <script src="facebox.js" type="text/javascript"></script>
2) Attach It onLoad – While calling facebox() on any anchor tag will do the trick, it’s easier to give your Faceboxy links a rel=”facebox” and hit them all onLoad.
jQuery(document).ready(function($) { $('a[rel*=facebox]').facebox() })
3) Open Image – Notice that rel has the value “facebox”
<a href="stairs.jpg" rel="facebox">text</a>
If you need assistance you can join Famspam’s Google Groups mailing list.
- Source & Examples: http://famspam.com/facebox/
Inspired by Facebook’s Modal Box (lightweight, subtle, and very stylish), Davis Walsh took Facebook’s imagery and CSS and combined it with MooTools’ awesome functionality to duplicate the effect.
The MooTools JavaScript
window.addEvent('domready',function() { /* hide using opacity on page load */ $('fb-modal').setStyles({ opacity:0, display:'block' }); /* hiders */ $('fb-close').addEvent('click',function(e) { $('fb-modal').fade('out'); }); window.addEvent('keypress',function(e) { if(e.key == 'esc') { $('fb-modal').fade('out'); } }); $(document.body).addEvent('click',function(e) { if($('fb-modal').get('opacity') == 1 && !e.target.getParent('.generic_dialog')) { $('fb-modal').fade('out'); } }); /* click to show */ $('fb-trigger').addEvent('click',function() { $('fb-modal').fade('in'); }); });
Do you wish to receive the latest updates as soon as they are posted? Get our RSS Feed or Subscribe to the Newsletter!
- March 12, 2010
- article by Gabriel C.
- Leave a reply!
Related Posts
Elastic jQuery Plugin Makes Your Textareas Grow Facebook Styleat August 21, 2009 with 1 comment
Image Reflection with jQuery, MooTools and script.aculo.usat January 11, 2009 with 3 comments
Highlight Elements in Script.aculo.us, jQuery and MooToolsat March 29, 2009 with 1 comment
How to use the Scroll Effect in jQuery, MooTools and Script.aculo.usat March 16, 2009 with 5 comments
Zoom Images using jQuery and MooToolsat December 21, 2008 with 2 comments


