SqueezeBox - Expandable Lightbox (v1.1)

Project SqueezeBox - Expandable Lightbox Showcase SqueezeBox is an unobtrusive LightBox inspired overlay, for modal boxed content on your site. It’s a snap to show images but just as easy to use HTML elements, Ajax requests, iFrames, SWF movies and more.

Showcases:

Showcase “From Elements”

Content cloned or adopted from existing Elements.

The Action Happens Here

Clone me my content in a box! | More content please!
Content to grab:
I am the clone!

You can easily add elements to your XHTML and show them with a single click. The href points to the id, like usual. You can set the size and other options via link-attribute or during assigning the SqueezeBox.

I also am the clone!

If the content is too big for your box, it will overflow with scrollbars!

Because maybe you show your Terms of Use here.

Or another looong text with a lot of long words.

Simply pop it up in a new box and people have to read it ;-)

Sits so easy and even without extra Ajax request.

Hooray

This message loads when the you enter the site. It shows how to manually "fire" the SqueezeBox opener.

Cloning elements remove all the events, so sometimes grabbing content is a better solution. From here you can link to the clone, which switches the box to the next content.

JavaScript & MooTools

window.addEvent('domready', function() {
 
	/**
	 * You can provide preset options here ... if you want.
	 * You can SqueezeBox.assign without calling initialize, but
	 * not if you create the SqueezeBox with SqueezeBox.setContent
	 * (because initialize creates the used elements).
	 */
	SqueezeBox.initialize();
 
	/**
	 * Our welcome message, loaded when the site is loaded.
	 *
	 * We search our element by id and set the default content handler
	 * to adopt. Can be only used once, since the element is *moved* inside the box
	 * and deleted afterwards.
	 */
	SqueezeBox.open($('demo-target-adopt'), {
		handler: 'adopt',
		size: {x: 300, y: 200}
	});
 
	/**
	 * That CSS selector will find all <a> elements with the
	 * attribute rel="boxed" 	 * and href starting with a #.
	 *
	 * The second argument sets additional options
	 */
	SqueezeBox.assign($$('a[rel=boxed][href^=#]'), {
		size: {x: 200, y: 200}
	});
 
});

XHTML Markup

<a href="#demo-target-clone" rel="boxed">Clone me my content in a box!</a> |
<a href="#demo-target-clone-2" rel="boxed">More content please!</a>
 
<h5>Content to grab:</h5>
<div id="demo-target-clone">
	<h5>I am the clone!</h5>
	<p>
		You can easily add elements to your XHTML and show them with a single click.
		The href points to the id, like usual. You can set the size and other options
		via link-attribute or during assigning the SqueezeBox.
	</p>
</div>
<div id="demo-target-clone-2">
	<h5>I also am the clone!</h5>
	<p>
		If the content is too big for your box, it will overflow with scrollbars!
	</p>
	<p>
		Because maybe you show your Terms of Use here.
	</p>
	<p>
		Or another looong text with a lot of long words.
	</p>
	<p>
		Simply pop it up in a new box and people have to read it ;-)
	</p>
	<p>
		Sits so easy and even without extra Ajax request.
	</p>
</div>
<div id="demo-target-adopt">
	<h5>Hooray</h5>
	<p>
		This message loads when the you enter the site. It shows how to manually "fire"
		the SqueezeBox opener.
	</p>
	<p>
		Cloning elements remove all the events, so sometimes grabbing content
		is a better solution. From here you can
		<a href="#demo-target-clone" rel="boxed">link to the clone</a>, which
		switches the box to the next content.
	</p>
</div>

This example and the accompanying sources/assets are © 2008-2009 by Harald Kirschner and available under The MIT License. For debugging and profiling the scripts and their markup download Firefox and use addons like Firebug and Web Developer Toolbar.

Share it: Stumble it!Digg This!del.icio.us (167 Posts: )

discussion by DISQUS 349 Comments

Please use the support forums for discussing the project, asking questions or posting bug-fixes!

