home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 May / comcd0502.iso / homepage / special / javascript / 10_01 / jscript / popupfly / utilpopupflytest.js < prev   
Encoding:
JavaScript  |  2001-07-30  |  4.4 KB  |  153 lines

  1. // CREDITS:
  2. // Flying Popup Generator
  3. // by Urs Dudli and Peter Gehrig 
  4. // Copyright (c) 2001 Peter Gehrig and Urs Dudli. All rights reserved.
  5. // Permission given to use the script provided that this notice remains as is.
  6. // Additional scripts can be found at http://www.24fun.com
  7. // info@24fun.com
  8. // 4/6/2001
  9.  
  10. // IMPORTANT: 
  11. // If you add this script to a script-library or script-archive 
  12. // you have to add a link to http://www.24fun.com on the webpage 
  13. // where this script Script will be running.
  14.  
  15. // INSTRUCTIONS: 
  16. // Got to http://www.24fun.com, open category 'utility' and
  17. // generate your own Flying Popup with the new Flying Popup Generator
  18.  
  19. var popwindow
  20. var thistoolbar
  21. var thislocation
  22. var thisdirectories
  23. var thisstatus
  24. var thismenubar
  25. var thisscrollbars
  26. var thisresizable
  27. var thisurl
  28. var thiswidth
  29. var thisheight
  30. var thisdirection
  31. var thistopposition
  32. var thisleftposition
  33. var pause=20
  34. var stepfactor=20
  35. var stepx
  36. var stepy
  37.  
  38. var marginpadding=23
  39.  
  40. var startleft=0
  41. var endleft=0
  42. var starttop=0
  43. var endtop=0
  44.  
  45. var marginleft=0
  46. var margintop=0
  47. var marginright
  48. var marginbottom
  49. var timer
  50.  
  51.  
  52. function configurepopupbylink(whatdirection) {
  53.     thistoolbar=tistoolbar
  54.     thislocation=tislocation
  55.     thisdirectories=tisdirectories
  56.     thisstatus=tisstatus
  57.     thismenubar=tismenubar
  58.     thisscrollbars=tisscrollbars
  59.     thisresizable=tisresizable
  60.     thisurl=tisurl
  61.     thiswidth=tiswidth
  62.     thisheight=tisheight
  63.     thisdirection=whatdirection
  64.     openpopup()
  65. }
  66.  
  67. function configurepopupbyform() {
  68.     thistoolbar=document.wizard.popuptoolbar[document.wizard.popuptoolbar.selectedIndex].value
  69.     thislocation=document.wizard.popuplocation[document.wizard.popuplocation.selectedIndex].value
  70.     thisdirectories=document.wizard.popupdirectories[document.wizard.popupdirectories.selectedIndex].value
  71.     thisstatus=document.wizard.popupstatus[document.wizard.popupstatus.selectedIndex].value
  72.     thismenubar=document.wizard.popupmenubar[document.wizard.popupmenubar.selectedIndex].value
  73.     thisscrollbars=document.wizard.popupscrollbars[document.wizard.popupscrollbars.selectedIndex].value
  74.     thisresizable=document.wizard.popupresizable[document.wizard.popupresizable.selectedIndex].value
  75.     thisurl=document.wizard.popupurl.value
  76.     thiswidth=document.wizard.popupwidth.value
  77.     thisheight=document.wizard.popupheight.value
  78.     thisdirection=document.wizard.popupdirection[document.wizard.popupdirection.selectedIndex].value
  79.     makecode()
  80.     openpopup()
  81. }
  82.  
  83. function openpopup() {
  84.  
  85.     marginright=screen.width
  86.     marginbottom=screen.height
  87.     
  88.     if (thisdirection=="horitop") {
  89.         startleft=marginleft
  90.         endleft=marginright-thiswidth-marginpadding
  91.         starttop=marginpadding
  92.         endtop=starttop
  93.         stepx=stepfactor
  94.         stepy=0    
  95.     }
  96.     if (thisdirection=="horimiddle") {
  97.         startleft=marginleft
  98.         endleft=marginright-thiswidth-marginpadding
  99.         starttop=Math.round((marginbottom-thisheight)/2)
  100.         endtop=starttop
  101.         stepx=stepfactor
  102.         stepy=0    
  103.     }
  104.     if (thisdirection=="horibottom") {
  105.         startleft=marginleft
  106.         endleft=marginright-thiswidth-marginpadding
  107.         starttop=marginbottom-thisheight-2*marginpadding
  108.         endtop=starttop
  109.         stepx=stepfactor
  110.         stepy=0    
  111.     
  112.     }
  113.     if (thisdirection=="vertileft") {
  114.         startleft=marginleft
  115.         endleft=startleft
  116.         starttop=marginpadding
  117.         endtop=marginbottom-thisheight-2*marginpadding
  118.         stepx=0
  119.         stepy=stepfactor    
  120.     }
  121.     if (thisdirection=="vertimiddle") {
  122.         startleft=Math.round((marginright-thiswidth)/2)
  123.         endleft=startleft
  124.         starttop=marginpadding
  125.         endtop=marginbottom-thisheight-2*marginpadding
  126.         stepx=0
  127.         stepy=stepfactor    
  128.     }
  129.     if (thisdirection=="vertiright") {
  130.         startleft=marginright-thiswidth-marginpadding
  131.         endleft=marginright-thiswidth-marginpadding
  132.         starttop=marginpadding
  133.         endtop=marginbottom-thisheight-2*marginpadding
  134.         stepx=0
  135.         stepy=stepfactor    
  136.     }
  137.     popwindow=window.open("popupwindow.html", "newwindow", "toolbar="+thistoolbar+",location="+thislocation+",directories="+thisdirectories+",status="+thisstatus+",menubar="+thismenubar+",scrollbars="+thisscrollbars+",resizable="+thisresizable+",width="+thiswidth+",height="+thisheight+",top="+starttop+",left="+startleft+"")
  138.     movewindow()
  139.     popwindow.focus()
  140. }
  141.  
  142. function movewindow() {
  143.     if ((starttop<=endtop) && (startleft<=endleft)){
  144.         popwindow.moveTo(startleft,starttop)
  145.         startleft+=stepx
  146.         starttop+=stepy
  147.         timer=setTimeout("movewindow()",pause)
  148.     }
  149.     else {
  150.         clearTimeout(timer)
  151.         popwindow.moveTo(endleft,endtop)
  152.     }
  153. }