Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Better popups


16 replies to this topic

#1 dreamscape

  • Community Member
  • 1,546 posts
  • Real Name:departing this world in search of another

Posted 11 April 2003, 04:16

many of my big images are quite large size... so I came up with this to show an "image loading" while the image was loading, so people did not begin to wonder what was going on since some of my large images are big. while I was at it, I also changed the resize function to center itself (the popup window) on the screen upon the image loading.

for a live view of what exactly this is, goto http://www.madmacgames.com/mac_game.php?products_id=29 and click on any of the thumbs (they are all pretty big).

This will be included as standard in my next update of the Dynamic MoPics module, but thought I'd share it here for everyone else as well.

1st you'll need these get 2 image files... save them as catalog/images/loading.gif and catalog/images/loaded.gif respectively:
[img]http://javascript.internet.com/img/resizable-viewer/loading.gif[/img]
[img]http://javascript.internet.com/img/resizable-viewer/loaded.gif[/img]

next in popup_image.php, change the javascript in the head from:
<script language="javascript"><!--

var i=0;

function resize() {

  if (navigator.appName == 'Netscape') i=40;

  if (document.images[0]) window.resizeTo(document.images[0].width +30, document.images[0].height+60-i);

  self.focus();

}

//--></script>
to
<script language="javascript"><!--

var i=0;

function resize() {

  if (navigator.appName == 'Netscape') i=10;

  if (document.images[1]) {

  imgHeight = document.images[1].height+60-i;

  imgWidth = document.images[1].width+30;

  var height = screen.height;

  var width = screen.width;

  var leftpos = width / 2 - imgWidth / 2;

  var toppos = height / 2 - imgHeight / 2; 

  window.moveTo(leftpos, toppos);  

  window.resizeTo(imgWidth, imgHeight);

  document.loading.src = 'images/loaded.gif';

  }

  self.focus();

}

//--></script>

and finally, replace
<body onload="resize();">
with
<body onload="resize();">

<div align="center"><img border="0" src="images/loading.gif" width="100" height="9" name="loading" onload="window.focus()"></div>

and that is all folks... upload the 2 new images and new popup_image.php. much better popups now :)

Ps.. I have also included the fix for netscape that was causing images to get cut off.
The only thing necessary for evil to flourish is for good men to do nothing
- Edmund Burke

#2 Ajeh

  • Community Member
  • 6,327 posts
  • Real Name:Linda McGrath
  • Location:Ohio

Posted 11 April 2003, 04:30

Handy addition ...

Is there a way to center the initial window while it is debating on the image to load?

On 1600x1200 ... I get a small window way over on the left while it is thinking about the image to load, then finally the real image comes up and the window centers on the screen.

#3 dreamscape

  • Community Member
  • 1,546 posts
  • Real Name:departing this world in search of another

Posted 11 April 2003, 05:25

Quote

Is there a way to center the initial window while it is debating on the image to load?

oh, there sure is... thanks for mentioning it... just put this in my site and it seems to working good.

in product_info.php, replace:
<script language="javascript"><!--

function popupWindow(url) {

  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizab
le=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=1
50')

}

//--></script>

wih:
<script language="javascript"><!--

  var height = screen.height;

  var width = screen.width;

  var leftpos = width / 2 - 50;

  var toppos = height / 2 - 50; 

function popupWindow(url) {

  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizab
le=yes,copyhistory=no,width=100,height=100,screenX=' + leftpos + ',screenY=' + toppos + ',top=' + toppos + ',left=' + leftpos)

}

//--></script>

The only thing necessary for evil to flourish is for good men to do nothing
- Edmund Burke

#4 Ajeh

  • Community Member
  • 6,327 posts
  • Real Name:Linda McGrath
  • Location:Ohio

Posted 11 April 2003, 05:38

Thanks for the fix!

Cannot wait to do the regular Mo Pics ... :wink:

#5 Waza04

  • Banned
  • 680 posts
  • Real Name:Warren Ashcroft
  • Gender:Male

Posted 11 April 2003, 20:13

Cool Thanks!!!

