Solved

closing a modal window that is already using close once

Posted on 2009-05-14
7
438 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
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Obsolete font tag need to convert to CSS 3 37
disable and enable textboxes in dataTable 7 32
Put POST values into cookies. 14 35
Calculating percentage 2 32
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
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).

730 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