1 /*** -*- Mode: Javascript; tab-width: 2;
3 The contents of this file are subject to the Mozilla Public
4 License Version 1.1 (the "License"); you may not use this file
5 except in compliance with the License. You may obtain a copy of
6 the License at http://www.mozilla.org/MPL/
8 Software distributed under the License is distributed on an "AS
9 IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 implied. See the License for the specific language governing
11 rights and limitations under the License.
13 The Original Code is Mozdev Group, Inc. code.
14 The Initial Developer of the Original Code is Pete Collins.
16 Portions created by Mozdev Group, Inc. are
17 Copyright (C) 2003 Mozdev Group, Inc. All
20 Contributor(s): Pete Collins <pete@mozdev.org)> (original author)
21 Henrik Gemal <http://gemal.dk>
25 /****************** Globals **********************/
27 if(typeof(JS_LIB_LOADED
)=='boolean') {
29 const JS_COMMONWINDOW_FILE
= "commonWindow.js";
30 const JS_COMMONWINDOW_LOADED
= true;
32 const JS_TOP_LEFT
= 0;
33 const JS_TOP_CENTER
= 1;
34 const JS_TOP_RIGHT
= 2;
36 const JS_MIDDLE_LEFT
= 3;
37 const JS_MIDDLE_CENTER
= 4;
38 const JS_MIDDLE_RIGHT
= 5;
40 const JS_BOTTOM_LEFT
= 6;
41 const JS_BOTTOM_CENTER
= 7;
42 const JS_BOTTOM_RIGHT
= 8;
43 const JS_UNINSTALL_URL
= JS_LIB_PATH
+ "install/uninstall.xul";
45 /****************** Common Dialog Object Class *********************/
47 function CommonWindow(aURL
, aWidth
, aHeight
)
49 if (typeof(aWidth
)=="number")
52 if (typeof(aHeight
)=="number")
55 if (typeof(aURL
)=="string")
62 CommonWindow
.prototype = {
67 mPosition
: JS_TOP_LEFT
,
79 set height (aHeight
) {
80 this.mHeight
= aHeight
;
91 case JS_MIDDLE_CENTER
:
93 x
= Math
.round(this.mWidth
/2);
94 y
= Math
.round(this.mHeight
/2);
96 var sY
= window
.screen
.height
/2;
97 var sX
= window
.screen
.width
/2;
99 jslibPrint("width: "+this.mWidth
);
100 jslibPrint("height: "+this.mHeight
);
102 jslibPrint("x: "+x
+"y: "+y
);
103 jslibPrint("sX: "+sX
+"sY: "+sY
);
107 jslibPrint("mX: "+this.mX
);
108 jslibPrint("mY: "+this.mY
);
112 this.mPosition
=JS_TOP_LEFT
;
113 jslibDebug("not implemented yet setting to JS_TOP_LEFT for now");
120 switch (this.mPosition
) {
137 case JS_MIDDLE_CENTER
:
138 rv
="JS_MIDDLE_CENTER";
141 case JS_MIDDLE_RIGHT
:
142 rv
="JS_MIDDLE_RIGHT";
149 case JS_BOTTOM_CENTER
:
150 rv
="JS_BOTTOM_CENTER";
153 case JS_BOTTOM_RIGHT
:
154 rv
="JS_BOTTOM_RIGHT";
168 openFullScreen : function () {
173 var h
= window
.screen
.height
;
174 var w
= window
.screen
.width
;
176 var win_prefs
= "chrome,dialog=no,width="+w
+
177 ",height="+h
+",screenX=0,screenY=0";
179 window
.openDialog(this.mURL
, "_blank", win_prefs
);
182 openWebTop : function () {
187 var h
= window
.screen
.height
;
188 var w
= window
.screen
.width
;
189 var win_prefs
= "chrome,popup,scrollbars=yes,width="+w
+
190 ",height="+h
+",screenX=0,screenY=0";
192 jslibDebug(this.mURL
+"_blank"+win_prefs
);
193 window
.openDialog(this.mURL
, "_blank", win_prefs
);
196 openUninstallWindow : function (aPackage
, aCallback
) {
199 jslibDebug("Please provide a package name to uninstall")
202 var win_prefs
= "chrome,dialog,dependent=no,resize=yes,screenX="+this.mX
+
204 ",width="+this.mWidth
+",height="+this.mHeight
;
206 window
.openDialog(JS_UNINSTALL_URL
, "_blank", win_prefs
, aPackage
, aCallback
);
209 openAbout : function () {
214 var h
= this.mHeight
;
216 var win_prefs
= "chrome,dialog,modal,dependent=no,resize=no,width="+w
+
217 ",height="+h
+",screenX="+this.mX
+",screenY="+this.mY
;
219 window
.openDialog(this.mURL
, "_blank", win_prefs
);
222 openSplash : function () {
224 jslibPrint("open splash . . . ");
229 var h
= this.mHeight
;
232 if (/Mac/g.test(window
.navigator
.platform
))
234 var win_prefs
= "chrome,dialog=no,titlebar=no,"+popup
+"width="+w
+
235 ",height="+h
+",screenX="+this.mX
+",screenY="+this.mY
;
237 window
.openDialog(this.mURL
, "_blank", win_prefs
);
245 var win_prefs
= "chrome,dialog=no,dependent=no,resize=yes,screenX="+this.mX
+",screenY="+this.mY
+
246 ",width="+this.mWidth
+",height="+this.mHeight
;
248 window
.openDialog(this.mURL
, "_blank", win_prefs
);
251 openDialog : function () {
256 var win_prefs
= "chrome,dialog,dependent=yes,resize=yes,screenX="+this.mX
+",screenY="+this.mY
+
257 ",width="+this.mWidth
+",height="+this.mHeight
;
259 window
.openDialog(this.mURL
, "_blank", win_prefs
);
262 openModalDialog : function () {
267 var win_prefs
= "chrome,dialog,dependent=no,modal,resize=yes,screenX="+this.mX
+",screenY="+this.mY
+
268 ",width="+this.mWidth
+",height="+this.mHeight
;
270 window
.openDialog(this.mURL
, "_blank", win_prefs
);
275 var wm
= jslibGetService("@mozilla.org/appshell/window-mediator;1",
276 "nsIWindowMediator");
278 var enumerator
= wm
.getEnumerator(null);
280 var winArray
= new Array();
281 while (enumerator
.hasMoreElements()) {
282 var domWindow
= enumerator
.getNext();
283 winArray
.push(domWindow
);
288 /********************* help *****************************
291 * Returns the methods in this object
293 * return values on success and failure
294 * aStr The methods in this object
297 * <string> = obj.help;
298 ****************************************************/
303 "\n\nFunction and Attribute List:\n" +
311 jslibDebug('*** load: '+JS_COMMONWINDOW_FILE
+' OK');
313 } // END BLOCK JS_LIB_LOADED CHECK
315 // If jslib base library is not loaded, dump this error.
317 dump("JS_BASE library not loaded:\n"
318 + " \tTo load use: chrome://jslib/content/jslib.js\n"
320 + " \tThen: include('chrome://jslib/content/xul/commonWindow.js');\n\n");
322 }; // END FileSystem Class