#6 hotnuts21

  • Community Member
  • 582 posts
  • Real Name:Paul McCann
  • Location:Aberystwyth UK

Posted 21 April 2003, 20:04

Great tip, thanx :)
Feel free to ask me for help
beep... beep....My Pager

#7 Waza04

  • Banned
  • 680 posts
  • Real Name:Warren Ashcroft
  • Gender:Male

Posted 21 April 2003, 22:29

I imagine that this works on all browsers....

:(

#8 Waza04

  • Banned
  • 680 posts
  • Real Name:Warren Ashcroft
  • Gender:Male

Posted 21 April 2003, 22:30

I imagine that this works on all browsers....

:(

#9 burt

  • Community Sponsor
  • 6,975 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 21 April 2003, 22:42

lowsrc

tep_image(DIR_WS_IMAGES . $products_values['products_image'], $products_values['products_name'], 'lowsrc=low_' . $products_values['products_image'])

Untested.

Made for this job. Means uploading another file (maybe a 1 bit b/w image or somesuch, but it would work perfectly.[/b]

#10 karcher

  • Community Member
  • 89 posts
  • Real Name:karen

Posted 28 April 2003, 15:04

Quote

tep_image(DIR_WS_IMAGES . $products_values['products_image'], $products_values['products_name'], 'lowsrc=low_' . $products_values['products_image'])

Seems much simpler Burt. Have you tested it?
K
.....................................................................
When the going get's tough,
the tough get going.

#11 burt

  • Community Sponsor
  • 6,975 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 28 April 2003, 15:09

I haven't...the only reason being is that I'm on a very fast connection so I wouldn't see the lowsrc version of the image...

I don't see why it wouldn't work though.

#12 dreamscape

  • Community Member
  • 1,546 posts
  • Real Name:departing this world in search of another

Posted 28 April 2003, 16:00

burt I can't see where that has anything to do with this thread...

the main changes were to center the popup on the users screen so that its not way up in corner.

what exactly is lowsrc?
The only thing necessary for evil to flourish is for good men to do nothing
- Edmund Burke

#13 karcher

  • Community Member
  • 89 posts
  • Real Name:karen

Posted 28 April 2003, 16:32

Josh,

If you go back to the beginning it was about modifying the popup window to display the loading animated gif.

In that regard, thanks, I have installed your contribution, it works well. As far as the loading gif thing, I'm going to make the loaded.gif image blank so that when the image is loaded you don't see the redundant loaded text.
K
.....................................................................
When the going get's tough,
the tough get going.

#14 dreamscape

  • Community Member
  • 1,546 posts
  • Real Name:departing this world in search of another

Posted 28 April 2003, 16:42

Quote

If you go back to the beginning it was about modifying the popup window to display the loading animated gif.

that was half of it... the other half was centering the window.

burt makes it sound like the lowsrc thing is a replacement for the whole thing, which it is not. as far as I can tell lowsrc does not center a window, and this is where I did not follow.
The only thing necessary for evil to flourish is for good men to do nothing
- Edmund Burke

#15 burt

  • Community Sponsor
  • 6,975 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 28 April 2003, 18:00

lowsrc is a valid html tag which loads up a Low Res version of a picture before it loads the "normal" res version.

so instead of the "loading..." graphic, I would prefer to use lowsrc. In all other respects your idea is great.

Pretty obvious that I didn't mention "center", because I had no better input to that than what you wrote in your first post in the thread...

#16 karcher

  • Community Member
  • 89 posts
  • Real Name:karen

Posted 28 April 2003, 18:36

Burt

Do you know from which version of the standard browsers this html tag works with? It sounds like something worth remembering.
K
.....................................................................
When the going get's tough,
the tough get going.

#17 burt

  • Community Sponsor
  • 6,975 posts
  • Real Name:G Burton
  • Gender:Male
  • Location:UK/DEV/on

Posted 28 April 2003, 18:43

Quote

Burt

Do you know from which version of the standard browsers this html tag works with?  It sounds like something worth remembering.

I know it worked 4 years ago, as I used to use it all the time (I had a 14.4 modem!!! ) :D

So whatever browser I used back then, which was most likely NS2 and IE2 I guess...