toolkit/obsolete/content/dialogOverlay.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 var doOKFunction = 0;
     6 var doCancelFunction = 0;
     7 var doButton2Function = 0;
     8 var doButton3Function = 0;
    10 // call this from dialog onload() to allow ok and cancel to call your code
    11 // functions should return true if they want the dialog to close
    12 function doSetOKCancel(okFunc, cancelFunc, button2Func, button3Func )
    13 {
    14 	//dump("top.window.navigator.platform: " + top.window.navigator.platform + "\n");
    16 	doOKFunction = okFunc;
    17 	doCancelFunction = cancelFunc;
    18 	doButton2Function = button2Func;
    19 	doButton3Function = button3Func;
    20 }
    22 function doOKButton()
    23 {
    24 	var close = true;
    26 	if ( doOKFunction )
    27 		close = doOKFunction();
    29 	if (close && top)
    30 		top.window.close();
    31 }
    33 function doCancelButton()
    34 {
    35 	var close = true;
    37 	if ( doCancelFunction )
    38 		close = doCancelFunction();
    40 	if (close && top)
    41 		top.window.close();
    42 }
    44 function doButton2()
    45 {
    46 	var close = true;
    48 	if ( doButton2Function )
    49 		close = doButton2Function();
    51 	if (close && top)
    52 		top.window.close();
    53 }
    55 function doButton3()
    56 {
    57 	var close = true;
    59 	if ( doButton3Function )
    60 		close = doButton3Function();
    62 	if (close && top)
    63 		top.window.close();
    64 }
    66 function moveToAlertPosition()
    67 {
    68     // hack. we need this so the window has something like its final size
    69     if (window.outerWidth == 1) {
    70         dump("Trying to position a sizeless window; caller should have called sizeToContent() or sizeTo(). See bug 75649.\n");
    71         sizeToContent();
    72     }
    74 	var xOffset = (opener.outerWidth - window.outerWidth) / 2;
    75 	var yOffset = opener.outerHeight / 5;
    77 	var newX = opener.screenX + xOffset;
    78 	var newY = opener.screenY + yOffset;
    80 	// ensure the window is fully onscreen (if smaller than the screen)
    81 	if (newX < screen.availLeft)
    82 		newX = screen.availLeft + 20;
    83 	if ((newX + window.outerWidth) > (screen.availLeft + screen.availWidth))
    84 		newX = (screen.availLeft + screen.availWidth) - window.outerWidth - 20;
    86 	if (newY < screen.availTop)
    87 		newY = screen.availTop + 20;
    88 	if ((newY + window.outerHeight) > (screen.availTop + screen.availHeight))
    89 		newY = (screen.availTop + screen.availHeight) - window.outerHeight - 60;
    91 	window.moveTo( newX, newY );
    92 }
    94 function centerWindowOnScreen()
    95 {
    96 	var xOffset = screen.availWidth/2 - window.outerWidth/2;
    97 	var yOffset = screen.availHeight/2 - window.outerHeight/2; //(opener.outerHeight *2)/10;
    99 	xOffset = ( xOffset > 0 ) ? xOffset : 0;
   100   yOffset = ( yOffset > 0 ) ? yOffset : 0;
   101 	window.moveTo( xOffset, yOffset);
   102 }

mercurial