won't have opac view in staff cat details page
[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://dev.gapines.org/"
4
5 /* listen for page changes */
6
7 function buildProgressListener(p) {
8         sdump('D_OPAC',arg_dump(arguments));
9         var progressListener = {
10                 onProgressChange        : function(){},
11                 onLocationChange        : function(){},
12                 onStatusChange          : function(){},
13                 onSecurityChange        : function(){},
14                 onStateChange           : function ( webProgress, request, stateFlags, status) {
15                         const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
16                         const nsIChannel = Components.interfaces.nsIChannel;
17                         if (stateFlags == 65540 || stateFlags == 65537 || stateFlags == 65552) { return; }
18                         dump('onStateChange: stateFlags = ' + stateFlags + ' status = ' + status + '\n');
19                         if (stateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
20                                 dump('\tSTATE_IS_REQUEST\n');
21                         }
22                         if (stateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) {
23                                 dump('\tSTATE_IS_DOCUMENT\n');
24                                 if( stateFlags & nsIWebProgressListener.STATE_STOP ) set_opac_vars(p); 
25                         }
26                         if (stateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
27                                 dump('\tSTATE_IS_NETWORK\n');
28                         }
29                         if (stateFlags & nsIWebProgressListener.STATE_IS_WINDOW) {
30                                 dump('\tSTATE_IS_WINDOW\n');
31                         }
32                         if (stateFlags & nsIWebProgressListener.STATE_START) {
33                                 dump('\tSTATE_START\n');
34                         }
35                         if (stateFlags & nsIWebProgressListener.STATE_REDIRECTING) {
36                                 dump('\tSTATE_REDIRECTING\n');
37                         }
38                         if (stateFlags & nsIWebProgressListener.STATE_TRANSFERING) {
39                                 dump('\tSTATE_TRANSFERING\n');
40                         }
41                         if (stateFlags & nsIWebProgressListener.STATE_NEGOTIATING) {
42                                 dump('\tSTATE_NEGOTIATING\n');
43                         }
44                         if (stateFlags & nsIWebProgressListener.STATE_STOP) {
45                                 dump('\tSTATE_STOP\n');
46                         }
47                 }
48         }
49         progressListener.QueryInterface = function(){return this;};
50         return progressListener;
51 }
52
53 /* init the opac */
54 function opac_init(p) {
55         sdump('D_OPAC',"Initing OPAC\n");
56
57         p.opac_progressListener = buildProgressListener(p);
58
59         p.opac_iframe = p.w.document.getElementById('opac_opac_iframe');
60         p.opac_iframe.addProgressListener(p.opac_progressListener, 
61                 Components.interfaces.nsIWebProgress.NOTIFY_ALL );
62         p.opac_iframe.setAttribute("src", OPAC_URL) 
63 }
64
65 /* shoves data into the OPAC's space */
66 function set_opac_vars(p) {
67         sdump('D_OPAC',arg_dump(arguments));
68         p.opac_iframe.contentWindow.IAMXUL = true;
69         p.opac_iframe.contentWindow.xulG = mw.G;
70         p.opac_iframe.contentWindow.attachEvt("rresult", "recordDrawn", 
71                 function(id,node){opac_make_details_page(p,id,node)});
72         p.opac_iframe.removeProgressListener(p.opac_progressListener);
73         p.opac_iframe.addProgressListener(p.opac_progressListener, 
74                 Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT );
75
76 }
77
78 function opac_make_details_page(p, id) {
79         sdump('D_OPAC',arg_dump(arguments));
80         dump("Node HREF attribute is: " + node.getAttribute("href") + "\n and doc id is " + id +'\n');
81         var f = function(ev) {
82                 spawn_record_details(
83                         p.w.app_shell, 'new_tab', 'main_tabbox', {
84                                 'find_this_id' : id
85                                 /* , 'opac_url' : node.getAttribute('href')*/
86                         }
87                 ).find_this_id = id;
88                 ev.preventDefault();
89                 ev.stopPropagation();
90                 return true;
91         }
92         node.addEventListener( 'click', f, false );
93 }
94
95 /* -------------------------------------------------------------------------- 
96         back-forward
97         -------------------------------------------------------------------------- */
98 function opac_build_navigation(p) {
99         p.webForward = function webForward() {
100                 try {
101                         if(p.opac_iframe.webNavigation.canGoForward)
102                                 p.opac_iframe.webNavigation.goForward();
103                 } catch(E) {
104                         sdump('D_OPAC','goForward error: ' + js2JSON(E) + '\n');
105                 }
106         }
107
108         p.webBack = function webBack() {
109                 try {
110                         if(p.opac_iframe.webNavigation.canGoBack)
111                                 p.opac_iframe.webNavigation.goBack();
112                 } catch(E) {
113                         sdump('D_OPAC','goBack error: ' + js2JSON(E) + '\n');
114                 }
115         }
116 }
117
118
119
120
121
122
123