1 sdump('D_TRACE','Loading win.js\n');
4 sdump('D_WIN',arg_dump(arguments));
5 // alert() replacement, intended to stop barcode scanners from "scanning through" the dialog
7 // get a reference to the prompt service component.
8 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
9 .getService(Components.interfaces.nsIPromptService);
11 // set the buttons that will appear on the dialog. It should be
12 // a set of constants multiplied by button position constants. In this case,
13 // three buttons appear, Save, Cancel and a custom button.
14 //var flags=promptService.BUTTON_TITLE_OK * promptService.BUTTON_POS_0 +
15 // promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1 +
16 // promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
17 var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0;
19 // display the dialog box. The flags set above are passed
20 // as the fourth argument. The next three arguments are custom labels used for
21 // the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a
22 // particular button. The last two arguments are for an optional check box.
24 sdump('D_WIN','s_alert: ' + s);
25 var rv = promptService.confirmEx(window,"ALERT",
29 "Check this box to confirm this message",
39 function yns_alert(s,title,b1,b2,b3,c) {
40 sdump('D_WIN',arg_dump(arguments));
41 // alert() replacement, intended to stop barcode scanners from "scanning through" the dialog
43 // get a reference to the prompt service component.
44 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
45 .getService(Components.interfaces.nsIPromptService);
47 // set the buttons that will appear on the dialog. It should be
48 // a set of constants multiplied by button position constants. In this case,
49 // three buttons appear, Save, Cancel and a custom button.
50 //var flags=promptService.BUTTON_TITLE_OK * promptService.BUTTON_POS_0 +
51 // promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1 +
52 // promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
53 var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 +
54 promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1 +
55 promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
57 // display the dialog box. The flags set above are passed
58 // as the fourth argument. The next three arguments are custom labels used for
59 // the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a
60 // particular button. The last two arguments are for an optional check box.
62 sdump('D_WIN','yns_alert: ' + s);
63 var rv = promptService.confirmEx(window,title, s, flags, b1, b2, b3, c, check);
64 if (c && !check.value) {
66 return yns_alert(s,title,b1,b2,b3,c);
71 function new_window(chrome,params) {
72 sdump('D_WIN',arg_dump(arguments));
73 var name = ++mw.G['window_name_increment'];
74 var options = 'chrome,resizable=yes,scrollbars=yes,width=800,height=600,fullscreen=yes';
77 if (params['window_name']) { name = params.window_name; }
78 if (params['window_options']) { options = params.window_options; }
82 //var w = window.open(
83 var w = SafeWindowOpen(
90 w.parentWindow = self;
94 w.am_i_a_top_level_tab = false;
103 // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004
104 // Message-ID: <ckjh7a$18q1@ripley.netscape.com>
105 // Modified to return window handler, and do errors differently
106 function SafeWindowOpen(url,title,features)
108 sdump('D_WIN',arg_dump(arguments));
111 netscape.security.PrivilegeManager
112 .enablePrivilege("UniversalXPConnect");
113 const CI = Components.interfaces;
115 Components.classes["@mozilla.org/preferences-service;1"]
116 .getService(CI.nsIPrefBranch);
121 // pref 'dom.disable_open_during_load' is the main popup
122 // blocker preference
123 blocked = PB.getBoolPref("dom.disable_open_during_load");
125 PB.setBoolPref("dom.disable_open_during_load",false);
127 w = window.open(url,title,features);
131 //alert("SafeWindowOpen error:\n\n" + e);
135 PB.setBoolPref("dom.disable_open_during_load",true);
140 function register_AppShell(w) {
141 sdump('D_WIN',arg_dump(arguments,{0:true}));
142 mw.G.appshell_list.push(w);
145 function unregister_AppShell(w) {
146 sdump('D_WIN',arg_dump(arguments,{0:true}));
147 mw.G.appshell_list = filter_list( mw.G.appshell_list, function(e){return(e!=w);} );
150 function register_window(w) {
151 sdump('D_WIN',arg_dump(arguments,{0:false}));
152 mw.G.win_list.push(w);
154 sdump('D_TRACE_EXIT',arg_dump(arguments));
157 function unregister_window(w) {
158 sdump('D_WIN',arg_dump(arguments,{0:true}));
159 mw.G.win_list = filter_list( mw.G.win_list, function(e){return(e!=w);} );
160 mw.G.last_win = mw.G.win_list[ mw.G.win_list.length - 1 ];
161 sdump('D_TRACE_EXIT',arg_dump(arguments));
164 function close_all_windows() {
165 sdump('D_WIN',arg_dump(arguments));
167 for (var i in mw.G.appshell_list) {
168 sdump('D_WIN','\tconsidering ' + i + '...');
169 if (mw.G.appshell_list[i] != mw) {
170 sdump('D_WIN','closing');
171 var w = mw.G.appshell_list[i];
172 try { w.close(); } catch (E) {}
176 sdump('D_TRACE_EXIT',arg_dump(arguments));
179 function register_document(d) {
180 sdump('D_WIN',arg_dump(arguments,{0:true}));
181 mw.G.doc_list[d.toString()] = d;
185 function unregister_document(d) {
186 sdump('D_WIN',arg_dump(arguments,{0:true}));
187 try { delete mw.G.doc_list[d.toString()]; } catch(E) { mw.G.doc_list[d.toString()] = false; }