!import
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
doSetOKCancel
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
doOKButton
18 function doOKButton()
19 {
20 var close = true;
21
22 if ( doOKFunction )
23 close = doOKFunction();
24
25 if (close && top)
26 top.window.close();
27 }
28
doCancelButton
29 function doCancelButton()
30 {
31 var close = true;
32
33 if ( doCancelFunction )
34 close = doCancelFunction();
35
36 if (close && top)
37 top.window.close();
38 }
39
doButton2
40 function doButton2()
41 {
42 var close = true;
43
44 if ( doButton2Function )
45 close = doButton2Function();
46
47 if (close && top)
48 top.window.close();
49 }
50
doButton3
51 function doButton3()
52 {
53 var close = true;
54
55 if ( doButton3Function )
56 close = doButton3Function();
57
58 if (close && top)
59 top.window.close();
60 }
61
moveToAlertPosition
62 function moveToAlertPosition()
63 {
64 // hack. we need this so the window has something like its final size
65 if (window.outerWidth == 1) {
66 dump("Trying to position a sizeless window; caller should have called sizeToContent() or sizeTo(). See bug 75649.\n");
67 sizeToContent();
68 }
69
70 var xOffset = (opener.outerWidth - window.outerWidth) / 2;
71 var yOffset = opener.outerHeight / 5;
72
73 var newX = opener.screenX + xOffset;
74 var newY = opener.screenY + yOffset;
75
76 // ensure the window is fully onscreen (if smaller than the screen)
77 if (newX < screen.availLeft)
78 newX = screen.availLeft + 20;
79 if ((newX + window.outerWidth) > (screen.availLeft + screen.availWidth))
80 newX = (screen.availLeft + screen.availWidth) - window.outerWidth - 20;
81
82 if (newY < screen.availTop)
83 newY = screen.availTop + 20;
84 if ((newY + window.outerHeight) > (screen.availTop + screen.availHeight))
85 newY = (screen.availTop + screen.availHeight) - window.outerHeight - 60;
86
87 window.moveTo( newX, newY );
88 }
89
centerWindowOnScreen
90 function centerWindowOnScreen()
91 {
92 var xOffset = screen.availWidth/2 - window.outerWidth/2;
93 var yOffset = screen.availHeight/2 - window.outerHeight/2; //(opener.outerHeight *2)/10;
94
95 xOffset = ( xOffset > 0 ) ? xOffset : 0;
96 yOffset = ( yOffset > 0 ) ? yOffset : 0;
97 window.moveTo( xOffset, yOffset);
98 }