Solved

closing a modal window that is already using close once

Posted on 2009-05-14
7
442 Views
Last Modified: 2012-05-07
if you mouseover the 1st thumb here:

http://ctemps.cjehost.com/subgallery_4column_with_test.php#

you'll see "close window" in the upper right corner - that works.

however i need the "back to the gallery" link underneath the picture to do the same thing and i can't get it to fly. there are two parts to this: 1:css and 2: js.

It looks like i need to create another close function that uses another close-window class like close-window2 or something. i've tried this but i can't get both to work.
js:
 
var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
		var modal = "";
		modal += "<div class=\"modal-overlay\"></div>";
		modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
		modal += this.content;
		modal += "</div>";	
 
		$(this.parent).append(modal);
 
		$(".modal-window").append("<a class=\"close-window\"></a>");
		$(".close-window").click(function(){modalWindow.close();});
		$(".modal-overlay").click(function(){modalWindow.close();});
		
		
	}
};
 
css:
 
.close-window
{
position:absolute;
width:82px;
height:8px;
right:8px;
top:8px;
background:transparent url('../images/close-button.png') no-repeat scroll right top;
text-indent:-99999px;
overflow:hidden;
cursor:pointer;
opacity:.5;
filter: alpha(opacity=50);
-moz-opacity: 0.5;
}
.close-window:hover
{
opacity:.99;
filter: alpha(opacity=99);
-moz-opacity: 0.99;
}

Open in new window

0
Comment
Question by:phillystyle123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 

Author Comment

by:phillystyle123
ID: 24391538
i've got the thing COMPLETELYstyled - i just need to figure out how to make the "back to the gallery" text close the window - currently just the "close widnow" png closes the window


var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
		var modal = "";
		modal += "<div class=\"modal-overlay\"></div>";
		modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
		modal += this.content;
		modal += "</div>";	
 
		$(this.parent).append(modal);
 
		$(".modal-window").append("<a class=\"close-window\"></a>");
		$(".close-window").click(function(){modalWindow.close();});
		$(".modal-overlay").click(function(){modalWindow.close();});
		
		
	}
};

Open in new window

0
 

Author Comment

by:phillystyle123
ID: 24391546
oops -i need to create another block of code like this:


  $(".modal-window").append("<a class=\"close-window\"></a>");
                $(".close-window").click(function(){modalWindow.close();});
                $(".modal-overlay").click(function(){modalWindow.close();});
 call the class .close-window2 or something - i can't get it to work.

mouseover the 1st thumb on this page to see the modal window:
http://ctemps.cjehost.com/subgallery_4column_with_test.php#
0
 
LVL 18

Accepted Solution

by:
Pawel Witkowski earned 500 total points
ID: 24394111
Well to be honest - using IFRAME in that solution what you need is kind strange, but I assume that you need this for something. So well what you need to do is to call  top.modalWindow.close()  when you click on   back to gallery

instead of:

<a onmousedown="window.returnValue = this.href;modalWindow.close();" href="http://www.google.com">back to gallery</a>

do:

<a onmousedown="window.returnValue = this.href;top.modalWindow.close();" href="http://www.google.com">back to gallery</a>



should be fine as long as both of pages are on one domain:)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:phillystyle123
ID: 24394303
so close!

mouseover the 1st thumb to get modal window:

http://ctemps.cjehost.com/subgallery_4column_with_test.php

the modal window now closes! which is one thing i need  - but i'm not being redirected to "detail_vertical.php" - fyi - i tried http://google.com here as well and i wasn't redirected - no error just the modal closes and that's it.
<a onmousedown="window.returnValue = this.href;top.modalWindow.close();" href="detail_vertical.php">view larger</a>

Open in new window

0
 
LVL 18

Expert Comment

by:Pawel Witkowski
ID: 24395301
have you tried    top.window   ?:)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24402432
How about

                                                              <a onclick="window.returnValue = this.href;top.modalWindow.close();" href="detail_vertical.php">view larger</a>
0
 

Author Closing Comment

by:phillystyle123
ID: 31581740
that's exactly what i ended up with - thanks!  i had a similar question open about this - but it was about closing the modal window and redirecting to another page here are both:

view larger | back to gallery      
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question