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 = self.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);
126 w = window.open(url,title,features);
130 //alert("SafeWindowOpen error:\n\n" + e);
134 PB.setBoolPref("dom.disable_open_during_load",true);
139 function register_AppShell(w) {
140 sdump('D_WIN',arg_dump(arguments,{0:true}));
141 mw.G.appshell_list.push(w);
144 function unregister_AppShell(w) {
145 sdump('D_WIN',arg_dump(arguments,{0:true}));
146 mw.G.appshell_list = filter_list( mw.G.appshell_list, function(e){return(e!=w);} );
149 function register_window(w) {
150 sdump('D_WIN',arg_dump(arguments,{0:true}));
151 mw.G.win_list.push(w);
153 sdump('D_TRACE_EXIT',arg_dump(arguments));
156 function unregister_window(w) {
157 sdump('D_WIN',arg_dump(arguments,{0:true}));
158 mw.G.win_list = filter_list( mw.G.win_list, function(e){return(e!=w);} );
159 mw.G.last_win = mw.G.win_list[ mw.G.win_list.length - 1 ];
160 sdump('D_TRACE_EXIT',arg_dump(arguments));
163 function close_all_windows() {
164 sdump('D_WIN',arg_dump(arguments));
166 for (var i in mw.G.appshell_list) {
167 sdump('D_WIN','\tconsidering ' + i + '...');
168 if (mw.G.appshell_list[i] != mw) {
169 sdump('D_WIN','closing');
170 var w = mw.G.appshell_list[i];
171 try { w.close(); } catch (E) {}
175 sdump('D_TRACE_EXIT',arg_dump(arguments));
178 function register_document(d) {
179 sdump('D_WIN',arg_dump(arguments,{0:true}));
180 mw.G.doc_list[d.toString()] = d;
184 function unregister_document(d) {
185 sdump('D_WIN',arg_dump(arguments,{0:true}));
186 try { delete mw.G.doc_list[d.toString()]; } catch(E) { mw.G.doc_list[d.toString()] = false; }