]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/staff_client/chrome/content/evergreen/opac/opac.js
d2be8fb2cca2c2e683922015802407e452b0a3b8
[Evergreen.git] / Evergreen / staff_client / chrome / content / evergreen / opac / opac.js
1 sdump('D_OPAC','Loading opac.js\n');
2
3 var OPAC_URL = "http://spacely.georgialibraries.org:8080/";
4 var opac_page_thing;
5
6
7 /* listen for page changes */
8 var progressListener = new Object();
9 progressListener.onProgressChange       = function(){}
10 progressListener.onLocationChange       = function(){}
11 progressListener.onStatusChange         = function(){}
12 progressListener.onSecurityChange       = function(){}
13 progressListener.QueryInterface = function qi(iid) { return this; }
14 progressListener.onStateChange = 
15         function client_statechange ( webProgress, request, stateFlags, status) {
16                 if( stateFlags == 131088 ) set_opac_vars();
17 };
18
19
20 /* init the opac */
21 function opac_init(p) {
22         sdump('D_OPAC',"Initing OPAC\n");
23         opac_page_thing = p;
24         p.opac_iframe = p.w.document.getElementById('opac_opac_iframe');
25         p.opac_iframe.addProgressListener(progressListener, 
26                 Components.interfaces.nsIWebProgress.NOTIFY_ALL );
27         p.opac_iframe.setAttribute("src", OPAC_URL) 
28 }
29
30 /* shoves data into the OPAC's space */
31 function set_opac_vars() {
32         var p = opac_page_thing;
33         p.opac_iframe = p.w.document.getElementById('opac_opac_iframe');
34         p.opac_iframe.contentWindow.IAMXUL = true;
35         p.opac_iframe.contentWindow.makeXULLink = makeXULLink;
36         p.opac_iframe.contentWindow.xulG = mw.G;
37 }
38
39 /* build a XUL specific link within the OPAC.
40         @param type The type of link to build
41         @param node The DOM node (<a>..</a>, most likely) whose onclick you wish to set
42         @param thing The data need to set the action for the specific type.  For
43                 example, 'thing' is the record id for 'marc' and 'copy' types.
44 */
45 function makeXULLink(type, node, thing) {
46
47         var p = opac_page_thing;
48         switch(type) {
49
50                 case "marc":
51                         node.onclick = function(thing) { 
52                                 spawn_marc_editor( 
53                                         p.w.app_shell, 'new_tab', 'main_tabbox', 
54                                                 { 'find_this_id' : thing } ).find_this_id = thing;
55                         };
56                         break;
57
58                 case "copy":
59                         node.onclick = function(thing) { 
60                                 spawn_copy_browser(
61                                         p.w.app_shell, 'new_tab', 'main_tabbox', 
62                                                 { 'find_this_id' : thing }).find_this_id = thing;
63                         };
64                         break;
65         }
66 }
67
68
69 /* -------------------------------------------------------------------------- 
70         back-forward
71         -------------------------------------------------------------------------- */
72 function opac_build_navigation(p) {
73         p.webForward = function webForward() {
74                 try {
75                         if(p.opac_iframe.webNavigation.canGoForward)
76                                 p.opac_iframe.webNavigation.goForward();
77                 } catch(E) {
78                         sdump('D_OPAC','goForward error: ' + js2JSON(E) + '\n');
79                 }
80         }
81
82         p.webBack = function webBack() {
83                 try {
84                         if(p.opac_iframe.webNavigation.canGoBack)
85                                 p.opac_iframe.webNavigation.goBack();
86                 } catch(E) {
87                         sdump('D_OPAC','goBack error: ' + js2JSON(E) + '\n');
88                 }
89         }
90 }
91
92
93
94
95
96
97 /* -------------------------------------------------------------------------- 
98         XUL Callbacks
99         -------------------------------------------------------------------------- */
100
101 /*
102 function opac_build_callbacks(p) {
103         p.xulEvtRecordResultDisplayed = function(ui_obj, record) {
104                 ui_obj.addItem("Edit MARC", function() { 
105                                 spawn_marc_editor( 
106                                         p.w.app_shell, 'new_tab', 'main_tabbox', { 
107                                                 'find_this_id' : record.doc_id() 
108                                         } 
109                                 ).find_this_id = record.doc_id();
110                         }
111                 );
112
113                 ui_obj.addItem("Open Copy Browser", function() { 
114                                 spawn_copy_browser(
115                                         p.w.app_shell, 'new_tab', 'main_tabbox', {
116                                                 'find_this_id' : record.doc_id()
117                                         }
118                                 ).find_this_id = record.doc_id();
119                         }
120                 );
121
122         }
123
124         p.xulEvtMRResultDisplayed = function(ui_obj, record) {
125                 sdump('D_OPAC',"xulEvtMRRsultsDisplayed()\n");
126         }
127
128
129         p.xulEvtRecordDetailDisplayed = function(ui_obj, record) {
130                 ui_obj.addItem("Edit MARC", function() { 
131                                 spawn_marc_editor( 
132                                         p.w.app_shell, 'new_tab', 'main_tabbox', { 
133                                                 'find_this_id' : record.doc_id() 
134                                         } 
135                                 ).find_this_id = record.doc_id();
136                         }
137                 );
138
139                 ui_obj.addItem("Open Copy Browser", function() { 
140                                 spawn_copy_browser(
141                                         p.w.app_shell, 'new_tab', 'main_tabbox', {
142                                                 'find_this_id' : record.doc_id()
143                                         }
144                                 ).find_this_id = record.doc_id();
145                         }
146                 );
147         }
148
149         p.xulEvtViewMARC = function( node, record ) {
150                 node.onclick = p.buildViewMARCWindow(record);
151         }
152
153
154
155         p.buildViewMARCWindow = function(record) {
156         
157         debug("Setting up view marc with record " + record.doc_id());
158         
159         var func = function() { marc_view(p.w.app_shell,record.doc_id()); }
160         return func;
161         }
162
163
164 }
165 */