1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/obsolete/content/dialogOverlay.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,102 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +var doOKFunction = 0; 1.9 +var doCancelFunction = 0; 1.10 +var doButton2Function = 0; 1.11 +var doButton3Function = 0; 1.12 + 1.13 +// call this from dialog onload() to allow ok and cancel to call your code 1.14 +// functions should return true if they want the dialog to close 1.15 +function doSetOKCancel(okFunc, cancelFunc, button2Func, button3Func ) 1.16 +{ 1.17 + //dump("top.window.navigator.platform: " + top.window.navigator.platform + "\n"); 1.18 + 1.19 + doOKFunction = okFunc; 1.20 + doCancelFunction = cancelFunc; 1.21 + doButton2Function = button2Func; 1.22 + doButton3Function = button3Func; 1.23 +} 1.24 + 1.25 +function doOKButton() 1.26 +{ 1.27 + var close = true; 1.28 + 1.29 + if ( doOKFunction ) 1.30 + close = doOKFunction(); 1.31 + 1.32 + if (close && top) 1.33 + top.window.close(); 1.34 +} 1.35 + 1.36 +function doCancelButton() 1.37 +{ 1.38 + var close = true; 1.39 + 1.40 + if ( doCancelFunction ) 1.41 + close = doCancelFunction(); 1.42 + 1.43 + if (close && top) 1.44 + top.window.close(); 1.45 +} 1.46 + 1.47 +function doButton2() 1.48 +{ 1.49 + var close = true; 1.50 + 1.51 + if ( doButton2Function ) 1.52 + close = doButton2Function(); 1.53 + 1.54 + if (close && top) 1.55 + top.window.close(); 1.56 +} 1.57 + 1.58 +function doButton3() 1.59 +{ 1.60 + var close = true; 1.61 + 1.62 + if ( doButton3Function ) 1.63 + close = doButton3Function(); 1.64 + 1.65 + if (close && top) 1.66 + top.window.close(); 1.67 +} 1.68 + 1.69 +function moveToAlertPosition() 1.70 +{ 1.71 + // hack. we need this so the window has something like its final size 1.72 + if (window.outerWidth == 1) { 1.73 + dump("Trying to position a sizeless window; caller should have called sizeToContent() or sizeTo(). See bug 75649.\n"); 1.74 + sizeToContent(); 1.75 + } 1.76 + 1.77 + var xOffset = (opener.outerWidth - window.outerWidth) / 2; 1.78 + var yOffset = opener.outerHeight / 5; 1.79 + 1.80 + var newX = opener.screenX + xOffset; 1.81 + var newY = opener.screenY + yOffset; 1.82 + 1.83 + // ensure the window is fully onscreen (if smaller than the screen) 1.84 + if (newX < screen.availLeft) 1.85 + newX = screen.availLeft + 20; 1.86 + if ((newX + window.outerWidth) > (screen.availLeft + screen.availWidth)) 1.87 + newX = (screen.availLeft + screen.availWidth) - window.outerWidth - 20; 1.88 + 1.89 + if (newY < screen.availTop) 1.90 + newY = screen.availTop + 20; 1.91 + if ((newY + window.outerHeight) > (screen.availTop + screen.availHeight)) 1.92 + newY = (screen.availTop + screen.availHeight) - window.outerHeight - 60; 1.93 + 1.94 + window.moveTo( newX, newY ); 1.95 +} 1.96 + 1.97 +function centerWindowOnScreen() 1.98 +{ 1.99 + var xOffset = screen.availWidth/2 - window.outerWidth/2; 1.100 + var yOffset = screen.availHeight/2 - window.outerHeight/2; //(opener.outerHeight *2)/10; 1.101 + 1.102 + xOffset = ( xOffset > 0 ) ? xOffset : 0; 1.103 + yOffset = ( yOffset > 0 ) ? yOffset : 0; 1.104 + window.moveTo( xOffset, yOffset); 1.105 +}