/    Sign up×
Community /Pin to ProfileBookmark

Managing Multiple Overlay Boxes (Named Windows?)

Hi

I am trying to create a page that has a couple of pop-up overlay boxes from a couple of links, Everything is working ok I think except for a problem on a browser resize.

The original code I found : ( [url]http://kalyanchakravarthy.net/?p=208[/url] ) was created or only one window so the resize code controls both windows, when I think need each one controlled separately. The resize code will make a closed overlay box appear.

Any suggestions or help will be greatly appreciated. THANK YOU

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />

<script language=”javascript” src=”jquery-1.2.6.min.js”></script>
<!–script language=”javascript” src=”jquery-schedule-overlay.js”></script–>
<style type=”text/css”>

.bgCover { background:#000; position:absolute; left:0; top:0; display:none; overflow:hidden }

.overlayBox {
border:1px solid #09F;
position:absolute;
display:none;
width:730px;
height:600px;
background:#fff;
}

.overlayBoxb {
border:1px solid #09F;
position:absolute;
display:none;
width:730px;
height:600px;
background:#fff;
}

.overlayContent {
padding:0px;
}

.overlayContentb {
padding:0px;
}

.closeLink {
float:right;
color:red;
text-decoration:none;
}
a:hover { text-decoration:none; }

</style></head>

<body>

<div class=”bgCover”>&nbsp;</div>

<a href=”#” class=”launchLink”>Launch Window</a>

<div class=”overlayBox”>
<div class=”overlayContent”>
<a href=”#” class=”closeLink”>Close</a>

<img src=”Session-A-mock-up.jpg” alt=”Session A Schedule ” />
</div></div>

<br /><br />

<a href=”#” class=”launchLinkb”>Launch Window 2</a>

<div class=”overlayBoxb”>
<div class=”overlayContentb”>
<a href=”#” class=”closeLink”>Close</a>

<img src=”Session-B-mock-up.jpg” alt=”Session B Schedule “/>
</div></div>

<script language=”javascript”>

function showOverlayBox() {

//if box is not set to open then don’t do anything
if( window.isOpen == false ) return;

// set the properties of the overlay box, the left and top positions
$(‘.overlayBox’).css({
display:’block’,
left? $(window).width() – $(‘.overlayBox’).width() )/2,
top? $(window).height() – $(‘.overlayBox’).height() )/2 -20,
position:’absolute’
});

// set the window background for the overlay. i.e the body becomes darker
$(‘.bgCover’).css({
display:’block’,
width: $(window).width(),
height:$(window).height(),
});

function showOverlayBoxb() {

windowb=window.open;
//if box is not set to open then don’t do anything
if( windowb.isOpen == false ) return;

// set the properties of the overlay box, the left and top positions
$(‘.overlayBoxb’).css({
display:’block’,
left? $(window).width() – $(‘.overlayBoxb’).width() )/2,
top? $(window).height() – $(‘.overlayBoxb’).height() )/2 -20,
position:’absolute’
});
// set the window background for the overlay. i.e the body becomes darker
$(‘.bgCover’).css({
display:’block’,
width: $(window).width(),
height:$(window).height(),
});
}

function doOverlayOpen() {
//set status to open
isOpen = true;
showOverlayBox();
$(‘.bgCover’).css({opacity:0}).animate( {opacity:0.5, backgroundColor:’#000′} );
// dont follow the link : so return false.
return false;
}

function doOverlayOpenb() {
//set status to open
isOpen = true;
showOverlayBoxb();
$(‘.bgCover’).css({opacity:0}).animate( {opacity:0.5, backgroundColor:’#000′} );
// dont follow the link : so return false.
return false;
}

function doOverlayClose() {
//set status to closed
isOpen = false;
$(‘.overlayBox,.overlayBoxb’).css( ‘display’, ‘none’ );
// now animate the background to fade out to opacity 0
// and then hide it after the animation is complete.
$(‘.bgCover’).animate( {opacity:0}, null, null, function() { $(this).hide(); } );
}

// if window is resized then reposition the overlay box

$(window).bind(‘resize’,showOverlayBox) ;
$(window).bind(‘resize’,showOverlayBoxb) ;

// activate when the link with class launchLink is clicked
$(‘a.launchLink’).click( doOverlayOpen );
// activate when the link with class launchLink2 is clicked
$(‘a.launchLinkb’).click( doOverlayOpenb );
// close it when closeLink is clicked
$(‘a.closeLink’).click( doOverlayClose );

</script>

</body>
</html>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Commander_Hot_D spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...