1 sdump('D_WIN','Loading win.js\n');
4 // alert() replacement, intended to stop barcode scanners from "scanning through" the dialog
6 // get a reference to the prompt service component.
7 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
8 .getService(Components.interfaces.nsIPromptService);
10 // set the buttons that will appear on the dialog. It should be
11 // a set of constants multiplied by button position constants. In this case,
12 // three buttons appear, Save, Cancel and a custom button.
13 //var flags=promptService.BUTTON_TITLE_OK * promptService.BUTTON_POS_0 +
14 // promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1 +
15 // promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
16 var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0;
18 // display the dialog box. The flags set above are passed
19 // as the fourth argument. The next three arguments are custom labels used for
20 // the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a
21 // particular button. The last two arguments are for an optional check box.
23 sdump('D_WIN','s_alert: ' + s);
24 var rv = promptService.confirmEx(window,"ALERT",
28 "Check this box to confirm this message",
38 function yns_alert(s,title,b1,b2,b3,c) {
39 // alert() replacement, intended to stop barcode scanners from "scanning through" the dialog
41 // get a reference to the prompt service component.
42 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
43 .getService(Components.interfaces.nsIPromptService);
45 // set the buttons that will appear on the dialog. It should be
46 // a set of constants multiplied by button position constants. In this case,
47 // three buttons appear, Save, Cancel and a custom button.
48 //var flags=promptService.BUTTON_TITLE_OK * promptService.BUTTON_POS_0 +
49 // promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1 +
50 // promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
51 var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 +
52 promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1;
54 // display the dialog box. The flags set above are passed
55 // as the fourth argument. The next three arguments are custom labels used for
56 // the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a
57 // particular button. The last two arguments are for an optional check box.
59 sdump('D_WIN','yns_alert: ' + s);
60 var rv = promptService.confirmEx(window,title, s, flags, b1, b2, b3, c, check);
61 if (c && !check.value) {
63 return yns_alert(s,title,b1,b2,b3,c);
68 function new_window(chrome,params) {
69 var name = self.name + '_' + ++mw.G['window_name_increment'];
70 var options = 'chrome,resizable=yes,scrollbars=yes,width=800,height=600,fullscreen=yes';
73 if (params['window_name']) { name = params.window_name; }
74 if (params['window_options']) { options = params.window_options; }
78 //var w = window.open(
79 var w = SafeWindowOpen(
86 w.parentWindow = self;
90 w.am_i_a_top_level_tab = false;
99 // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004
100 // Message-ID: <ckjh7a$18q1@ripley.netscape.com>
101 // Modified to return window handler, and do errors differently
102 function SafeWindowOpen(url,title,features)
106 netscape.security.PrivilegeManager
107 .enablePrivilege("UniversalXPConnect");
108 const CI = Components.interfaces;
110 Components.classes["@mozilla.org/preferences-service;1"]
111 .getService(CI.nsIPrefBranch);
116 // pref 'dom.disable_open_during_load' is the main popup
117 // blocker preference
118 blocked = PB.getBoolPref("dom.disable_open_during_load");
120 PB.setBoolPref("dom.disable_open_during_load",false);
121 w = window.open(url,title,features);
125 //alert("SafeWindowOpen error:\n\n" + e);
129 PB.setBoolPref("dom.disable_open_during_load",true);
134 function register_AppShell(w) {
135 sdump('D_WIN',arg_dump(arguments,{0:true}));
136 mw.G.appshell_list.push(w);
139 function unregister_AppShell(w) {
140 sdump('D_WIN',arg_dump(arguments,{0:true}));
141 mw.G.appshell_list = filter_list( mw.G.appshell_list, function(e){return(e!=w);} );
144 function register_window(w) {
145 sdump('D_WIN',arg_dump(arguments,{0:true}));
146 mw.G.win_list.push(w);
148 sdump('D_TRACE_EXIT',arg_dump(arguments));
151 function unregister_window(w) {
152 sdump('D_WIN',arg_dump(arguments,{0:true}));
153 mw.G.win_list = filter_list( mw.G.win_list, function(e){return(e!=w);} );
154 mw.G.last_win = mw.G.win_list[ mw.G.win_list.length - 1 ];
155 sdump('D_TRACE_EXIT',arg_dump(arguments));
158 function close_all_windows() {
159 sdump('D_WIN',arg_dump(arguments));
161 for (var i in mw.G.appshell_list) {
162 sdump('D_WIN','\tconsidering ' + i + '...');
163 if (mw.G.appshell_list[i] != mw) {
164 sdump('D_WIN','closing');
165 var w = mw.G.appshell_list[i];
166 try { w.close(); } catch (E) {}
170 sdump('D_TRACE_EXIT',arg_dump(arguments));
174 function register_document(d) {
175 sdump('D_WIN',arg_dump(arguments,{0:true}));
176 mw.G.doc_list[d.toString()] = d;
180 function unregister_document(d) {
181 sdump('D_WIN',arg_dump(arguments,{0:true}));
182 try { delete mw.G.doc_list[d.toString()]; } catch(E) { mw.G.doc_list[d.toString()] = false; }