1 dump('entering util/window.js\n');
3 if (typeof util == 'undefined') util = {};
4 util.window = function () {
5 JSAN.use('util.error'); this.error = new util.error(); this.win = window;
9 util.window.prototype = {
11 // list of open window references, used for debugging in shell
14 // list of Top Level menu interface window references
17 // list of documents for debugging. BROKEN
20 // Windows need unique names. This number helps.
21 'window_name_increment' : function() {
22 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
23 if (typeof data.window_name_increment == 'undefined') {
24 data.window_name_increment = 1;
26 data.window_name_increment++;
28 data.stash('window_name_increment');
29 return data.window_name_increment;
32 // This number gets put into the title bar for Top Level menu interface windows
33 'appshell_name_increment' : function() {
34 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
35 if (typeof data.appshell_name_increment == 'undefined') {
36 data.appshell_name_increment = 1;
38 data.appshell_name_increment++;
40 data.stash('appshell_name_increment');
41 return data.appshell_name_increment;
44 // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004
45 // Message-ID: <ckjh7a$18q1@ripley.netscape.com>
46 // Modified by Jason for Evergreen
47 'SafeWindowOpen' : function (url,title,features) {
50 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
51 netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead");
52 netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
53 netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
54 netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
56 const CI = Components.interfaces;
57 const PB = Components.classes["@mozilla.org/preferences-service;1"].getService(CI.nsIPrefBranch);
61 // pref 'dom.disable_open_during_load' is the main popup blocker preference
62 blocked = PB.getBoolPref("dom.disable_open_during_load");
63 if(blocked) PB.setBoolPref("dom.disable_open_during_load",false);
64 w = this.win.open(url,title,features);
66 this.error.sdump('D_ERROR','window.SafeWindowOpen: ' + E + '\n');
69 if(blocked) PB.setBoolPref("dom.disable_open_during_load",true);
74 'open' : function(url,title,features) {
75 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
76 if (!title) title = 'anon' + this.window_name_increment();
77 if (!features) features = 'chrome';
78 this.error.sdump('D_WIN',
79 'opening ' + url + ', ' + title + ', ' + features + ' from ' + this.win + '\n');
80 var w = this.SafeWindowOpen(url,title,features);
84 try { w.title = title; } catch(E) { dump('**'+E+'\n'); }
85 try { w.document.title = title; } catch(E) { dump('**'+E+'\n'); }
93 dump('exiting util/window.js\n');