Sort:
Comments 1 – 20 of 349:
  • reply
    Avatar
    dlarah
    said 6 months ago (1 Point)
    I have a link working that opens an iframe in a squeezebox. I would like to be able to link to this page and have that same squeezebox open onload. Any ideas? Support forums have similar questions with no response. The forums look like an echo chamber to people seeking help. Thanks.
  • reply
    Avatar
    qwerty
    said 7 months ago (1 Point)
    I need to close an AJAX window when user clicks on some link.

    What function should I call?
  • reply
    Avatar
    Mike
    replied 7 months ago (1 Point)
    Try this:
    <a href="javascript:parent.SqueezeBox.close()">(Close box)</td>
  • reply
    Avatar
    qwerty
    replied 7 months ago (1 Point)
    Oh! Thanks a lot!
  • reply
    Avatar
    Max
    said 7 months ago (1 Point)
    Hi everybody!

    I need to close an AJAX window after a click on some link.

    What function should I call?
  • reply
    Avatar
    Gorky
    said 7 months ago (1 Point)
    please, help to fix this
    This page contains the following errors:

    error on line 8 at column 9: Opening and ending tag mismatch: img line 0 and div
    Below is a rendering of the page up to the first error.

    i get this error in google chrome. i've seen in comments, that you've fixed it for safari, can you tell me how to fix it? sorry for weak english =)
  • reply
    Avatar
    Name
    said 7 months ago (1 Point)
    please, help to fix this
    This page contains the following errors:

    error on line 8 at column 9: Opening and ending tag mismatch: img line 0 and div
    Below is a rendering of the page up to the first error.

    i get this error in google chrome. i've seen in comments, that you've fixed it for safari, can you tell me how to fix it? sorry for weak english =)
  • reply
    Avatar
    said 8 months ago (1 Point)
    Ok - this may be a really dumb question - but how do I get it to display w/out the close button (X in the upper right) besides just removing the image?
    Im kicking it off w/ this :
    SqueezeBox.open('display_alert', {
    size: {x: 300, y: 200},
    closeBtn: false,
    closable: false
    });
    But it still shows the X.
    Granted w/ the closable set to false - it does nothing, but is there an option to not display it?
  • reply
    Avatar
    zaxuz 1 Point
    replied 7 months ago (1 Point)
    you can hide the close button by changing its style in squeezbox.css. Like this:
    #sbox-btn-close {
    position: absolute;
    width: 30px;
    height: 30px;
    right: -15px;
    top: -15px;
    background: url(/images/squeezebox/closebox.png) no-repeat center;
    border: none;
    display: none; /* hide */
    }
  • reply
    Avatar
    Kevin
    said 8 months ago (1 Point)
    i think there is a bug in the ajax portion of your script. with Request.HTML the arguments for onSuccess are as follows: responseTree, responseElements, responseHTML, responseJavaScript. you are only accepting the first argument 'resp'. this works for some responses. but if you wrap your ajaxed html in a div...the styles seamed to be stripped from its inner elements.

    my tests responses were:

    <div>

    text IS NOT red

    </div>

    and

    text IS red



    would we maybe want to accept all the arguments for onSuccess and pass the responseHTML to applyContent? that initially seams to fix this problem for me, haven't looked too in depth though.
  • reply
    Avatar
    Max
    said 8 months ago (1 Point)
    Hello,
    I use SqueezeBox 1.0rc1 (buildin joomla 1.5.x)
    I cant do ajax request, my code:
    window.addEvent('domready', function() {
    SqueezeBox.initialize({});
    $$('a.modal').each(function(el) {
    el.addEvent('click', function(e) {
    new Event(e).stop();
    SqueezeBox.fromElement(el);
    });
    });
    });

    html:
    click me

    where is error? thanks.
  • reply
    Avatar
    Kay
    said 8 months ago (1 Point)
    Is there a way to make the page behind the squeezebox refresh once you close your squeezebox.

    Thanks
  • reply
    Avatar
    Mon
    replied 8 months ago (1 Point)
    @kay: yes, do something like the following:
    $$('a[rel=boxed]').each(function(item){
    item.addEvent('click', function(){
    return !SqueezeBox.fromElement(item,
    {
    handler:'iframe',
    onClose:function(){
    window.location.reload();
    }
    });
    });
    });
  • reply
    Avatar
    Mon
    said 8 months ago (1 Point)
    Hey, I don't know how relevant this is, as Firefox 3.5 is still not at release stage, but the box won't load in it. It stays at the loading animation. The content loads OK though..
    I am not sure if this is the cause, but firebug reports: "Use of getBoxObjectFor() is deprecated. Try to use element.getBoundingClientRect() if possible."
  • reply
    Avatar
    Mon
    replied 8 months ago (1 Point)
    disregard the above, it works now, probably since 3.5 reached official release.
  • reply
    Avatar
    jan
    said 8 months ago (1 Point)
    Can I get a content from specific element via this AJAX method? for instance I have a requet from one page (within the same domain) but do not want to retrieve whole page just one div element

    Is this possible?
  • reply
    Avatar
    mb2000inc
    said 9 months ago (1 Point)
    Safari is having issues with it... in an effort to get it to play a streaming video hosted on a friend's server, I had to embed a video onto a completely separate page... and call it through the squeezebox.... it works great in IE 7 & FireFox... but Safari is giving me the following error.

    This page contains the following errors:
    error on line 5 at column 24: Opening and ending tag mismatch: root line 0 and div
    Below is a rendering of the page up to the first error.

    Any thoughts?
  • reply
    Avatar
    Tyrone
    said 9 months ago (1 Point)
    progress.addEvent('click', function() {
    this.currentProgress.start($random(0, 100));
    }.bind(this));


    Funny guy, eh??
  • reply
    Avatar
    digitarald Site Owner
    replied 9 months ago (1 Point)
    Good catch, I forgot those debug lines. Stable 3.0 release fixes that ;)
  • reply
    Avatar
    Naomi
    said 10 months ago (1 Point)
    It's works perfectly. Thank you for this fabulous script. I hope the grouped images function will be out a day.
Comments 1 – 20 of 349:

Post your comment

Please use the support forums for discussing the project, asking questions or posting bug-fixes!


Internet Consultant & Contractor

I'm available to combine forces with you and your team to find the most simple, elegant and convenient web solutions . I await your call.

If you just like my work and want to say Thank You, donate via PayPal or Amazon Wish List.

Feed Subscribe Feeds

Developer Resources & Tools

Web Design Agency on Mallorca d/vision