PDA

View Full Version : pop-up windows in CMotion Image Gallery II



southernbelle
06-07-2007, 05:10 AM
I am new to this so not sure if this is the right place, but can someone tell me how to change the background colour (want black) of the pop-up image windows in CMotion Image Gallery II?

Thanks

jscheuer1
06-07-2007, 05:39 AM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

southernbelle
06-08-2007, 05:35 AM
Here is the link - http://www.dynamicdrive.com/dynamicindex4/cmotiongallery2.htm

jscheuer1
06-08-2007, 06:55 AM
I am assuming that you are showing a larger sized image, not a page.

I really think that there are much better ways to present a larger sized image with this script than with a pop up. But, if that's the way that you want to go (that has been the default method with Cmotion from before I ever got involved with it, and is perhaps the easiest method), use this enlargeimage() function in motiongallery2.js instead of the default:


function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
try {
enlargeimage.popwin.close();
}
catch(e){};
var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to default height
if(screen.availWidth){
var cw=screen.availWidth/2, ch=screen.availHeight/2;
enlargeimage.atop=ch-parseInt(actualHeight)/2, enlargeimage.aleft=cw-parseInt(actualWidth)/2;
}
var winattributes="width="+actualWidth+",height="+actualHeight+(typeof enlargeimage.atop==='number'? ',top='+Math.min(enlargeimage.atop,150)+',left='+enlargeimage.aleft:'')+",resizable=yes"
enlargeimage.popwin=window.open("","popwin", winattributes);
enlargeimage.popwin.document.write('<body style="text-align:center;background-color:black;color:#dddddd;" onblur="self.close();" onload="document.images[0].style.marginTop=('+[parseInt(actualHeight)-30]+'/2-document.images[0].height/2)+\'px\';"><img src="'+path+'">');
enlargeimage.popwin.document.close();
enlargeimage.popwin.focus();
}

southernbelle
06-08-2007, 09:47 PM
Thank you, I tried the script that you provided, but although the background is black, the images are now positioned to one side and there is just a strip of black on the left, whereas the script I was using below seemed to show a balanced border all around when I specified the size of the images to be loaded - any suggestions, or any ideas for a better way of doing this, as you mentioned that there are better ways.

Your help is most appreciated.



function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to default height
var winattributes="width="+actualWidth+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

jscheuer1
06-09-2007, 02:26 AM
Works fine here:

http://home.comcast.net/~jscheuer1/side/cmotion2.htm

southernbelle
06-10-2007, 12:22 AM
Hi John

You are right, I hadn't added extra pixels onto the size of the image in the script in the body of the page, but once I did that it works great.

Thanks so much for your help.