home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mozil06.zip / bin / chrome / toolkit.jar / content / global / dialogOverlay.js < prev    next >
Text File  |  2001-02-14  |  2KB  |  95 lines

  1. var doOKFunction = 0;
  2. var doCancelFunction = 0;
  3. var doButton2Function = 0;
  4. var doButton3Function = 0;
  5.  
  6. // call this from dialog onload() to allow ok and cancel to call your code
  7. // functions should return true if they want the dialog to close
  8. function doSetOKCancel(okFunc, cancelFunc, button2Func, button3Func )
  9. {
  10.     //dump("top.window.navigator.platform: " + top.window.navigator.platform + "\n");
  11.     
  12.     doOKFunction = okFunc;
  13.     doCancelFunction = cancelFunc;
  14.     doButton2Function = button2Func;
  15.     doButton3Function = button3Func;
  16. }
  17.  
  18. function doOKButton()
  19. {
  20.     var v = document.commandDispatcher.focusedElement;
  21.             
  22.     if (v && v.localName.toLowerCase() == 'textarea')
  23.       return;
  24.     
  25.     var close = true;
  26.     
  27.     if ( doOKFunction )
  28.         close = doOKFunction();
  29.     
  30.     if ( close )
  31.         top.window.close();
  32. }
  33.  
  34. function doCancelButton()
  35. {
  36.     var close = true;
  37.     
  38.     if ( doCancelFunction )
  39.         close = doCancelFunction();
  40.     
  41.     if ( close )
  42.         top.window.close();
  43. }
  44.  
  45. function doButton2()
  46. {
  47.     var close = true;
  48.     
  49.     if ( doButton2Function )
  50.         close = doButton2Function();
  51.     
  52.     if ( close )
  53.         top.window.close();
  54. }
  55.  
  56. function doButton3()
  57. {
  58.     var close = true;
  59.     
  60.     if ( doButton3Function )
  61.         close = doButton3Function();
  62.     
  63.     if ( close )
  64.         top.window.close();
  65. }
  66.  
  67. function moveToAlertPosition()
  68. {
  69.     var xOffset = opener.outerWidth/2 - window.outerWidth/2;
  70.     var yOffset = (opener.outerHeight *2)/10;
  71.     
  72.     xOffset  = xOffset> 0 ? xOffset : 0;
  73.     if ((opener.screenX + xOffset + window.outerWidth) > screen.availWidth)
  74.         xOffset = screen.availWidth - window.outerWidth - opener.screenX;
  75.     if((opener.screenY + yOffset + window.outerHeight) > screen.availHeight)
  76.             yOffset = screen.availHeight - window.outerHeight - opener.screenY;
  77.     xOffset = ( xOffset > 0 ) ? xOffset : 0;
  78.     yOffset = ( yOffset > 0 ) ? yOffset : 0;
  79.     dump( "Move window by " + xOffset + ","+yOffset+"\n");
  80.     dump( "screen x "+ opener.screenX +"screen y "+ opener.screenY +"\n");
  81.     window.moveTo( opener.screenX + xOffset, opener.screenY + yOffset );
  82.  
  83. }
  84.  
  85. function centerWindowOnScreen()
  86. {
  87.     var xOffset = screen.availWidth/2 - window.outerWidth/2;
  88.     var yOffset = screen.availHeight/2 - window.outerHeight/2; //(opener.outerHeight *2)/10;
  89.     
  90.     xOffset = ( xOffset > 0 ) ? xOffset : 0;
  91.   yOffset = ( yOffset > 0 ) ? yOffset : 0;
  92.     dump( "Move window by " + xOffset + ","+yOffset+"\n");
  93.     window.moveTo( xOffset, yOffset);
  94. }
  95.