]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/components/nsOpenILS.js
Improve Firefox/XULRunner Support
[Evergreen.git] / Open-ILS / xul / staff_client / components / nsOpenILS.js
1 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
2
3 // This entire component is a singleton that exists solely to store data.
4
5 function nsOpenILS() {
6     this.wrappedJSObject = this;
7 }
8
9 nsOpenILS.prototype = {
10     classDescription: "OpenILS Data Cache",
11     classID:          Components.ID("{dc3e4b5f-c0f4-4b34-bc57-7b4099c3a5d6}"),
12     contractID:       "@open-ils.org/openils_data_cache;1",
13     QueryInterface:   XPCOMUtils.generateQI(),
14     _xpcom_factory:   {
15         singleton: null,
16         createInstance: function (aOuter, aIID) {
17             if (aOuter != null)
18                 throw Components.results.NS_ERROR_NO_AGGREGATION;
19             if (this.singleton == null)
20                 this.singleton = new nsOpenILS();
21             return this.singleton.QueryInterface(aIID);
22         },
23         getService: function (aIID) {
24             if (aOuter != null)
25                 throw Components.results.NS_ERROR_NO_AGGREGATION;
26             if (this.singleton == null)
27                 this.singleton = new nsOpenILS();
28             return this.singleton.QueryInterface(aIID);
29         }
30     },
31     data: {},
32     openMainEGWindow: function() {
33         var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
34                  .getService(Components.interfaces.nsIWindowMediator);
35         var targetWindow = wm.getMostRecentWindow("eg_main");
36         if (targetWindow != null) {
37             targetWindow.focus();
38         } else {
39             var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
40                      .getService(Components.interfaces.nsIWindowWatcher);
41             ww.openWindow(null, "chrome://open_ils_staff_client/content/main/main.xul", "_blank", "chrome,resizable,dialog=no", null);
42         }
43     },
44 };
45
46 if (XPCOMUtils.generateNSGetFactory)
47     var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsOpenILS]);
48 else
49     var NSGetModule = XPCOMUtils.generateNSGetModule([nsOpenILS]);