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 promptService.confirmEx(window,"ALERT",
28 "Check this box to confirm this message",
37 function new_window(chrome,params) {
38 var name = self.name + '_' + ++mw.G['window_name_increment'];
39 var options = 'chrome,resizable=yes,scrollbars=yes,width=800,height=600,fullscreen=yes';
42 if (params['window_name']) { name = params.window_name; }
43 if (params['window_options']) { options = params.window_options; }
47 //var w = window.open(
48 var w = SafeWindowOpen(
55 w.parentWindow = self;
59 w.am_i_a_top_level_tab = false;
68 // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004
69 // Message-ID: <ckjh7a$18q1@ripley.netscape.com>
70 // Modified to return window handler, and do errors differently
71 function SafeWindowOpen(url,title,features)
75 netscape.security.PrivilegeManager
76 .enablePrivilege("UniversalXPConnect");
77 const CI = Components.interfaces;
79 Components.classes["@mozilla.org/preferences-service;1"]
80 .getService(CI.nsIPrefBranch);
85 // pref 'dom.disable_open_during_load' is the main popup
87 blocked = PB.getBoolPref("dom.disable_open_during_load");
89 PB.setBoolPref("dom.disable_open_during_load",false);
90 w = window.open(url,title,features);
94 //alert("SafeWindowOpen error:\n\n" + e);
98 PB.setBoolPref("dom.disable_open_during_load",true);
103 function register_AppShell(w) {
104 sdump('D_WIN',arg_dump(arguments,{0:true}));
105 mw.G.appshell_list.push(w);
108 function unregister_AppShell(w) {
109 sdump('D_WIN',arg_dump(arguments,{0:true}));
110 mw.G.appshell_list = filter_list( mw.G.appshell_list, function(e){return(e!=w);} );
113 function register_window(w) {
114 sdump('D_WIN',arg_dump(arguments,{0:true}));
115 mw.G.win_list.push(w);
119 function unregister_window(w) {
120 sdump('D_WIN',arg_dump(arguments,{0:true}));
121 mw.G.win_list = filter_list( mw.G.win_list, function(e){return(e!=w);} );
122 mw.G.last_win = mw.G.win_list[ mw.G.win_list.length - 1 ];
125 function close_all_windows() {
126 sdump('D_WIN',arg_dump(arguments));
128 for (var i in mw.G.appshell_list) {
129 sdump('D_WIN','\tconsidering ' + i + '...');
130 if (mw.G.win_list[i] != mw) {
131 sdump('D_WIN','closing');
132 var w = mw.G.win_list[i];
133 try { w.close(); } catch (E) {}
134 //unregister_window( w );
141 function register_document(d) {
142 sdump('D_WIN',arg_dump(arguments,{0:true}));
143 mw.G.doc_list[d.toString()] = d;
147 function unregister_document(d) {
148 sdump('D_WIN',arg_dump(arguments,{0:true}));
149 try { delete mw.G.doc_list[d.toString()]; } catch(E) { mw.G.doc_list[d.toString()] = false; }